diff --git a/Block/Adminhtml/Banner.php b/Block/Adminhtml/Banner.php index a171f63..8daffa9 100644 --- a/Block/Adminhtml/Banner.php +++ b/Block/Adminhtml/Banner.php @@ -36,9 +36,9 @@ class Banner extends Container */ protected function _construct() { - $this->_controller = 'adminhtml_banner'; - $this->_blockGroup = 'Mageplaza_BannerSlider'; - $this->_headerText = __('Banners'); + $this->_controller = 'adminhtml_banner'; + $this->_blockGroup = 'Mageplaza_BannerSlider'; + $this->_headerText = __('Banners'); $this->_addButtonLabel = __('Create New Banner'); parent::_construct(); diff --git a/Block/Adminhtml/Banner/Edit.php b/Block/Adminhtml/Banner/Edit.php index 89b9166..2d98650 100644 --- a/Block/Adminhtml/Banner/Edit.php +++ b/Block/Adminhtml/Banner/Edit.php @@ -24,6 +24,7 @@ use Magento\Backend\Block\Widget\Context; use Magento\Backend\Block\Widget\Form\Container; use Magento\Framework\Registry; +use Mageplaza\BannerSlider\Model\Banner; /** * Class Edit @@ -34,23 +35,22 @@ class Edit extends Container /** * Core registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $coreRegistry; /** * constructor * - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\Block\Widget\Context $context + * @param Registry $coreRegistry + * @param Context $context * @param array $data */ public function __construct( Registry $coreRegistry, Context $context, array $data = [] - ) - { + ) { parent::__construct($context, $data); $this->coreRegistry = $coreRegistry; @@ -63,7 +63,7 @@ public function __construct( */ protected function _construct() { - $this->_objectId = 'banner_id'; + $this->_objectId = 'banner_id'; $this->_blockGroup = 'Mageplaza_BannerSlider'; $this->_controller = 'adminhtml_banner'; parent::_construct(); @@ -94,7 +94,7 @@ protected function _construct() */ public function getHeaderText() { - /** @var \Mageplaza\BannerSlider\Model\Banner $banner */ + /** @var Banner $banner */ $banner = $this->getBanner(); if ($banner->getId()) { return __("Edit Banner '%1'", $this->escapeHtml($banner->getName())); diff --git a/Block/Adminhtml/Banner/Edit/Form.php b/Block/Adminhtml/Banner/Edit/Form.php index 9438230..b36bf13 100644 --- a/Block/Adminhtml/Banner/Edit/Form.php +++ b/Block/Adminhtml/Banner/Edit/Form.php @@ -24,6 +24,7 @@ use Magento\Backend\Block\Template\Context; use Magento\Backend\Block\Widget\Form\Generic; use Magento\Framework\Data\FormFactory; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; use Mageplaza\BannerSlider\Model\Config\Source\Template; @@ -58,8 +59,7 @@ public function __construct( FormFactory $formFactory, Template $template, array $data = [] - ) - { + ) { $this->template = $template; parent::__construct($context, $registry, $formFactory, $data); @@ -67,7 +67,7 @@ public function __construct( /** * @return Generic - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareForm() { diff --git a/Block/Adminhtml/Banner/Edit/Tab/Banner.php b/Block/Adminhtml/Banner/Edit/Tab/Banner.php index 121d220..eecddb9 100644 --- a/Block/Adminhtml/Banner/Edit/Tab/Banner.php +++ b/Block/Adminhtml/Banner/Edit/Tab/Banner.php @@ -29,6 +29,7 @@ use Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory; use Magento\Framework\Convert\DataObject; use Magento\Framework\Data\FormFactory; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; use Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\Image as BannerImage; use Mageplaza\BannerSlider\Helper\Data; @@ -45,7 +46,7 @@ class Banner extends Generic implements TabInterface /** * Type options * - * @var \Mageplaza\BannerSlider\Model\Config\Source\Type + * @var Type */ protected $typeOptions; @@ -59,27 +60,27 @@ class Banner extends Generic implements TabInterface /** * Status options * - * @var \Magento\Config\Model\Config\Source\Enabledisable + * @var Enabledisable */ protected $statusOptions; /** - * @var \Mageplaza\BannerSlider\Helper\Image + * @var HelperImage */ protected $imageHelper; /** - * @var \Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory + * @var FieldFactory */ protected $_fieldFactory; /** - * @var \Magento\Framework\Convert\DataObject + * @var DataObject */ protected $_objectConverter; /** - * @var \Magento\Cms\Model\Wysiwyg\Config + * @var WysiwygConfig */ protected $_wysiwygConfig; @@ -110,28 +111,27 @@ public function __construct( DataObject $objectConverter, WysiwygConfig $wysiwygConfig, array $data = [] - ) - { - $this->typeOptions = $typeOptions; - $this->template = $template; - $this->statusOptions = $statusOptions; - $this->imageHelper = $imageHelper; - $this->_fieldFactory = $fieldFactory; + ) { + $this->typeOptions = $typeOptions; + $this->template = $template; + $this->statusOptions = $statusOptions; + $this->imageHelper = $imageHelper; + $this->_fieldFactory = $fieldFactory; $this->_objectConverter = $objectConverter; - $this->_wysiwygConfig = $wysiwygConfig; + $this->_wysiwygConfig = $wysiwygConfig; parent::__construct($context, $registry, $formFactory, $data); } /** * @return Generic - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareForm() { /** @var \Mageplaza\BannerSlider\Model\Banner $banner */ $banner = $this->_coreRegistry->registry('mpbannerslider_banner'); - $form = $this->_formFactory->create(); + $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('banner_'); $form->setFieldNameSuffix('banner'); $fieldset = $form->addFieldset('base_fieldset', [ @@ -212,7 +212,7 @@ protected function _prepareForm() 'label' => __('Load Template'), ] ]); - $insertbutton = $fieldset->addField('load_template', 'note', [ + $insertbutton = $fieldset->addField('load_template', 'note', [ 'text' => $insertVariableButton->toHtml(), 'label' => '' ]); diff --git a/Block/Adminhtml/Banner/Edit/Tab/Render/GridImage.php b/Block/Adminhtml/Banner/Edit/Tab/Render/GridImage.php index fe5fc29..082504b 100644 --- a/Block/Adminhtml/Banner/Edit/Tab/Render/GridImage.php +++ b/Block/Adminhtml/Banner/Edit/Tab/Render/GridImage.php @@ -48,8 +48,7 @@ public function __construct( Context $context, ImageModel $imageModel, array $data = [] - ) - { + ) { $this->imageModel = $imageModel; parent::__construct($context, $data); @@ -72,4 +71,4 @@ public function render(DataObject $row) return ''; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Banner/Edit/Tab/Render/Image.php b/Block/Adminhtml/Banner/Edit/Tab/Render/Image.php index f1a903c..05a4703 100644 --- a/Block/Adminhtml/Banner/Edit/Tab/Render/Image.php +++ b/Block/Adminhtml/Banner/Edit/Tab/Render/Image.php @@ -56,8 +56,7 @@ public function __construct( Escaper $escaper, UrlInterface $urlBuilder, array $data - ) - { + ) { $this->imageModel = $imageModel; parent::__construct($factoryElement, $factoryCollection, $escaper, $urlBuilder, $data); diff --git a/Block/Adminhtml/Banner/Edit/Tab/Render/Slider.php b/Block/Adminhtml/Banner/Edit/Tab/Render/Slider.php index 24d16f2..bb9e1d8 100644 --- a/Block/Adminhtml/Banner/Edit/Tab/Render/Slider.php +++ b/Block/Adminhtml/Banner/Edit/Tab/Render/Slider.php @@ -27,6 +27,7 @@ use Magento\Framework\Data\Form\Element\Multiselect; use Magento\Framework\Escaper; use Mageplaza\BannerSlider\Helper\Data; +use Mageplaza\BannerSlider\Model\ResourceModel\Slider\Collection; use Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory as SliderCollectionFactory; /** @@ -38,7 +39,7 @@ class Slider extends Multiselect /** * Authorization * - * @var \Magento\Framework\AuthorizationInterface + * @var AuthorizationInterface */ public $authorization; @@ -64,10 +65,9 @@ public function __construct( SliderCollectionFactory $collectionFactory, AuthorizationInterface $authorization, array $data = [] - ) - { + ) { $this->collectionFactory = $collectionFactory; - $this->authorization = $authorization; + $this->authorization = $authorization; parent::__construct($factoryElement, $factoryCollection, $escaper, $data); } @@ -95,13 +95,13 @@ public function getElementHtml() */ public function getSliderCollection() { - /* @var $collection \Mageplaza\BannerSlider\Model\ResourceModel\Slider\Collection */ + /* @var $collection Collection */ $collection = $this->collectionFactory->create(); $sliderById = []; foreach ($collection as $slider) { - $sliderById[$slider->getId()]['value'] = $slider->getId(); + $sliderById[$slider->getId()]['value'] = $slider->getId(); $sliderById[$slider->getId()]['is_active'] = 1; - $sliderById[$slider->getId()]['label'] = $slider->getName(); + $sliderById[$slider->getId()]['label'] = $slider->getName(); } return $sliderById; @@ -124,7 +124,7 @@ public function getValues() return []; } - /* @var $collection \Mageplaza\BannerSlider\Model\ResourceModel\Slider\Collection */ + /* @var $collection Collection */ $collection = $this->collectionFactory->create()->addIdFilter($values); $options = []; @@ -176,4 +176,4 @@ public function getAfterElementHtml() return $html; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Banner/Edit/Tab/Render/Status.php b/Block/Adminhtml/Banner/Edit/Tab/Render/Status.php index 4d06b54..e0f62d1 100644 --- a/Block/Adminhtml/Banner/Edit/Tab/Render/Status.php +++ b/Block/Adminhtml/Banner/Edit/Tab/Render/Status.php @@ -43,4 +43,4 @@ public function render(DataObject $row) return $status === '1' ? 'Enable' : 'Disable'; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Banner/Edit/Tab/Render/Type.php b/Block/Adminhtml/Banner/Edit/Tab/Render/Type.php index f1ccbdf..102d4c7 100644 --- a/Block/Adminhtml/Banner/Edit/Tab/Render/Type.php +++ b/Block/Adminhtml/Banner/Edit/Tab/Render/Type.php @@ -51,4 +51,4 @@ public function render(DataObject $row) return $type; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Banner/Edit/Tabs.php b/Block/Adminhtml/Banner/Edit/Tabs.php index f375fc9..65d81a0 100644 --- a/Block/Adminhtml/Banner/Edit/Tabs.php +++ b/Block/Adminhtml/Banner/Edit/Tabs.php @@ -22,7 +22,7 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit; /** - * @method Tabs setTitle(\string $title) + * @method Tabs setTitle(string $title) */ class Tabs extends \Magento\Backend\Block\Widget\Tabs { diff --git a/Block/Adminhtml/Config/Field/Responsive.php b/Block/Adminhtml/Config/Field/Responsive.php index e79f78a..ef309f0 100644 --- a/Block/Adminhtml/Config/Field/Responsive.php +++ b/Block/Adminhtml/Config/Field/Responsive.php @@ -37,7 +37,7 @@ protected function _prepareToRender() $this->addColumn('size', ['label' => __('Screen size from'), 'renderer' => false, 'class' => 'required-entry validate-digits']); $this->addColumn('items', ['label' => __('Number of items'), 'renderer' => false, 'class' => 'required-entry validate-digits']); - $this->_addAfter = false; + $this->_addAfter = false; $this->_addButtonLabel = __('Add'); } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Slider.php b/Block/Adminhtml/Slider.php index f4093e6..8a01499 100644 --- a/Block/Adminhtml/Slider.php +++ b/Block/Adminhtml/Slider.php @@ -21,11 +21,13 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml; +use Magento\Backend\Block\Widget\Grid\Container; + /** * Class Slider * @package Mageplaza\BannerSlider\Block\Adminhtml */ -class Slider extends \Magento\Backend\Block\Widget\Grid\Container +class Slider extends Container { /** * constructor @@ -34,9 +36,9 @@ class Slider extends \Magento\Backend\Block\Widget\Grid\Container */ protected function _construct() { - $this->_controller = 'adminhtml_slider'; - $this->_blockGroup = 'Mageplaza_BannerSlider'; - $this->_headerText = __('Sliders'); + $this->_controller = 'adminhtml_slider'; + $this->_blockGroup = 'Mageplaza_BannerSlider'; + $this->_headerText = __('Sliders'); $this->_addButtonLabel = __('Create New Slider'); parent::_construct(); diff --git a/Block/Adminhtml/Slider/Edit.php b/Block/Adminhtml/Slider/Edit.php index 9909665..197126a 100644 --- a/Block/Adminhtml/Slider/Edit.php +++ b/Block/Adminhtml/Slider/Edit.php @@ -24,6 +24,7 @@ use Magento\Backend\Block\Widget\Context; use Magento\Backend\Block\Widget\Form\Container; use Magento\Framework\Registry; +use Mageplaza\BannerSlider\Model\Slider; /** * Class Edit @@ -49,9 +50,9 @@ public function __construct( Registry $coreRegistry, Context $context, array $data = [] - ) - { + ) { $this->coreRegistry = $coreRegistry; + parent::__construct($context, $data); } @@ -62,7 +63,7 @@ public function __construct( */ protected function _construct() { - $this->_objectId = 'slider_id'; + $this->_objectId = 'slider_id'; $this->_blockGroup = 'Mageplaza_BannerSlider'; $this->_controller = 'adminhtml_slider'; parent::_construct(); @@ -93,7 +94,7 @@ protected function _construct() */ public function getHeaderText() { - /** @var \Mageplaza\BannerSlider\Model\Slider $slider */ + /** @var Slider $slider */ $slider = $this->getSlider(); if ($slider->getId()) { return __("Edit Slider '%1'", $this->escapeHtml($slider->getName())); @@ -107,8 +108,6 @@ public function getHeaderText() */ public function getSlider() { - $slider = $this->coreRegistry->registry('mpbannerslider_slider'); - - return $slider; + return $this->coreRegistry->registry('mpbannerslider_slider'); } } diff --git a/Block/Adminhtml/Slider/Edit/Form.php b/Block/Adminhtml/Slider/Edit/Form.php index 295f48c..81baba0 100644 --- a/Block/Adminhtml/Slider/Edit/Form.php +++ b/Block/Adminhtml/Slider/Edit/Form.php @@ -22,6 +22,7 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit; use Magento\Backend\Block\Widget\Form\Generic; +use Magento\Framework\Exception\LocalizedException; /** * Class Form @@ -31,7 +32,7 @@ class Form extends Generic { /** * @return Generic - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareForm() { diff --git a/Block/Adminhtml/Slider/Edit/Tab/Banner.php b/Block/Adminhtml/Slider/Edit/Tab/Banner.php index 41f1816..d99bbb1 100644 --- a/Block/Adminhtml/Slider/Edit/Tab/Banner.php +++ b/Block/Adminhtml/Slider/Edit/Tab/Banner.php @@ -21,13 +21,20 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab; +use Exception; use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget\Grid\Column; use Magento\Backend\Block\Widget\Grid\Extended; use Magento\Backend\Block\Widget\Tab\TabInterface; use Magento\Backend\Helper\Data as backendHelper; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; +use Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\GridImage; +use Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\Status; +use Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\Type; use Mageplaza\BannerSlider\Model\BannerFactory; -use Mageplaza\BannerSlider\Model\ResourceModel\Banner\CollectionFactory as bannerCollectionFactory; +use Mageplaza\BannerSlider\Model\ResourceModel\Banner\Collection; +use Mageplaza\BannerSlider\Model\ResourceModel\Banner\CollectionFactory as BannerCollectionFactory; /** * Class Banner @@ -38,28 +45,28 @@ class Banner extends Extended implements TabInterface /** * Banner collection factory * - * @var \Mageplaza\BannerSlider\Model\ResourceModel\Banner\CollectionFactory + * @var BannerCollectionFactory */ protected $bannerCollectionFactory; /** * Registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $coreRegistry; /** * Banner factory * - * @var \Mageplaza\BannerSlider\Model\BannerFactory + * @var BannerFactory */ protected $bannerFactory; /** * Banner constructor. * - * @param bannerCollectionFactory $bannerCollectionFactory + * @param BannerCollectionFactory $bannerCollectionFactory * @param Registry $coreRegistry * @param BannerFactory $bannerFactory * @param Context $context @@ -67,17 +74,16 @@ class Banner extends Extended implements TabInterface * @param array $data */ public function __construct( - bannerCollectionFactory $bannerCollectionFactory, + BannerCollectionFactory $bannerCollectionFactory, Registry $coreRegistry, BannerFactory $bannerFactory, Context $context, backendHelper $backendHelper, array $data = [] - ) - { + ) { $this->bannerCollectionFactory = $bannerCollectionFactory; - $this->coreRegistry = $coreRegistry; - $this->bannerFactory = $bannerFactory; + $this->coreRegistry = $coreRegistry; + $this->bannerFactory = $bannerFactory; parent::__construct($context, $backendHelper, $data); } @@ -103,7 +109,7 @@ public function _construct() */ protected function _prepareCollection() { - /** @var \Mageplaza\BannerSlider\Model\ResourceModel\Banner\Collection $collection */ + /** @var Collection $collection */ $collection = $this->bannerCollectionFactory->create(); if ($this->getSlider()->getId()) { $constraint = 'related.slider_id=' . $this->getSlider()->getId(); @@ -130,7 +136,7 @@ protected function _prepareMassaction() /** * @return $this|Extended - * @throws \Exception + * @throws Exception */ protected function _prepareColumns() { @@ -157,7 +163,7 @@ protected function _prepareColumns() 'header_css_class' => 'col-image', 'column_css_class' => 'col-image', 'sortable' => false, - 'renderer' => "Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\GridImage" + 'renderer' => GridImage::class ]); $this->addColumn('name', [ @@ -172,7 +178,7 @@ protected function _prepareColumns() 'index' => 'type', 'header_css_class' => 'col-type', 'column_css_class' => 'col-type', - 'renderer' => 'Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\Type' + 'renderer' => Type::class ]); $this->addColumn('status', [ @@ -180,7 +186,7 @@ protected function _prepareColumns() 'index' => 'status', 'header_css_class' => 'col-status', 'column_css_class' => 'col-status', - 'renderer' => 'Mageplaza\BannerSlider\Block\Adminhtml\Banner\Edit\Tab\Render\Status' + 'renderer' => Status::class ]); $this->addColumn('position', [ @@ -230,7 +236,7 @@ public function getSelectedBanners() } /** - * @param \Mageplaza\BannerSlider\Model\Banner|\Magento\Framework\Object $item + * @param \Mageplaza\BannerSlider\Model\Banner|Object $item * * @return string */ @@ -263,10 +269,10 @@ public function getSlider() } /** - * @param \Magento\Backend\Block\Widget\Grid\Column $column + * @param Column $column * * @return $this|Extended - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _addColumnFilterToCollection($column) { diff --git a/Block/Adminhtml/Slider/Edit/Tab/Design.php b/Block/Adminhtml/Slider/Edit/Tab/Design.php index dc64fc0..78db01b 100644 --- a/Block/Adminhtml/Slider/Edit/Tab/Design.php +++ b/Block/Adminhtml/Slider/Edit/Tab/Design.php @@ -22,11 +22,14 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab; use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget\Form\Element\Dependence; use Magento\Backend\Block\Widget\Form\Generic; use Magento\Backend\Block\Widget\Tab\TabInterface; use Magento\Config\Model\Config\Source\Yesno; use Magento\Framework\Data\FormFactory; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; +use Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab\Renderer\Responsive; use Mageplaza\BannerSlider\Model\Config\Source\Effect; /** @@ -62,17 +65,16 @@ public function __construct( Effect $effect, Yesno $yesno, array $data = [] - ) - { + ) { $this->_effect = $effect; - $this->_yesno = $yesno; + $this->_yesno = $yesno; parent::__construct($context, $registry, $formFactory, $data); } /** * @return Generic - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareForm() { @@ -92,7 +94,7 @@ protected function _prepareForm() 'title' => __('Animation Effect'), 'values' => $this->_effect->toOptionArray() ]); - $design = $fieldset->addField('design', 'select', [ + $design = $fieldset->addField('design', 'select', [ 'name' => 'design', 'label' => __('Manually Design'), 'title' => __('Manually Design'), @@ -101,66 +103,66 @@ protected function _prepareForm() '1' => __('Yes') ] ]); - $responsive = $fieldset->addField('is_responsive', 'select', [ + $responsive = $fieldset->addField('is_responsive', 'select', [ 'name' => 'is_responsive', 'label' => __('Is Responsive'), 'title' => __('Is Responsive'), 'values' => $this->_yesno->toOptionArray() ]); - $responsiveItem = $fieldset->addField('responsive_items', 'Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab\Renderer\Responsive', [ + $responsiveItem = $fieldset->addField('responsive_items', Responsive::class, [ 'name' => 'responsive_items', 'label' => __('Max Items Slider'), 'title' => __('Max Items Slider'), ]); - $autoWidth = $fieldset->addField('autoWidth', 'select', [ + $autoWidth = $fieldset->addField('autoWidth', 'select', [ 'name' => 'autoWidth', 'label' => __('Auto Width'), 'title' => __('Auto Width'), 'values' => $this->_yesno->toOptionArray() ]); - $autoHeight = $fieldset->addField('autoHeight', 'select', [ + $autoHeight = $fieldset->addField('autoHeight', 'select', [ 'name' => 'autoHeight', 'label' => __('Auto Height'), 'title' => __('Auto Height'), 'values' => $this->_yesno->toOptionArray() ]); - $loop = $fieldset->addField('loop', 'select', [ + $loop = $fieldset->addField('loop', 'select', [ 'name' => 'loop', 'label' => __('Infinity Loop'), 'title' => __('Infinity Loop'), 'values' => $this->_yesno->toOptionArray() ]); - $nav = $fieldset->addField('nav', 'select', [ + $nav = $fieldset->addField('nav', 'select', [ 'name' => 'nav', 'label' => __('Show Next/Prev Buttons'), 'title' => __('Show Next/Prev Buttons'), 'values' => $this->_yesno->toOptionArray() ]); - $dots = $fieldset->addField('dots', 'select', [ + $dots = $fieldset->addField('dots', 'select', [ 'name' => 'dots', 'label' => __('Show Dots Navigation'), 'title' => __('Show Dots Navigation'), 'values' => $this->_yesno->toOptionArray() ]); - $lazyload = $fieldset->addField('lazyLoad', 'select', [ + $lazyload = $fieldset->addField('lazyLoad', 'select', [ 'name' => 'lazyLoad', 'label' => __('Lazy Loading Images'), 'title' => __('Lazy Loading Images'), 'values' => $this->_yesno->toOptionArray() ]); - $autoplay = $fieldset->addField('autoplay', 'select', [ + $autoplay = $fieldset->addField('autoplay', 'select', [ 'name' => 'autoplay', 'label' => __('Autoplay'), 'title' => __('Autoplay'), 'values' => $this->_yesno->toOptionArray() ]); - $timeout = $fieldset->addField('autoplayTimeout', 'text', [ + $timeout = $fieldset->addField('autoplayTimeout', 'text', [ 'name' => 'autoplayTimeout', 'label' => __('Autoplay Time-Out'), 'title' => __('Autoplay Time-Out') ]); - $dependencies = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Form\Element\Dependence') + $dependencies = $this->getLayout()->createBlock(Dependence::class) ->addFieldMap($design->getHtmlId(), $design->getName()) ->addFieldMap($responsive->getHtmlId(), $responsive->getName()) ->addFieldMap($responsiveItem->getHtmlId(), $responsiveItem->getName()) diff --git a/Block/Adminhtml/Slider/Edit/Tab/Renderer/Responsive.php b/Block/Adminhtml/Slider/Edit/Tab/Renderer/Responsive.php index 3f303db..655a084 100644 --- a/Block/Adminhtml/Slider/Edit/Tab/Renderer/Responsive.php +++ b/Block/Adminhtml/Slider/Edit/Tab/Renderer/Responsive.php @@ -53,8 +53,7 @@ public function __construct( Escaper $escaper, LayoutInterface $layout, array $data = [] - ) - { + ) { $this->layout = $layout; parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -73,4 +72,4 @@ public function getElementHtml() return $html; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Slider/Edit/Tab/Renderer/Snippet.php b/Block/Adminhtml/Slider/Edit/Tab/Renderer/Snippet.php index 27187db..5baf2a8 100644 --- a/Block/Adminhtml/Slider/Edit/Tab/Renderer/Snippet.php +++ b/Block/Adminhtml/Slider/Edit/Tab/Renderer/Snippet.php @@ -35,18 +35,18 @@ class Snippet extends AbstractElement public function getElementHtml() { $sliderId = '1'; - $html = '
'; + $html = ' '; return $html; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Slider/Edit/Tab/Slider.php b/Block/Adminhtml/Slider/Edit/Tab/Slider.php index 440e26d..ecdf6ea 100644 --- a/Block/Adminhtml/Slider/Edit/Tab/Slider.php +++ b/Block/Adminhtml/Slider/Edit/Tab/Slider.php @@ -21,6 +21,7 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab; +use Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element; use Magento\Backend\Block\Template\Context; use Magento\Backend\Block\Widget\Form\Generic; use Magento\Backend\Block\Widget\Tab\TabInterface; @@ -28,10 +29,13 @@ use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Convert\DataObject; +use Magento\Framework\Data\Form\Element\Renderer\RendererInterface; use Magento\Framework\Data\FormFactory; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; use Magento\Framework\Stdlib\DateTime; use Magento\Store\Model\System\Store; +use Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab\Renderer\Snippet; use Mageplaza\BannerSlider\Model\Config\Source\Location; /** @@ -43,32 +47,32 @@ class Slider extends Generic implements TabInterface /** * Status options * - * @var \Magento\Config\Model\Config\Source\Enabledisable + * @var Enabledisable */ protected $statusOptions; /** - * @var \Mageplaza\BannerSlider\Model\Config\Source\Location + * @var Location */ protected $_location; /** - * @var \Magento\Store\Model\System\Store + * @var Store */ protected $_systemStore; /** - * @var \Magento\Customer\Api\GroupRepositoryInterface + * @var GroupRepositoryInterface */ protected $_groupRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ protected $_searchCriteriaBuilder; /** - * @var \Magento\Framework\Convert\DataObject + * @var DataObject */ protected $_objectConverter; @@ -97,27 +101,26 @@ public function __construct( DataObject $objectConverter, Store $systemStore, array $data = [] - ) - { - $this->statusOptions = $statusOptions; - $this->_location = $location; - $this->_groupRepository = $groupRepository; + ) { + $this->statusOptions = $statusOptions; + $this->_location = $location; + $this->_groupRepository = $groupRepository; $this->_searchCriteriaBuilder = $searchCriteriaBuilder; - $this->_objectConverter = $objectConverter; - $this->_systemStore = $systemStore; + $this->_objectConverter = $objectConverter; + $this->_systemStore = $systemStore; parent::__construct($context, $registry, $formFactory, $data); } /** * @return Generic - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareForm() { /** @var \Mageplaza\BannerSlider\Model\Slider $slider */ $slider = $this->_coreRegistry->registry('mpbannerslider_slider'); - $form = $this->_formFactory->create(); + $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('slider_'); $form->setFieldNameSuffix('slider'); $fieldset = $form->addFieldset('base_fieldset', [ @@ -143,8 +146,8 @@ protected function _prepareForm() ]); if (!$this->_storeManager->isSingleStoreMode()) { - /** @var \Magento\Framework\Data\Form\Element\Renderer\RendererInterface $rendererBlock */ - $rendererBlock = $this->getLayout()->createBlock('Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'); + /** @var RendererInterface $rendererBlock */ + $rendererBlock = $this->getLayout()->createBlock(Element::class); $fieldset->addField('store_ids', 'multiselect', [ 'name' => 'store_ids', 'label' => __('Store Views'), @@ -208,7 +211,7 @@ protected function _prepareForm() 'legend' => __('Another way to add sliders to your page'), 'class' => 'fieldset-wide' ]); - $subfieldset->addField('snippet', 'Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab\Renderer\Snippet', [ + $subfieldset->addField('snippet', Snippet::class, [ 'name' => 'snippet', 'label' => __('How to use'), 'title' => __('How to use'), diff --git a/Block/Adminhtml/Slider/Edit/Tabs.php b/Block/Adminhtml/Slider/Edit/Tabs.php index 93c8a69..e16da71 100644 --- a/Block/Adminhtml/Slider/Edit/Tabs.php +++ b/Block/Adminhtml/Slider/Edit/Tabs.php @@ -22,7 +22,7 @@ namespace Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit; /** - * @method Tabs setTitle(\string $title) + * @method Tabs setTitle(string $title) */ class Tabs extends \Magento\Backend\Block\Widget\Tabs { diff --git a/Block/Slider.php b/Block/Slider.php index 14f3b91..fee1c1b 100644 --- a/Block/Slider.php +++ b/Block/Slider.php @@ -21,10 +21,13 @@ namespace Mageplaza\BannerSlider\Block; +use Exception; use Magento\Cms\Model\Template\FilterProvider; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\View\Element\Template; +use Magento\Store\Model\StoreManagerInterface; use Mageplaza\BannerSlider\Helper\Data as bannerHelper; /** @@ -34,22 +37,22 @@ class Slider extends Template { /** - * @type \Mageplaza\BannerSlider\Helper\Data + * @type bannerHelper */ public $helperData; /** - * @type \Magento\Store\Model\StoreManagerInterface + * @type StoreManagerInterface */ protected $store; /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ protected $customerRepository; /** - * @var \Magento\Framework\Stdlib\DateTime\DateTime + * @var DateTime */ protected $_date; @@ -75,13 +78,12 @@ public function __construct( DateTime $dateTime, FilterProvider $filterProvider, array $data = [] - ) - { - $this->helperData = $helperData; + ) { + $this->helperData = $helperData; $this->customerRepository = $customerRepository; - $this->store = $context->getStoreManager(); - $this->_date = $dateTime; - $this->filterProvider = $filterProvider; + $this->store = $context->getStoreManager(); + $this->_date = $dateTime; + $this->filterProvider = $filterProvider; parent::__construct($context, $data); } @@ -113,7 +115,7 @@ public function getSliderId() * @param $content * * @return string - * @throws \Exception + * @throws Exception */ public function getPageFilter($content) { @@ -121,7 +123,7 @@ public function getPageFilter($content) } /** - * @return array|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection + * @return array|AbstractCollection */ public function getBannerCollection() { @@ -140,4 +142,4 @@ public function getBannerOptions() { return $this->helperData->getBannerOptions($this->getSlider()); } -} \ No newline at end of file +} diff --git a/Block/Widget.php b/Block/Widget.php index 9eec071..1b28f9a 100644 --- a/Block/Widget.php +++ b/Block/Widget.php @@ -21,6 +21,8 @@ namespace Mageplaza\BannerSlider\Block; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; + /** * Class Widget * @package Mageplaza\BannerSlider\Block @@ -28,19 +30,19 @@ class Widget extends Slider { /** - * @return array|bool|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection + * @return array|bool|AbstractCollection */ public function getBannerCollection() { $sliderId = $this->getData('slider_id'); - if (!$this->helperData->isEnabled() || !$sliderId) { + if (!$sliderId || !$this->helperData->isEnabled()) { return false; } $sliderCollection = $this->helperData->getActiveSliders(); - $slider = $sliderCollection->addFieldToFilter('slider_id', $sliderId)->getFirstItem(); + $slider = $sliderCollection->addFieldToFilter('slider_id', $sliderId)->getFirstItem(); $this->setSlider($slider); return parent::getBannerCollection(); } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Banner.php b/Controller/Adminhtml/Banner.php index 4fe443d..9c1fc06 100644 --- a/Controller/Adminhtml/Banner.php +++ b/Controller/Adminhtml/Banner.php @@ -23,6 +23,7 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\RedirectFactory; use Magento\Framework\Registry; use Mageplaza\BannerSlider\Model\BannerFactory; @@ -49,7 +50,7 @@ abstract class Banner extends Action /** * Result redirect factory * - * @var \Magento\Backend\Model\View\Result\RedirectFactory + * @var RedirectFactory */ /** @@ -63,10 +64,9 @@ public function __construct( BannerFactory $bannerFactory, Registry $coreRegistry, Context $context - ) - { + ) { $this->bannerFactory = $bannerFactory; - $this->coreRegistry = $coreRegistry; + $this->coreRegistry = $coreRegistry; parent::__construct($context); } diff --git a/Controller/Adminhtml/Banner/Delete.php b/Controller/Adminhtml/Banner/Delete.php index a8f6098..b403ea2 100644 --- a/Controller/Adminhtml/Banner/Delete.php +++ b/Controller/Adminhtml/Banner/Delete.php @@ -21,6 +21,10 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Banner; +use Exception; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; use Mageplaza\BannerSlider\Controller\Adminhtml\Banner; /** @@ -30,7 +34,7 @@ class Delete extends Banner { /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface + * @return ResponseInterface|Redirect|ResultInterface */ public function execute() { @@ -40,7 +44,7 @@ public function execute() ->load($this->getRequest()->getParam('banner_id')) ->delete(); $this->messageManager->addSuccess(__('The Banner has been deleted.')); - } catch (\Exception $e) { + } catch (Exception $e) { // display error message $this->messageManager->addErrorMessage($e->getMessage()); // go back to edit form diff --git a/Controller/Adminhtml/Banner/Edit.php b/Controller/Adminhtml/Banner/Edit.php index f736b24..8b014c0 100644 --- a/Controller/Adminhtml/Banner/Edit.php +++ b/Controller/Adminhtml/Banner/Edit.php @@ -22,7 +22,11 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Banner; use Magento\Backend\App\Action\Context; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Registry; +use Magento\Framework\View\Result\Page; use Magento\Framework\View\Result\PageFactory; use Mageplaza\BannerSlider\Controller\Adminhtml\Banner; use Mageplaza\BannerSlider\Model\BannerFactory; @@ -38,31 +42,30 @@ class Edit extends Banner /** * Page factory * - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; /** * Edit constructor. * - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Mageplaza\BannerSlider\Model\BannerFactory $bannerFactory - * @param \Magento\Framework\Registry $registry - * @param \Magento\Backend\App\Action\Context $context + * @param PageFactory $resultPageFactory + * @param BannerFactory $bannerFactory + * @param Registry $registry + * @param Context $context */ public function __construct( PageFactory $resultPageFactory, BannerFactory $bannerFactory, Registry $registry, Context $context - ) - { + ) { $this->resultPageFactory = $resultPageFactory; parent::__construct($bannerFactory, $registry, $context); } /** - * @return \Magento\Backend\Model\View\Result\Page|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page + * @return \Magento\Backend\Model\View\Result\Page|ResponseInterface|Redirect|ResultInterface|Page */ public function execute() { @@ -92,7 +95,7 @@ public function execute() $banner->setData($data); } - /** @var \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page $resultPage */ + /** @var \Magento\Backend\Model\View\Result\Page|Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Mageplaza_BannerSlider::banner'); $resultPage->getConfig()->getTitle() diff --git a/Controller/Adminhtml/Banner/Index.php b/Controller/Adminhtml/Banner/Index.php index d691268..f246cb7 100644 --- a/Controller/Adminhtml/Banner/Index.php +++ b/Controller/Adminhtml/Banner/Index.php @@ -23,6 +23,7 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Framework\View\Result\Page; use Magento\Framework\View\Result\PageFactory; /** @@ -34,7 +35,7 @@ class Index extends Action /** * Page result factory * - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; @@ -54,8 +55,7 @@ class Index extends Action public function __construct( Context $context, PageFactory $resultPageFactory - ) - { + ) { $this->resultPageFactory = $resultPageFactory; parent::__construct($context); @@ -64,7 +64,7 @@ public function __construct( /** * execute the action * - * @return \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page + * @return \Magento\Backend\Model\View\Result\Page|Page */ public function execute() { diff --git a/Controller/Adminhtml/Banner/InlineEdit.php b/Controller/Adminhtml/Banner/InlineEdit.php index 49c0055..bc15591 100644 --- a/Controller/Adminhtml/Banner/InlineEdit.php +++ b/Controller/Adminhtml/Banner/InlineEdit.php @@ -21,10 +21,16 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Banner; +use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Framework\Controller\Result\Json; use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; +use Mageplaza\BannerSlider\Model\Banner; use Mageplaza\BannerSlider\Model\BannerFactory; +use RuntimeException; /** * Class InlineEdit @@ -57,24 +63,23 @@ public function __construct( JsonFactory $jsonFactory, BannerFactory $bannerFactory, Context $context - ) - { - $this->jsonFactory = $jsonFactory; + ) { + $this->jsonFactory = $jsonFactory; $this->bannerFactory = $bannerFactory; parent::__construct($context); } /** - * @return \Magento\Framework\Controller\ResultInterface + * @return ResultInterface */ public function execute() { - /** @var \Magento\Framework\Controller\Result\Json $resultJson */ + /** @var Json $resultJson */ $resultJson = $this->jsonFactory->create(); - $error = false; - $messages = []; - $postItems = $this->getRequest()->getParam('items', []); + $error = false; + $messages = []; + $postItems = $this->getRequest()->getParam('items', []); if (!($this->getRequest()->getParam('isAjax') && count($postItems))) { return $resultJson->setData([ 'messages' => [__('Please correct the data sent.')], @@ -82,24 +87,24 @@ public function execute() ]); } foreach (array_keys($postItems) as $bannerId) { - /** @var \Mageplaza\BannerSlider\Model\Banner $banner */ + /** @var Banner $banner */ $banner = $this->bannerFactory->create()->load($bannerId); try { $bannerData = $postItems[$bannerId];//todo: handle dates $banner->addData($bannerData); $banner->save(); - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $messages[] = $this->getErrorWithBannerId($banner, $e->getMessage()); - $error = true; - } catch (\RuntimeException $e) { + $error = true; + } catch (RuntimeException $e) { $messages[] = $this->getErrorWithBannerId($banner, $e->getMessage()); - $error = true; - } catch (\Exception $e) { + $error = true; + } catch (Exception $e) { $messages[] = $this->getErrorWithBannerId( $banner, __('Something went wrong while saving the Banner.') ); - $error = true; + $error = true; } } @@ -112,12 +117,12 @@ public function execute() /** * Add Banner id to error message * - * @param \Mageplaza\BannerSlider\Model\Banner $banner + * @param Banner $banner * @param string $errorText * * @return string */ - protected function getErrorWithBannerId(\Mageplaza\BannerSlider\Model\Banner $banner, $errorText) + protected function getErrorWithBannerId(Banner $banner, $errorText) { return '[Banner ID: ' . $banner->getId() . '] ' . $errorText; } diff --git a/Controller/Adminhtml/Banner/MassDelete.php b/Controller/Adminhtml/Banner/MassDelete.php index 883efee..a016510 100644 --- a/Controller/Adminhtml/Banner/MassDelete.php +++ b/Controller/Adminhtml/Banner/MassDelete.php @@ -23,7 +23,13 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Ui\Component\MassAction\Filter; +use Mageplaza\BannerSlider\Model\Banner; use Mageplaza\BannerSlider\Model\ResourceModel\Banner\CollectionFactory; /** @@ -57,17 +63,16 @@ public function __construct( Filter $filter, CollectionFactory $collectionFactory, Context $context - ) - { - $this->filter = $filter; + ) { + $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); } /** - * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface - * @throws \Magento\Framework\Exception\LocalizedException + * @return Redirect|ResponseInterface|ResultInterface + * @throws LocalizedException */ public function execute() { @@ -75,13 +80,13 @@ public function execute() $delete = 0; foreach ($collection as $item) { - /** @var \Mageplaza\BannerSlider\Model\Banner $item */ + /** @var Banner $item */ $item->delete(); $delete++; } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $delete)); - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT); + /** @var Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } diff --git a/Controller/Adminhtml/Banner/MassStatus.php b/Controller/Adminhtml/Banner/MassStatus.php index 5819489..a7f1d16 100644 --- a/Controller/Adminhtml/Banner/MassStatus.php +++ b/Controller/Adminhtml/Banner/MassStatus.php @@ -21,9 +21,13 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Banner; +use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Ui\Component\MassAction\Filter; use Mageplaza\BannerSlider\Model\ResourceModel\Banner\CollectionFactory; @@ -37,14 +41,14 @@ class MassStatus extends Action /** * Mass Action Filter * - * @var \Magento\Ui\Component\MassAction\Filter + * @var Filter */ public $filter; /** * Collection Factory * - * @var \Mageplaza\BannerSlider\Model\ResourceModel\Banner\CollectionFactory + * @var CollectionFactory */ public $collectionFactory; @@ -59,22 +63,21 @@ public function __construct( Context $context, Filter $filter, CollectionFactory $collectionFactory - ) - { - $this->filter = $filter; + ) { + $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); } /** - * @return $this|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface + * @return $this|ResponseInterface|ResultInterface * @throws LocalizedException */ public function execute() { - $collection = $this->filter->getCollection($this->collectionFactory->create()); - $status = (int)$this->getRequest()->getParam('status'); + $collection = $this->filter->getCollection($this->collectionFactory->create()); + $status = (int)$this->getRequest()->getParam('status'); $bannerUpdated = 0; foreach ($collection as $banner) { try { @@ -84,7 +87,7 @@ public function execute() $bannerUpdated++; } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addErrorMessage(__('Something went wrong while updating status for %1.', $banner->getName())); } } @@ -93,7 +96,7 @@ public function execute() $this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been updated.', $bannerUpdated)); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); diff --git a/Controller/Adminhtml/Banner/NewAction.php b/Controller/Adminhtml/Banner/NewAction.php index f0b11b8..a3dd271 100644 --- a/Controller/Adminhtml/Banner/NewAction.php +++ b/Controller/Adminhtml/Banner/NewAction.php @@ -22,6 +22,8 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Banner; use Magento\Backend\App\Action; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\ResultInterface; /** * Class NewAction @@ -30,7 +32,7 @@ class NewAction extends Action { /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void + * @return ResponseInterface|ResultInterface|void */ public function execute() { diff --git a/Controller/Adminhtml/Banner/Save.php b/Controller/Adminhtml/Banner/Save.php index 2ceab0e..71ab030 100644 --- a/Controller/Adminhtml/Banner/Save.php +++ b/Controller/Adminhtml/Banner/Save.php @@ -21,12 +21,19 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Banner; +use Exception; use Magento\Backend\App\Action\Context; use Magento\Backend\Helper\Js; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; use Mageplaza\BannerSlider\Controller\Adminhtml\Banner; use Mageplaza\BannerSlider\Helper\Image; use Mageplaza\BannerSlider\Model\BannerFactory; +use RuntimeException; /** * Class Save @@ -37,14 +44,14 @@ class Save extends Banner /** * Image Helper * - * @var \Mageplaza\BannerSlider\Helper\Image + * @var Image */ protected $imageHelper; /** * JS helper * - * @var \Magento\Backend\Helper\Js + * @var Js */ public $jsHelper; @@ -62,17 +69,16 @@ public function __construct( Registry $registry, Js $jsHelper, Context $context - ) - { + ) { $this->imageHelper = $imageHelper; - $this->jsHelper = $jsHelper; + $this->jsHelper = $jsHelper; parent::__construct($bannerFactory, $registry, $context); } /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface - * @throws \Magento\Framework\Exception\FileSystemException + * @return ResponseInterface|Redirect|ResultInterface + * @throws FileSystemException */ public function execute() { @@ -116,11 +122,11 @@ public function execute() $resultRedirect->setPath('mpbannerslider/*/'); return $resultRedirect; - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); - } catch (\RuntimeException $e) { + } catch (RuntimeException $e) { $this->messageManager->addError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addException($e, __('Something went wrong while saving the Banner.')); } diff --git a/Controller/Adminhtml/Slider.php b/Controller/Adminhtml/Slider.php index c70619a..373897b 100644 --- a/Controller/Adminhtml/Slider.php +++ b/Controller/Adminhtml/Slider.php @@ -35,14 +35,14 @@ abstract class Slider extends Action /** * Slider Factory * - * @var \Mageplaza\BannerSlider\Model\SliderFactory + * @var SliderFactory */ protected $sliderFactory; /** * Core registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $coreRegistry; @@ -57,10 +57,9 @@ public function __construct( SliderFactory $sliderFactory, Registry $coreRegistry, Context $context - ) - { + ) { $this->sliderFactory = $sliderFactory; - $this->coreRegistry = $coreRegistry; + $this->coreRegistry = $coreRegistry; parent::__construct($context); } diff --git a/Controller/Adminhtml/Slider/Banners.php b/Controller/Adminhtml/Slider/Banners.php index 67a07e7..96a9a19 100644 --- a/Controller/Adminhtml/Slider/Banners.php +++ b/Controller/Adminhtml/Slider/Banners.php @@ -23,7 +23,9 @@ use Magento\Backend\App\Action\Context; use Magento\Framework\Registry; +use Magento\Framework\View\Result\Layout; use Magento\Framework\View\Result\LayoutFactory; +use Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab\Banner; use Mageplaza\BannerSlider\Controller\Adminhtml\Slider; use Mageplaza\BannerSlider\Model\SliderFactory; @@ -36,7 +38,7 @@ class Banners extends Slider /** * Result layout factory * - * @var \Magento\Framework\View\Result\LayoutFactory + * @var LayoutFactory */ protected $resultLayoutFactory; @@ -53,21 +55,20 @@ public function __construct( SliderFactory $bannerFactory, Registry $registry, Context $context - ) - { + ) { $this->resultLayoutFactory = $resultLayoutFactory; parent::__construct($bannerFactory, $registry, $context); } /** - * @return \Magento\Framework\View\Result\Layout + * @return Layout */ public function execute() { $this->initSlider(); $resultLayout = $this->resultLayoutFactory->create(); - /** @var \Mageplaza\BannerSlider\Block\Adminhtml\Slider\Edit\Tab\Banner $bannersBlock */ + /** @var Banner $bannersBlock */ $bannersBlock = $resultLayout->getLayout()->getBlock('slider.edit.tab.banner'); if ($bannersBlock) { $bannersBlock->setSliderBanners($this->getRequest()->getPost('slider_banners', null)); diff --git a/Controller/Adminhtml/Slider/Delete.php b/Controller/Adminhtml/Slider/Delete.php index 410caa1..f4c6355 100644 --- a/Controller/Adminhtml/Slider/Delete.php +++ b/Controller/Adminhtml/Slider/Delete.php @@ -21,7 +21,12 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; +use Exception; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; use Mageplaza\BannerSlider\Controller\Adminhtml\Slider; +use Mageplaza\BannerSlider\Model\Banner; /** * Class Delete @@ -30,18 +35,18 @@ class Delete extends Slider { /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface + * @return ResponseInterface|Redirect|ResultInterface */ public function execute() { $resultRedirect = $this->resultRedirectFactory->create(); try { - /** @var \Mageplaza\BannerSlider\Model\Banner $banner */ + /** @var Banner $banner */ $this->sliderFactory->create() ->load($this->getRequest()->getParam('slider_id')) ->delete(); $this->messageManager->addSuccess(__('The slider has been deleted.')); - } catch (\Exception $e) { + } catch (Exception $e) { // display error message $this->messageManager->addErrorMessage($e->getMessage()); // go back to edit form diff --git a/Controller/Adminhtml/Slider/Edit.php b/Controller/Adminhtml/Slider/Edit.php index 2cf00ad..7d41c75 100644 --- a/Controller/Adminhtml/Slider/Edit.php +++ b/Controller/Adminhtml/Slider/Edit.php @@ -22,7 +22,11 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; use Magento\Backend\App\Action\Context; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Registry; +use Magento\Framework\View\Result\Page; use Magento\Framework\View\Result\PageFactory; use Mageplaza\BannerSlider\Controller\Adminhtml\Slider; use Mageplaza\BannerSlider\Model\SliderFactory; @@ -38,7 +42,7 @@ class Edit extends Slider /** * Page factory * - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; @@ -55,15 +59,14 @@ public function __construct( SliderFactory $sliderFactory, Registry $registry, Context $context - ) - { + ) { $this->resultPageFactory = $resultPageFactory; parent::__construct($sliderFactory, $registry, $context); } /** - * @return \Magento\Backend\Model\View\Result\Page|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page + * @return \Magento\Backend\Model\View\Result\Page|ResponseInterface|Redirect|ResultInterface|Page */ public function execute() { @@ -93,7 +96,7 @@ public function execute() $slider->setData($data); } - /** @var \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page $resultPage */ + /** @var \Magento\Backend\Model\View\Result\Page|Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Mageplaza_BannerSlider::slider'); $resultPage->getConfig()->getTitle() diff --git a/Controller/Adminhtml/Slider/Index.php b/Controller/Adminhtml/Slider/Index.php index b707aed..6d02c85 100644 --- a/Controller/Adminhtml/Slider/Index.php +++ b/Controller/Adminhtml/Slider/Index.php @@ -23,6 +23,7 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Framework\View\Result\Page; use Magento\Framework\View\Result\PageFactory; /** @@ -34,7 +35,7 @@ class Index extends Action /** * Page result factory * - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; @@ -48,14 +49,13 @@ class Index extends Action /** * constructor * - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Backend\App\Action\Context $context + * @param PageFactory $resultPageFactory + * @param Context $context */ public function __construct( PageFactory $resultPageFactory, Context $context - ) - { + ) { $this->resultPageFactory = $resultPageFactory; parent::__construct($context); @@ -64,7 +64,7 @@ public function __construct( /** * execute the action * - * @return \Magento\Backend\Model\View\Result\Page|\Magento\Framework\View\Result\Page + * @return \Magento\Backend\Model\View\Result\Page|Page */ public function execute() { diff --git a/Controller/Adminhtml/Slider/InlineEdit.php b/Controller/Adminhtml/Slider/InlineEdit.php index f971336..e209a91 100644 --- a/Controller/Adminhtml/Slider/InlineEdit.php +++ b/Controller/Adminhtml/Slider/InlineEdit.php @@ -21,27 +21,34 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; +use Exception; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Framework\Controller\Result\Json; use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; +use Mageplaza\BannerSlider\Model\Slider; use Mageplaza\BannerSlider\Model\SliderFactory; +use RuntimeException; /** * Class InlineEdit * @package Mageplaza\BannerSlider\Controller\Adminhtml\Slider */ -class InlineEdit extends \Magento\Backend\App\Action +class InlineEdit extends Action { /** * JSON Factory * - * @var \Magento\Framework\Controller\Result\JsonFactory + * @var JsonFactory */ protected $jsonFactory; /** * Banner Factory * - * @var \Mageplaza\BannerSlider\Model\SliderFactory + * @var SliderFactory */ protected $sliderFactory; @@ -55,24 +62,23 @@ public function __construct( JsonFactory $jsonFactory, SliderFactory $sliderFactory, Context $context - ) - { - $this->jsonFactory = $jsonFactory; + ) { + $this->jsonFactory = $jsonFactory; $this->sliderFactory = $sliderFactory; parent::__construct($context); } /** - * @return \Magento\Framework\Controller\ResultInterface + * @return ResultInterface */ public function execute() { - /** @var \Magento\Framework\Controller\Result\Json $resultJson */ + /** @var Json $resultJson */ $resultJson = $this->jsonFactory->create(); - $error = false; - $messages = []; - $postItems = $this->getRequest()->getParam('items', []); + $error = false; + $messages = []; + $postItems = $this->getRequest()->getParam('items', []); if (!($this->getRequest()->getParam('isAjax') && count($postItems))) { return $resultJson->setData([ 'messages' => [__('Please correct the data sent.')], @@ -80,24 +86,24 @@ public function execute() ]); } foreach (array_keys($postItems) as $sliderId) { - /** @var \Mageplaza\BannerSlider\Model\Slider $slider */ + /** @var Slider $slider */ $slider = $this->sliderFactory->create()->load($sliderId); try { $sliderData = $postItems[$sliderId]; $slider->addData($sliderData); $slider->save(); - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $messages[] = $this->getErrorWithSliderId($slider, $e->getMessage()); - $error = true; - } catch (\RuntimeException $e) { + $error = true; + } catch (RuntimeException $e) { $messages[] = $this->getErrorWithSliderId($slider, $e->getMessage()); - $error = true; - } catch (\Exception $e) { + $error = true; + } catch (Exception $e) { $messages[] = $this->getErrorWithSliderId( $slider, __('Something went wrong while saving the Banner.') ); - $error = true; + $error = true; } } @@ -110,12 +116,12 @@ public function execute() /** * Add slider id to error message * - * @param \Mageplaza\BannerSlider\Model\Slider $slider + * @param Slider $slider * @param $errorText * * @return string */ - protected function getErrorWithSliderId(\Mageplaza\BannerSlider\Model\Slider $slider, $errorText) + protected function getErrorWithSliderId(Slider $slider, $errorText) { return '[Slider ID: ' . $slider->getId() . '] ' . $errorText; } diff --git a/Controller/Adminhtml/Slider/MassDelete.php b/Controller/Adminhtml/Slider/MassDelete.php index 00d4059..9003337 100644 --- a/Controller/Adminhtml/Slider/MassDelete.php +++ b/Controller/Adminhtml/Slider/MassDelete.php @@ -21,27 +21,34 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Ui\Component\MassAction\Filter; use Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory; +use Mageplaza\BannerSlider\Model\Slider; /** * Class MassDelete * @package Mageplaza\BannerSlider\Controller\Adminhtml\Slider */ -class MassDelete extends \Magento\Backend\App\Action +class MassDelete extends Action { /** * Mass Action Filter * - * @var \Magento\Ui\Component\MassAction\Filter + * @var Filter */ protected $filter; /** * Collection Factory * - * @var \Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory + * @var CollectionFactory */ protected $collectionFactory; @@ -56,17 +63,16 @@ public function __construct( Filter $filter, CollectionFactory $collectionFactory, Context $context - ) - { - $this->filter = $filter; + ) { + $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); } /** - * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface - * @throws \Magento\Framework\Exception\LocalizedException + * @return Redirect|ResponseInterface|ResultInterface + * @throws LocalizedException */ public function execute() { @@ -74,13 +80,13 @@ public function execute() $delete = 0; foreach ($collection as $item) { - /** @var \Mageplaza\BannerSlider\Model\Slider $item */ + /** @var Slider $item */ $item->delete(); $delete++; } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $delete)); - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT); + /** @var Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } diff --git a/Controller/Adminhtml/Slider/MassStatus.php b/Controller/Adminhtml/Slider/MassStatus.php index 7201781..bf7306d 100644 --- a/Controller/Adminhtml/Slider/MassStatus.php +++ b/Controller/Adminhtml/Slider/MassStatus.php @@ -21,9 +21,13 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; +use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Ui\Component\MassAction\Filter; use Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory; @@ -37,14 +41,14 @@ class MassStatus extends Action /** * Mass Action Filter * - * @var \Magento\Ui\Component\MassAction\Filter + * @var Filter */ public $filter; /** * Collection Factory * - * @var \Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory + * @var CollectionFactory */ public $collectionFactory; @@ -59,22 +63,21 @@ public function __construct( Context $context, Filter $filter, CollectionFactory $collectionFactory - ) - { - $this->filter = $filter; + ) { + $this->filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); } /** - * @return $this|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface + * @return $this|ResponseInterface|ResultInterface * @throws LocalizedException */ public function execute() { - $collection = $this->filter->getCollection($this->collectionFactory->create()); - $status = (int)$this->getRequest()->getParam('status'); + $collection = $this->filter->getCollection($this->collectionFactory->create()); + $status = (int)$this->getRequest()->getParam('status'); $sliderUpdated = 0; foreach ($collection as $slider) { try { @@ -84,7 +87,7 @@ public function execute() $sliderUpdated++; } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addErrorMessage(__('Something went wrong while updating status for %1.', $slider->getName())); } } @@ -93,7 +96,7 @@ public function execute() $this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been updated.', $sliderUpdated)); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); diff --git a/Controller/Adminhtml/Slider/NewAction.php b/Controller/Adminhtml/Slider/NewAction.php index a988d0b..dcd669c 100644 --- a/Controller/Adminhtml/Slider/NewAction.php +++ b/Controller/Adminhtml/Slider/NewAction.php @@ -22,6 +22,8 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; use Magento\Backend\App\Action; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\ResultInterface; /** * Class NewAction @@ -30,7 +32,7 @@ class NewAction extends Action { /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void + * @return ResponseInterface|ResultInterface|void */ public function execute() { diff --git a/Controller/Adminhtml/Slider/Save.php b/Controller/Adminhtml/Slider/Save.php index f71ea88..6026d0a 100644 --- a/Controller/Adminhtml/Slider/Save.php +++ b/Controller/Adminhtml/Slider/Save.php @@ -21,12 +21,19 @@ namespace Mageplaza\BannerSlider\Controller\Adminhtml\Slider; +use Exception; use Magento\Backend\App\Action\Context; use Magento\Backend\Helper\Js; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; use Magento\Framework\Stdlib\DateTime\Filter\Date; use Mageplaza\BannerSlider\Controller\Adminhtml\Slider; use Mageplaza\BannerSlider\Model\SliderFactory; +use RuntimeException; +use Zend_Filter_Input; /** * Class Save @@ -37,14 +44,14 @@ class Save extends Slider /** * JS helper * - * @var \Magento\Backend\Helper\Js + * @var Js */ protected $jsHelper; /** * Date filter * - * @var \Magento\Framework\Stdlib\DateTime\Filter\Date + * @var Date */ protected $_dateFilter; @@ -63,23 +70,22 @@ public function __construct( Registry $registry, Context $context, Date $dateFilter - ) - { - $this->jsHelper = $jsHelper; + ) { + $this->jsHelper = $jsHelper; $this->_dateFilter = $dateFilter; parent::__construct($sliderFactory, $registry, $context); } /** - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface + * @return ResponseInterface|Redirect|ResultInterface */ public function execute() { $resultRedirect = $this->resultRedirectFactory->create(); if ($data = $this->getRequest()->getPost('slider')) { - $data = $this->_filterData($data); + $data = $this->_filterData($data); $slider = $this->initSlider(); $banners = $this->getRequest()->getPost('banners', -1); @@ -114,11 +120,11 @@ public function execute() $resultRedirect->setPath('mpbannerslider/*/'); return $resultRedirect; - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); - } catch (\RuntimeException $e) { + } catch (RuntimeException $e) { $this->messageManager->addError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->messageManager->addException($e, __('Something went wrong while saving the Slider.')); } @@ -148,8 +154,8 @@ public function execute() */ protected function _filterData($data) { - $inputFilter = new \Zend_Filter_Input(['from_date' => $this->_dateFilter,], [], $data); - $data = $inputFilter->getUnescaped(); + $inputFilter = new Zend_Filter_Input(['from_date' => $this->_dateFilter,], [], $data); + $data = $inputFilter->getUnescaped(); if (isset($data['responsive_items'])) { unset($data['responsive_items']['__empty']); diff --git a/Helper/Data.php b/Helper/Data.php index 7b0fb01..0abfb34 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -21,12 +21,14 @@ namespace Mageplaza\BannerSlider\Helper; +use Exception; use Magento\Framework\App\Helper\Context; use Magento\Framework\App\Http\Context as HttpContext; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\BannerSlider\Model\BannerFactory; +use Mageplaza\BannerSlider\Model\ResourceModel\Banner\Collection; use Mageplaza\BannerSlider\Model\SliderFactory; use Mageplaza\Core\Helper\AbstractData; @@ -77,10 +79,9 @@ public function __construct( SliderFactory $sliderFactory, StoreManagerInterface $storeManager, ObjectManagerInterface $objectManager - ) - { - $this->date = $date; - $this->httpContext = $httpContext; + ) { + $this->date = $date; + $this->httpContext = $httpContext; $this->bannerFactory = $bannerFactory; $this->sliderFactory = $sliderFactory; @@ -100,9 +101,9 @@ public function getBannerOptions($slider = null) $config = $this->getModuleConfig('mpbannerslider_design'); } - $defaultOpt = $this->getDefaultConfig($config); + $defaultOpt = $this->getDefaultConfig($config); $responsiveOpt = $this->getResponsiveConfig($slider); - $effectOpt = $this->getEffectConfig($slider); + $effectOpt = $this->getEffectConfig($slider); $sliderOptions = array_merge($defaultOpt, $responsiveOpt, $effectOpt); @@ -137,27 +138,23 @@ public function getResponsiveConfig($slider = null) $sliderResponsive = $slider->getIsResponsive(); if (!$defaultResponsive && !$sliderResponsive) { - return ["items" => 1]; + return ['items' => 1]; } - if (!$slider->getDesign()) { - try { - $responsiveItems = $this->unserialize($this->getModuleConfig('mpbannerslider_design/item_slider')); - } catch (\Exception $e) { - $responsiveItems = []; - } - } else { - try { - $responsiveItems = $this->unserialize($slider->getResponsiveItems()); - } catch (\Exception $e) { - $responsiveItems = []; - } + $responsiveItemsValue = $slider->getDesign() + ? $slider->getResponsiveItems() + : $this->getModuleConfig('mpbannerslider_design/item_slider'); + + try { + $responsiveItems = $this->unserialize($responsiveItemsValue); + } catch (Exception $e) { + $responsiveItems = []; } $result = []; foreach ($responsiveItems as $config) { - $size = $config['size'] ?: 0; - $items = $config['items'] ?: 0; + $size = $config['size'] ?: 0; + $items = $config['items'] ?: 0; $result[$size] = ["items" => $items]; } @@ -181,7 +178,7 @@ public function getEffectConfig($slider) /** * @param null $id * - * @return \Mageplaza\BannerSlider\Model\ResourceModel\Banner\Collection + * @return Collection */ public function getBannerCollection($id = null) { @@ -200,13 +197,16 @@ public function getBannerCollection($id = null) /** * @return Collection + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getActiveSliders() { /** @var Collection $collection */ $collection = $this->sliderFactory->create() ->getCollection() - ->addFieldToFilter('customer_group_ids', ['finset' => $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP)]) + ->addFieldToFilter('customer_group_ids', [ + 'finset' => $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP) + ]) ->addFieldToFilter('status', 1) ->addOrder('priority'); diff --git a/Helper/Image.php b/Helper/Image.php index 053ffe9..eac1b61 100644 --- a/Helper/Image.php +++ b/Helper/Image.php @@ -29,7 +29,7 @@ */ class Image extends Media { - const TEMPLATE_MEDIA_PATH = 'mageplaza/bannerslider'; + const TEMPLATE_MEDIA_PATH = 'mageplaza/bannerslider'; const TEMPLATE_MEDIA_TYPE_BANNER = 'banner/image'; const TEMPLATE_MEDIA_TYPE_SLIDER = 'slider/image'; } diff --git a/Model/Banner.php b/Model/Banner.php index f4ed17e..ca986e7 100644 --- a/Model/Banner.php +++ b/Model/Banner.php @@ -27,6 +27,7 @@ use Magento\Framework\Model\ResourceModel\AbstractResource; use Magento\Framework\Registry; use Mageplaza\BannerSlider\Model\Config\Source\Image as configImage; +use Mageplaza\BannerSlider\Model\ResourceModel\Slider\Collection; use Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory as sliderCollectionFactory; /** @@ -40,15 +41,15 @@ * @method mixed getUrl() * @method mixed getType() * @method mixed getStatus() - * @method Banner setCreatedAt(\string $createdAt) + * @method Banner setCreatedAt(string $createdAt) * @method string getCreatedAt() - * @method Banner setUpdatedAt(\string $updatedAt) + * @method Banner setUpdatedAt(string $updatedAt) * @method string getUpdatedAt() * @method Banner setSlidersData(array $data) * @method array getSlidersData() * @method Banner setSlidersIds(array $sliderIds) * @method array getSlidersIds() - * @method Banner setIsChangedSliderList(\bool $flag) + * @method Banner setIsChangedSliderList(bool $flag) * @method bool getIsChangedSliderList() * @method Banner setAffectedSliderIds(array $ids) * @method bool getAffectedSliderIds() @@ -79,14 +80,14 @@ class Banner extends AbstractModel /** * Slider Collection * - * @var \Mageplaza\BannerSlider\Model\ResourceModel\Slider\Collection + * @var Collection */ protected $sliderCollection; /** * Slider Collection Factory * - * @var \Mageplaza\BannerSlider\Model\ResourceModel\Slider\CollectionFactory + * @var sliderCollectionFactory */ protected $sliderCollectionFactory; @@ -114,10 +115,9 @@ public function __construct( AbstractResource $resource = null, AbstractDb $resourceCollection = null, array $data = [] - ) - { + ) { $this->sliderCollectionFactory = $sliderCollectionFactory; - $this->imageModel = $configImage; + $this->imageModel = $configImage; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } diff --git a/Model/Config/Source/Effect.php b/Model/Config/Source/Effect.php index f7b6821..21eac5a 100644 --- a/Model/Config/Source/Effect.php +++ b/Model/Config/Source/Effect.php @@ -29,15 +29,15 @@ */ class Effect implements ArrayInterface { - const SLIDER = 'slider'; - const FADE_OUT = 'fadeOut'; - const ROTATE_OUT = 'rotateOut'; - const FLIP_OUT = 'flipOutX'; - const ROLL_OUT = 'rollOut'; - const ZOOM_OUT = 'zoomOut'; - const SLIDER_OUT_LEFT = 'slideOutLeft'; + const SLIDER = 'slider'; + const FADE_OUT = 'fadeOut'; + const ROTATE_OUT = 'rotateOut'; + const FLIP_OUT = 'flipOutX'; + const ROLL_OUT = 'rollOut'; + const ZOOM_OUT = 'zoomOut'; + const SLIDER_OUT_LEFT = 'slideOutLeft'; const SLIDER_OUT_RIGHT = 'slideOutRight'; - const LIGHT_SPEED_OUT = 'lightSpeedOut'; + const LIGHT_SPEED_OUT = 'lightSpeedOut'; /** * to option array @@ -87,4 +87,4 @@ public function toOptionArray() return $options; } -} \ No newline at end of file +} diff --git a/Model/Config/Source/Image.php b/Model/Config/Source/Image.php index b8d914b..1506afe 100644 --- a/Model/Config/Source/Image.php +++ b/Model/Config/Source/Image.php @@ -21,6 +21,8 @@ namespace Mageplaza\BannerSlider\Model\Config\Source; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Filesystem; use Magento\Framework\UrlInterface; @@ -77,10 +79,10 @@ public function getBaseUrl() * get base image dir * * @return string - * @throws \Magento\Framework\Exception\FileSystemException + * @throws FileSystemException */ public function getBaseDir() { - return $this->fileSystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)->getAbsolutePath($this->subDir . '/image/'); + return $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA)->getAbsolutePath($this->subDir . '/image/'); } } diff --git a/Model/Config/Source/Location.php b/Model/Config/Source/Location.php index 4bcaf0b..e7fdb2b 100644 --- a/Model/Config/Source/Location.php +++ b/Model/Config/Source/Location.php @@ -29,24 +29,24 @@ */ class Location implements ArrayInterface { - const ALLPAGE_CONTENT_TOP = 'allpage.content-top'; - const ALLPAGE_CONTENT_BOTTOM = 'allpage.content-bottom'; - const ALLPAGE_PAGE_TOP = 'allpage.page-top'; - const ALLPAGE_PAGE_BOTTOM = 'allpage.footer-container'; - const HOMEPAGE_CONTENT_TOP = 'cms_index_index.content-top'; + const ALLPAGE_CONTENT_TOP = 'allpage.content-top'; + const ALLPAGE_CONTENT_BOTTOM = 'allpage.content-bottom'; + const ALLPAGE_PAGE_TOP = 'allpage.page-top'; + const ALLPAGE_PAGE_BOTTOM = 'allpage.footer-container'; + const HOMEPAGE_CONTENT_TOP = 'cms_index_index.content-top'; const HOMEPAGE_CONTENT_BOTTOM = 'cms_index_index.content-bottom'; - const HOMEPAGE_PAGE_TOP = 'cms_index_index.page-top'; - const HOMEPAGE_PAGE_BOTTOM = 'cms_index_index.footer-container'; - const CATEGORY_CONTENT_TOP = 'catalog_category_view.content-top'; + const HOMEPAGE_PAGE_TOP = 'cms_index_index.page-top'; + const HOMEPAGE_PAGE_BOTTOM = 'cms_index_index.footer-container'; + const CATEGORY_CONTENT_TOP = 'catalog_category_view.content-top'; const CATEGORY_CONTENT_BOTTOM = 'catalog_category_view.content-bottom'; - const CATEGORY_PAGE_TOP = 'catalog_category_view.page-top'; - const CATEGORY_PAGE_BOTTOM = 'catalog_category_view.footer-container'; - const CATEGORY_SIDEBAR_TOP = 'catalog_category_view.sidebar-top'; + const CATEGORY_PAGE_TOP = 'catalog_category_view.page-top'; + const CATEGORY_PAGE_BOTTOM = 'catalog_category_view.footer-container'; + const CATEGORY_SIDEBAR_TOP = 'catalog_category_view.sidebar-top'; const CATEGORY_SIDEBAR_BOTTOM = 'catalog_category_view.sidebar-bottom'; - const PRODUCT_CONTENT_TOP = 'catalog_product_view.content-top'; - const PRODUCT_CONTENT_BOTTOM = 'catalog_product_view.content-bottom'; - const PRODUCT_PAGE_TOP = 'catalog_product_view.page-top'; - const PRODUCT_PAGE_BOTTOM = 'catalog_product_view.footer-container'; + const PRODUCT_CONTENT_TOP = 'catalog_product_view.content-top'; + const PRODUCT_CONTENT_BOTTOM = 'catalog_product_view.content-bottom'; + const PRODUCT_PAGE_TOP = 'catalog_product_view.page-top'; + const PRODUCT_PAGE_BOTTOM = 'catalog_product_view.footer-container'; /** * Return array of options as value-label pairs @@ -152,4 +152,4 @@ public function toOptionArray() return $options; } -} \ No newline at end of file +} diff --git a/Model/Config/Source/Sliders.php b/Model/Config/Source/Sliders.php index 6a344a2..1400efe 100644 --- a/Model/Config/Source/Sliders.php +++ b/Model/Config/Source/Sliders.php @@ -75,4 +75,4 @@ protected function toArray() return $options; } -} \ No newline at end of file +} diff --git a/Model/Config/Source/Template.php b/Model/Config/Source/Template.php index 57868fd..72a772e 100644 --- a/Model/Config/Source/Template.php +++ b/Model/Config/Source/Template.php @@ -89,7 +89,7 @@ public function toOptionArray() */ public function getTemplateHtml() { - $imgTmp = '