From 06ceb7023f6812fe40d34f9b14ce5726b52a05df Mon Sep 17 00:00:00 2001 From: alojua Date: Tue, 12 Dec 2017 16:24:48 +0100 Subject: [PATCH] Code improvements for crudEAV templates generation --- .../${Entityname}/Edit/DeleteButton.php | 3 +- .../Adminhtml/${Entityname}/Delete.php | 4 +- .../Adminhtml/${Entityname}/InlineEdit.php | 4 +- .../Model/ResourceModel/${Entityname}.php | 1 - .../${Entityname}/Collection.php | 5 + .../${Entityname}/Grid/Collection.php | 21 ++- .../Adminhtml/${Entityname}/Save.php | 23 ++- .../fileEAVAttribute/Model/${Entityname}.php | 45 ++--- .../Backend/${Fileattributename}.php | 149 ++------------- .../Attribute/Backend/ImageAbstract.php | 169 ++++++++++++++++++ .../Attribute/Backend/ImageFactory.php | 60 +++++++ .../Form/${Entityname}/DataProvider.php | 31 ++-- .../Controller/Adminhtml/File/Uploader.php | 2 +- .../fileProcessor/Helper/FileProcessor.php | 6 +- 14 files changed, 317 insertions(+), 206 deletions(-) create mode 100644 templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageAbstract.php create mode 100644 templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageFactory.php diff --git a/templates/crudEAV/Block/Adminhtml/${Entityname}/Edit/DeleteButton.php b/templates/crudEAV/Block/Adminhtml/${Entityname}/Edit/DeleteButton.php index 0a0c448..75dfff0 100644 --- a/templates/crudEAV/Block/Adminhtml/${Entityname}/Edit/DeleteButton.php +++ b/templates/crudEAV/Block/Adminhtml/${Entityname}/Edit/DeleteButton.php @@ -56,7 +56,8 @@ public function getButtonData() 'data_attribute' => [ 'url' => $this->getDeleteUrl() ], - 'on_click' => 'deleteConfirm(\'' . __("Are you sure you want to do this?") . '\', \'' . $this->getDeleteUrl() . '\')', + 'on_click' => + 'deleteConfirm(\'' . __("Are you sure you want to do this?") . '\', \'' . $this->getDeleteUrl() . '\')', 'sort_order' => 20, ]; return $data; diff --git a/templates/crudEAV/Controller/Adminhtml/${Entityname}/Delete.php b/templates/crudEAV/Controller/Adminhtml/${Entityname}/Delete.php index a356d9a..5223805 100644 --- a/templates/crudEAV/Controller/Adminhtml/${Entityname}/Delete.php +++ b/templates/crudEAV/Controller/Adminhtml/${Entityname}/Delete.php @@ -21,8 +21,8 @@ class Delete extends Action * @param ${Entityname}Factory $objectFactory */ public function __construct( - Context $context, - ${Entityname}Factory $objectFactory + Context $context, + ${Entityname}Factory $objectFactory ) { $this->objectFactory = $objectFactory; parent::__construct($context); diff --git a/templates/crudEAV/Controller/Adminhtml/${Entityname}/InlineEdit.php b/templates/crudEAV/Controller/Adminhtml/${Entityname}/InlineEdit.php index 7f7c909..b5ed051 100644 --- a/templates/crudEAV/Controller/Adminhtml/${Entityname}/InlineEdit.php +++ b/templates/crudEAV/Controller/Adminhtml/${Entityname}/InlineEdit.php @@ -64,8 +64,8 @@ public function execute() try { $this->objectCollection ->setStoreId($this->getRequest()->getParam('store', 0)) - ->addFieldToFilter('entity_id', array('in' => array_keys($postItems))) - ->walk('saveCollection', array($postItems)); + ->addFieldToFilter('entity_id', ['in' => array_keys($postItems)]) + ->walk('saveCollection', [$postItems]); } catch (\Exception $e) { $messages[] = __('There was an error saving the data: ') . $e->getMessage(); $error = true; diff --git a/templates/crudEAV/Model/ResourceModel/${Entityname}.php b/templates/crudEAV/Model/ResourceModel/${Entityname}.php index 91abad8..8d33306 100644 --- a/templates/crudEAV/Model/ResourceModel/${Entityname}.php +++ b/templates/crudEAV/Model/ResourceModel/${Entityname}.php @@ -84,7 +84,6 @@ public function getStoreId() return $this->_storeId; } - /** * Set Attribute values to be saved * diff --git a/templates/crudEAV/Model/ResourceModel/${Entityname}/Collection.php b/templates/crudEAV/Model/ResourceModel/${Entityname}/Collection.php index 45da67d..53160f4 100644 --- a/templates/crudEAV/Model/ResourceModel/${Entityname}/Collection.php +++ b/templates/crudEAV/Model/ResourceModel/${Entityname}/Collection.php @@ -22,6 +22,11 @@ use Magento\Store\Model\StoreManagerInterface; use Psr\Log\LoggerInterface; +/** + * Class Collection + * @package ${Vendorname}\${Modulename}\Model\ResourceModel\${Entityname} + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Collection extends AbstractCollection { /** diff --git a/templates/crudEAV/Model/ResourceModel/${Entityname}/Grid/Collection.php b/templates/crudEAV/Model/ResourceModel/${Entityname}/Grid/Collection.php index ddcb4ad..473e939 100644 --- a/templates/crudEAV/Model/ResourceModel/${Entityname}/Grid/Collection.php +++ b/templates/crudEAV/Model/ResourceModel/${Entityname}/Grid/Collection.php @@ -25,7 +25,8 @@ /** * Class Collection - * Collection for displaying grid + * @package ${Vendorname}\${Modulename}\Model\ResourceModel\${Entityname}\Grid + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Collection extends ${Entityname}Collection implements SearchResultInterface { @@ -69,9 +70,21 @@ public function __construct( $eventObject, $resourceModel, $model = '${Vendorname}\${Modulename}\Ui\Component\Listing\DataProvider\Document', - AdapterInterface $connection = null) - { - parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $eavConfig, $resource, $eavEntityFactory, $resourceHelper, $universalFactory, $storeManager, $connection); + AdapterInterface $connection = null + ) { + parent::__construct( + $entityFactory, + $logger, + $fetchStrategy, + $eventManager, + $eavConfig, + $resource, + $eavEntityFactory, + $resourceHelper, + $universalFactory, + $storeManager, + $connection + ); $this->_eventPrefix = $eventPrefix; $this->_eventObject = $eventObject; $this->_init($model, $resourceModel); diff --git a/templates/fileEAVAttribute/Controller/Adminhtml/${Entityname}/Save.php b/templates/fileEAVAttribute/Controller/Adminhtml/${Entityname}/Save.php index c08b634..d830920 100644 --- a/templates/fileEAVAttribute/Controller/Adminhtml/${Entityname}/Save.php +++ b/templates/fileEAVAttribute/Controller/Adminhtml/${Entityname}/Save.php @@ -9,6 +9,7 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use ${Vendorname}\${Modulename}\Model\${Entityname}\Attribute\Backend\ImageFactory; use ${Vendorname}\${Modulename}\Model\${Entityname}Factory; class Save extends Action @@ -58,7 +59,8 @@ public function execute() $objectInstance->load($data['entity_id']); $params['entity_id'] = $data['entity_id']; } - $this->${fileattributename}Preprocessing($data); + $imageData = $this->preparedImagesData($data); + $data = array_merge($data, $imageData); $objectInstance->addData($data); $this->_eventManager->dispatch( @@ -87,19 +89,16 @@ public function execute() return $resultRedirect->setPath('*/*/'); } - /** - * ${Fileattributename} data preprocessing - * - * @param array $data - * - * @return array - */ - protected function ${fileattributename}Preprocessing(&$data) + protected function preparedImagesData(array $data): array { - if (empty($data['${fileattributename}'])) { - unset($data['${fileattributename}']); - $data['${fileattributename}']['delete'] = true; + $imagesData = []; + $imageAttributeCodes = array_keys(ImageFactory::IMAGE_ATTRIBUTE_CODES); + foreach ($imageAttributeCodes as $imageAttrCode) { + if (empty($data[$imageAttrCode])) { + $imagesData[$imageAttrCode]['delete'] = true; + } } + return $imagesData; } } diff --git a/templates/fileEAVAttribute/Model/${Entityname}.php b/templates/fileEAVAttribute/Model/${Entityname}.php index a827c5d..defe098 100644 --- a/templates/fileEAVAttribute/Model/${Entityname}.php +++ b/templates/fileEAVAttribute/Model/${Entityname}.php @@ -15,7 +15,8 @@ use Magento\Framework\Model\ResourceModel\AbstractResource; use Magento\Framework\Data\Collection\AbstractDb; use Magento\Framework\Registry; -use ${Vendorname}\${Modulename}\Model\${Entityname}\Attribute\Backend\${Fileattributename}Factory; +use ${Vendorname}\${Modulename}\Model\${Entityname}\Attribute\Backend\ImageAbstract; +use ${Vendorname}\${Modulename}\Model\${Entityname}\Attribute\Backend\ImageFactory; class ${Entityname} extends AbstractModel implements IdentityInterface { @@ -23,23 +24,20 @@ class ${Entityname} extends AbstractModel implements IdentityInterface * CMS page cache tag */ const CACHE_TAG = '${vendorname}_${modulename}_${entityname}'; - /** * @var string */ protected $_cacheTag = '${vendorname}_${modulename}_${entityname}'; - /** * Prefix of model events names * * @var string */ protected $_eventPrefix = '${vendorname}_${modulename}_${entityname}'; - /** - * @var ${Fileattributename}Factory + * @var ImageFactory */ - private $${fileattributename}Factory; + private $imageFactory; /** * Initialize resource model @@ -52,17 +50,8 @@ protected function _construct() $this->_init('${Vendorname}\${Modulename}\Model\ResourceModel\${Entityname}'); } - /** - * Reference constructor. - * @param ${Fileattributename}Factory $${fileattributename}Factory - * @param Context $context - * @param Registry $registry - * @param AbstractResource|null $resource - * @param AbstractDb|null $resourceCollection - * @param array $data - */ public function __construct( - ${Fileattributename}Factory $${fileattributename}Factory, + ImageFactory $imageFactory, Context $context, Registry $registry, AbstractResource $resource = null, @@ -76,7 +65,7 @@ public function __construct( $resourceCollection, $data ); - $this->${fileattributename}Factory = $${fileattributename}Factory; + $this->imageFactory = $imageFactory; } /** @@ -104,26 +93,22 @@ public function saveCollection(array $data) return $this; } - /** - * Get ${Fileattributename} in right format to edit in admin form - * - * @return array - */ - public function get${Fileattributename}ValueForForm() + public function getImageValueForForm(string $imageAttrCode): array { - $${fileattributename} = $this->${fileattributename}Factory->create(); - return $${fileattributename}->getFileValueForForm($this); + /** @var ImageAbstract $image */ + $image = $this->imageFactory->create($imageAttrCode); + return $image->getFileValueForForm($this); } /** - * Get ${Fileattributename} Src to display in frontend - * + * @param string $imageAttrCode * @return mixed */ - public function get${Fileattributename}Src() + public function getMainImageSrc(string $imageAttrCode) { - $${fileattributename} = $this->${fileattributename}Factory->create(); - return $${fileattributename}->getFileInfo($this)->getUrl(); + /** @var ImageAbstract $image */ + $image = $this->imageFactory->create($imageAttrCode); + return $image->getFileInfo($this)->getUrl(); } } diff --git a/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/${Fileattributename}.php b/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/${Fileattributename}.php index 475b074..69de261 100644 --- a/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/${Fileattributename}.php +++ b/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/${Fileattributename}.php @@ -8,150 +8,21 @@ namespace ${Vendorname}\${Modulename}\Model\${Entityname}\Attribute\Backend; -use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend; -use Magento\Framework\DataObject; -use ${Vendorname}\${Modulename}\Helper\FileProcessor; - -class ${Fileattributename} extends AbstractBackend +class ${Fileattributename} extends ImageAbstract { /** * @var string */ - const FILES_SUBDIR = '${fileattributename}'; - - /** - * @var FileProcessor - */ - protected $fileProcessor; - - /** - * @param FileProcessor $fileProcessor - */ - public function __construct(FileProcessor $fileProcessor) - { - $this->fileProcessor = $fileProcessor; - } - - /** - * Prepare File data before saving object - * - * @param \Magento\Framework\DataObject $object - * - * @return $this - * @throws \Exception - */ - public function beforeSave($object) //@codingStandardsIgnoreLine - { - parent::beforeSave($object); - $file = $object->get${Fileattributename}(); - if (!is_array($file)) { - $object->setSkipSave${Fileattributename}(true); - return $this; - } - - if (isset($file['delete'])) { - $object->set${Fileattributename}(null); - return $this; - } - - $file = reset($file) ?: []; - if (!isset($file['file'])) { - throw new LocalizedException( - __('${Fileattributename} does not contain field \'file\'') - ); - } - // Add file related data to object - $object->set${Fileattributename}($file['file']); - $object->setFileExists(isset($file['exists'])); - - return $this; - } - - /** - * Save uploaded file and remove temporary file after saving object - * - * @param \Magento\Framework\DataObject $object - * - * @return $this - * @throws \Exception - */ - public function afterSave($object) //@codingStandardsIgnoreLine - { - parent::afterSave($object); - // if file already exists we do not need to save any new file - if ($object->getFileExists() || $object->getSkipSave${Fileattributename}()) { - return $this; - } + const ATTRIBUTE_CODE = '${fileattributename}'; - // Delete old file if new one has changed - if ($object->getOrigData('${fileattributename}') && $object->get${Fileattributename}() != $object->getOrigData('${fileattributename}')) { - $this->fileProcessor->delete($this->getFileSubDir($object), $object->getOrigData('${fileattributename}')); - } - - if ($object->get${Fileattributename}()) { - if (!$this->fileProcessor->saveFileFromTmp($object->get${Fileattributename}(), $this->getFileSubDir($object))) { - throw new \Exception('There was an error saving the file'); - } - } - } - - /** - * Subdir where files are stored - * - * @param \Magento\Framework\DataObject $object - * @return string - */ - protected function getFileSubDir($object) - { - return self::FILES_SUBDIR . '/' . $object->getId(); - } - - /** - * Delete media file before an ${fileattributename} row in database is removed - * @param \Magento\Framework\DataObject $object - * @return $this - */ - public function beforeDelete($object) //@codingStandardsIgnoreLine - { - parent::beforeDelete($object); - // Delete file from disk before the object is deleted from database - if ($object->get${Fileattributename}()) { - $this->fileProcessor->delete($this->getFileSubDir($object), $object->get${Fileattributename}()); - } - return $this; - } - - /** - * Get full info from file - * - * @param \Magento\Framework\DataObject $object - * @return DataObject - */ - public function getFileInfo($object) - { - if (!$object->getData('file_info') && $object->get${Fileattributename}()) { - $fileInfoObject = new DataObject(); - $fileInfo = $this->fileProcessor->getFileInfo($object->get${Fileattributename}(), $this->getFileSubDir($object)); - if ($fileInfo) { - $fileInfoObject->setData($fileInfo); - } - $object->setFileInfo($fileInfoObject); - } + protected function subdirName(): string +{ + return self::ATTRIBUTE_CODE; +} - return $object->getData('file_info'); - } + protected function attributeCode(): string +{ + return self::ATTRIBUTE_CODE; +} - /** - * Return file info in a format valid for ui form fields - * - * @param \Magento\Framework\DataObject $object - * @return array - */ - public function getFileValueForForm($object) - { - if ($this->getFileInfo($object)->getFile()) { - return [$this->getFileInfo($object)->getData()]; - } - return []; - } } diff --git a/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageAbstract.php b/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageAbstract.php new file mode 100644 index 0000000..a6b2c0e --- /dev/null +++ b/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageAbstract.php @@ -0,0 +1,169 @@ +fileProcessor = $fileProcessor; + } + + /** + * Dir name where the image will be saved + * + * @return string + */ + abstract protected function subdirName(): string; + + /** + * Attribute code to get image path from object + * + * @return string + */ + abstract protected function attributeCode(): string; + + private function skipSaveAttributeCode(): string + { + return 'skip_save_'.$this->attributeCode(); + } + + /** + * Prepare File data before saving object + * + * @param \Magento\Framework\DataObject $object + * + * @return $this + * @throws \Exception + */ + public function beforeSave($object) //@codingStandardsIgnoreLine + { + parent::beforeSave($object); + $file = $object->getData($this->attributeCode()); + if (!is_array($file)) { + $object->setData($this->skipSaveAttributeCode(), true); + return $this; + } + if (isset($file['delete'])) { + $object->setData($this->attributeCode(), null); + return $this; + } + $file = reset($file) ?: []; + if (!isset($file['file'])) { + throw new \Exception( + __('Image "%1" does not contain field \'file\'', [$this->attributeCode()]) + ); + } + $object->setData($this->attributeCode(), $file['file']); + if (isset($file['exists'])) { + $object->setData($this->skipSaveAttributeCode(), true); + } + return $this; + } + + /** + * Save uploaded file and remove temporary file after saving object + * + * @param \Magento\Framework\DataObject $object + * + * @return $this + * @throws \Exception + */ + public function afterSave($object) //@codingStandardsIgnoreLine + { + parent::afterSave($object); + + if (true == $object->getData($this->skipSaveAttributeCode())) { + return $this; + } + + $oldFilename = $object->getOrigData($this->attributeCode()); + $newFilename = $object->getData($this->attributeCode()); + if ($oldFilename && $oldFilename != $newFilename) { + $this->fileProcessor->delete($this->getFileSubDir($object), $oldFilename); + } + + if ($newFilename) { + if (!$this->fileProcessor->saveFileFromTmp($newFilename, $this->getFileSubDir($object))) { + throw new \Exception('There was an error saving the file'); + } + } + } + + /** + * Subdir where files are stored + * + * @param \Magento\Framework\DataObject $object + * @return string + */ + protected function getFileSubDir($object) + { + return $this->subdirName() . '/' . $object->getId(); + } + + /** + * Delete media file before the attribute value in table is removed + * + * @param \Magento\Framework\DataObject $object + * @return $this + */ + public function beforeDelete($object) //@codingStandardsIgnoreLine + { + parent::beforeDelete($object); + $filename = $object->getData($this->attributeCode()); + if ($filename) { + $this->fileProcessor->delete($this->getFileSubDir($object), $filename); + } + return $this; + } + + /** + * Get full info from file + * + * @param \Magento\Framework\DataObject $object + * @return DataObject + */ + public function getFileInfo($object) + { + $fileInfoObject = new DataObject(); + $filename = $object->getData($this->attributeCode()); + $fileInfo = $this->fileProcessor->getFileInfo($filename, $this->getFileSubDir($object)); + if ($fileInfo) { + $fileInfoObject->setData($fileInfo); + } + return $fileInfoObject; + } + + /** + * Return file info in a format valid for ui form fields + * + * @param \Magento\Framework\DataObject $object + * @return array + */ + public function getFileValueForForm($object) + { + $fileInfo = $this->getFileInfo($object); + if ($fileInfo->getFile()) { + return [$fileInfo->getData()]; + } + return []; + } +} diff --git a/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageFactory.php b/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageFactory.php new file mode 100644 index 0000000..204a0ed --- /dev/null +++ b/templates/fileEAVAttribute/Model/${Entityname}/Attribute/Backend/ImageFactory.php @@ -0,0 +1,60 @@ + ${Fileattributename}::class, + ]; + + /** + * Object Manager instance + * + * @var ObjectManagerInterface + */ + protected $objectManager = null; + + /** + * Factory constructor + * + * @param ObjectManagerInterface $objectManager + */ + public function __construct(ObjectManagerInterface $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Create corresponding class instance + * + * @param $imageAttributeCode + * @param array $data + * @return ObjectType + */ + public function create(string $imageAttributeCode, array $data = []) + { + if (empty(self::IMAGE_ATTRIBUTE_CODES[$imageAttributeCode])) { + throw new InvalidArgumentException(sprintf('"%s": isn\'t allowed', $imageAttributeCode)); + } + + $resultInstance = $this->objectManager->create(self::IMAGE_ATTRIBUTE_CODES[$imageAttributeCode], $data); + if (!$resultInstance instanceof ImageAbstract) { + throw new InvalidArgumentException(sprintf('%s isn\'t instance of %s', + get_class($resultInstance), + ImageAbstract::class + )); + } + + return $resultInstance; + } +} \ No newline at end of file diff --git a/templates/fileEAVAttribute/Ui/Component/Form/${Entityname}/DataProvider.php b/templates/fileEAVAttribute/Ui/Component/Form/${Entityname}/DataProvider.php index 8ed40e4..beed067 100644 --- a/templates/fileEAVAttribute/Ui/Component/Form/${Entityname}/DataProvider.php +++ b/templates/fileEAVAttribute/Ui/Component/Form/${Entityname}/DataProvider.php @@ -10,6 +10,8 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool; use Magento\Ui\DataProvider\AbstractDataProvider; +use ${Vendorname}\${Modulename}\Model\${Entityname}; +use ${Vendorname}\${Modulename}\Model\${Entityname}\Attribute\Backend\ImageFactory; use ${Vendorname}\${Modulename}\Model\ResourceModel\${Entityname}\Collection; class DataProvider extends AbstractDataProvider @@ -71,19 +73,26 @@ public function getData() { if (!$this->loadedData) { $storeId = (int)$this->request->getParam('store'); - $this->collection + $${entityname} = $this->collection ->setStoreId($storeId) - ->addAttributeToSelect('*'); - $items = $this->collection->getItems(); - foreach ($items as $item) { - if ($item->get${Fileattributename}()) { - $item->set${Fileattributename}($item->get${Fileattributename}ValueForForm()); - } - $item->setStoreId($storeId); - $this->loadedData[$item->getId()] = $item->getData(); - break; - } + ->addAttributeToSelect('*') + ->getFirstItem(); + $${entityname}->setStoreId($storeId); + $${entityname}->addData($this->${entityname}ImagesData($${entityname})); + $this->loadedData[$${entityname}->getId()] = $${entityname}->getData(); } return $this->loadedData; } + + private function ${entityname}ImagesData(${Entityname} $${entityname}): array + { + $imagesData = []; + $imageAttributeCodes = array_keys(ImageFactory::IMAGE_ATTRIBUTE_CODES); + foreach ($imageAttributeCodes as $imageAttrCode) { + if ($${entityname}->getData($imageAttrCode)) { + $imagesData[$imageAttrCode] = $${entityname}->getImageValueForForm($imageAttrCode); + } + } + return $imagesData; + } } diff --git a/templates/fileProcessor/Controller/Adminhtml/File/Uploader.php b/templates/fileProcessor/Controller/Adminhtml/File/Uploader.php index ac2bec3..a9b278e 100644 --- a/templates/fileProcessor/Controller/Adminhtml/File/Uploader.php +++ b/templates/fileProcessor/Controller/Adminhtml/File/Uploader.php @@ -63,7 +63,7 @@ protected function fixFile() $current = current($files); foreach ($current as $key => $value) { if (is_array($value)) { - array_walk_recursive($value, array($this, 'getNonArrayValue')); + array_walk_recursive($value, [$this, 'getNonArrayValue']); } else { $this->fixedFilesArray[$key] = $value; } diff --git a/templates/fileProcessor/Helper/FileProcessor.php b/templates/fileProcessor/Helper/FileProcessor.php index 8dec27a..34f08d1 100644 --- a/templates/fileProcessor/Helper/FileProcessor.php +++ b/templates/fileProcessor/Helper/FileProcessor.php @@ -66,8 +66,7 @@ public function __construct( Filesystem $filesystem, StoreManagerInterface $storeManager, File $backendFile - ) - { + ) { $this->uploaderFactory = $uploaderFactory; $this->storeManager = $storeManager; $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); @@ -127,7 +126,8 @@ protected function getAbsoluteMediaPath($subdir = null) */ protected function getMediaUrl($filename, $subdir = null) { - return $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . $this->getPath($subdir, $filename); + return $this->storeManager->getStore() + ->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . $this->getPath($subdir, $filename); } /**