Mark V
1: <?php
2: namespace MOC\V\Core\FileSystem\Component\Bridge\Repository;
3:
4: use MOC\V\Core\FileSystem\Component\Bridge\Bridge;
5: use MOC\V\Core\FileSystem\Component\IBridgeInterface;
6: use MOC\V\Core\FileSystem\Component\Parameter\Repository\FileParameter;
7: use MOC\V\Core\FileSystem\Vendor\Universal\Download;
8: use MOC\V\Core\GlobalsKernel\GlobalsKernel;
9:
10: /**
11: * Class UniversalDownload
12: *
13: * @package MOC\V\Core\FileSystem\Component\Bridge
14: */
15: class UniversalDownload extends Bridge implements IBridgeInterface
16: {
17:
18: /** @var Download $Instance */
19: private $Instance = null;
20:
21: /**
22: * @param FileParameter $FileLocation
23: * @param FileParameter $FileName
24: */
25: public function __construct(FileParameter $FileLocation, FileParameter $FileName = null)
26: {
27:
28: parent::__construct();
29: $this->Instance = new Download($FileLocation->getFile(), ( $FileName ? $FileName->getFile() : null ));
30: }
31:
32: /**
33: * @return string
34: */
35: public function getRealPath()
36: {
37:
38: $SERVER = GlobalsKernel::getGlobals()->getSERVER();
39: $SplFileInfo = (new \SplFileInfo($this->Instance->getLocation()));
40: if (!$SplFileInfo->getRealPath()) {
41: $SplFileInfo = (new \SplFileInfo($SERVER['DOCUMENT_ROOT'].$this->Instance->getLocation()));
42: }
43: return $SplFileInfo->getRealPath() ? $SplFileInfo->getRealPath() : '';
44: }
45:
46: /**
47: * @return string
48: */
49: public function getLocation()
50: {
51:
52: return $this->Instance->getLocation();
53: }
54:
55: /**
56: * @return string
57: */
58: public function __toString()
59: {
60:
61: return (string)$this->Instance;
62: }
63: }
64: