/** * Prepared Files collection for current directory * * @return \Magento\Framework\Data\Collection\Filesystem */ public function getFiles() { if (!$this->_filesCollection) { $this->_filesCollection = $this->_imageStorage->getFilesCollection($this->_imageHelper->getCurrentPath(), $this->_getMediaType()); } return $this->_filesCollection; }
/** * Json tree builder * * @return string */ public function getTreeJson() { $storageRoot = $this->_cmsWysiwygImages->getStorageRoot(); $collection = $this->_coreRegistry->registry('storage')->getDirsCollection($this->_cmsWysiwygImages->getCurrentPath()); $jsonArray = array(); foreach ($collection as $item) { $jsonArray[] = array('text' => $this->_cmsWysiwygImages->getShortFilename($item->getBasename(), 20), 'id' => $this->_cmsWysiwygImages->convertPathToId($item->getFilename()), 'path' => substr($item->getFilename(), strlen($storageRoot)), 'cls' => 'folder'); } return \Zend_Json::encode($jsonArray); }
public function testGetCurrentPathThrowException() { $this->setExpectedException('\\Magento\\Framework\\Exception\\LocalizedException', 'The directory PATH/wysiwyg is not writable by server.'); $this->directoryWriteMock->expects($this->once())->method('isExist')->willReturn(false); $this->directoryWriteMock->expects($this->any())->method('create')->willThrowException(new \Magento\Framework\Exception\FileSystemException(__('Could not create a directory.'))); $this->imagesHelper->getCurrentPath(); $this->fail('An expected exception has not been raised.'); }
/** * Resize images on the fly in controller action * * @param string $filename File basename * @return bool|string Thumbnail path or false for errors */ public function resizeOnTheFly($filename) { $path = $this->getSession()->getCurrentPath(); if (!$path) { $path = $this->_cmsWysiwygImages->getCurrentPath(); } return $this->resizeFile($path . '/' . $filename); }