Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Path.php
Go to the documentation of this file.
1 <?php
8 
11 
15 class Path implements \Magento\Framework\View\Design\Theme\Image\PathInterface
16 {
20  const DEFAULT_PREVIEW_IMAGE = 'Magento_Theme::theme/default_preview.jpg';
21 
27  protected $mediaDirectory;
28 
32  protected $assetRepo;
33 
37  protected $storeManager;
38 
46  public function __construct(
47  \Magento\Framework\Filesystem $filesystem,
48  \Magento\Framework\View\Asset\Repository $assetRepo,
50  ) {
51  $this->mediaDirectory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
52  $this->assetRepo = $assetRepo;
53  $this->storeManager = $storeManager;
54  }
55 
63  {
64  return $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
65  . self::PREVIEW_DIRECTORY_PATH . '/' . $theme->getPreviewImage();
66  }
67 
75  {
76  return $this->mediaDirectory->getAbsolutePath(self::PREVIEW_DIRECTORY_PATH . '/' . $theme->getPreviewImage());
77  }
78 
84  public function getPreviewImageDefaultUrl()
85  {
86  return $this->assetRepo->getUrl(self::DEFAULT_PREVIEW_IMAGE);
87  }
88 
94  public function getImagePreviewDirectory()
95  {
96  return $this->mediaDirectory->getAbsolutePath(self::PREVIEW_DIRECTORY_PATH);
97  }
98 
104  public function getTemporaryDirectory()
105  {
106  return $this->mediaDirectory->getRelativePath('/theme/origin');
107  }
108 }
getPreviewImageUrl(ThemeInterface $theme)
Definition: Path.php:62
$theme
__construct(\Magento\Framework\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Store\Model\StoreManagerInterface $storeManager)
Definition: Path.php:46
getPreviewImagePath(ThemeInterface $theme)
Definition: Path.php:74
$filesystem