101 \
Magento\Framework\View\Design\
Theme\FlyweightFactory $themeFactory
103 parent::__construct($context);
106 $this->_themeFactory = $themeFactory;
108 $this->mediaDirectoryWrite->create($this->mediaDirectoryWrite->getRelativePath($this->getStorageRoot()));
120 return $this->urlEncoder->encode(
$path);
147 return strlen($filename) <= $maxLength ? $filename : substr($filename, 0, $maxLength) .
'...';
157 if (
null === $this->_storageRoot) {
158 $this->_storageRoot = implode(
174 $themeId = $this->
_getRequest()->getParam(self::PARAM_THEME_ID);
175 $theme = $this->_themeFactory->create($themeId);
176 if (!$themeId || !
$theme) {
177 throw new \InvalidArgumentException(
'Theme was not found.');
195 if (!in_array(
$type, $allowedTypes)) {
196 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Invalid type'));
209 $node = $this->
_getRequest()->getParam(self::PARAM_NODE);
210 if ($node !== self::NODE_ROOT) {
211 $node = $this->urlDecoder->decode($node);
212 $nodes = explode(
'/', trim($node,
'/'));
213 $pathPieces = array_merge($pathPieces, $nodes);
215 $pathPieces[] = $this->urlDecoder->decode($this->
_getRequest()->getParam(self::PARAM_FILENAME));
216 return implode(
'/', $pathPieces);
226 if (!$this->_currentPath) {
232 if ($this->mediaDirectoryWrite->isDirectory(
$path) && 0 === strpos(
$path, $currentPath)) {
233 $currentPath = $this->mediaDirectoryWrite->getRelativePath(
$path);
236 $this->_currentPath = $currentPath;
262 if (!$this->mediaDirectoryWrite->isExist($imagePath) || 0 !== strpos($imagePath, $this->
getStorageRoot())) {
263 throw new \InvalidArgumentException(
'The image not found.');
275 $themeId = $this->
_getRequest()->getParam(self::PARAM_THEME_ID);
276 $contentType = $this->
_getRequest()->getParam(self::PARAM_CONTENT_TYPE);
277 $node = $this->
_getRequest()->getParam(self::PARAM_NODE);
279 self::PARAM_THEME_ID => $themeId,
280 self::PARAM_CONTENT_TYPE => $contentType,
281 self::PARAM_NODE => $node
294 ? [
'ttf',
'otf',
'eot',
'svg',
'woff']
295 : [
'jpg',
'jpeg',
'gif',
'png',
'xbm',
'wbmp'];
getThumbnailDirectory($path)
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Filesystem $filesystem, \Magento\Backend\Model\Session $session, \Magento\Framework\View\Design\Theme\FlyweightFactory $themeFactory)
getShortFilename($filename, $maxLength=20)
getThumbnailPath($imageName)
const THUMBNAIL_DIRECTORY
getAllowedExtensionsByType()