Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed May 3, 2019
1 parent a1e1cd6 commit 54ba83d
Show file tree
Hide file tree
Showing 70 changed files with 626 additions and 522 deletions.
6 changes: 3 additions & 3 deletions Block/Adminhtml/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions Block/Adminhtml/Banner/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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()));
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/Banner/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -58,16 +59,15 @@ public function __construct(
FormFactory $formFactory,
Template $template,
array $data = []
)
{
) {
$this->template = $template;

parent::__construct($context, $registry, $formFactory, $data);
}

/**
* @return Generic
* @throws \Magento\Framework\Exception\LocalizedException
* @throws LocalizedException
*/
protected function _prepareForm()
{
Expand Down
34 changes: 17 additions & 17 deletions Block/Adminhtml/Banner/Edit/Tab/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,7 +46,7 @@ class Banner extends Generic implements TabInterface
/**
* Type options
*
* @var \Mageplaza\BannerSlider\Model\Config\Source\Type
* @var Type
*/
protected $typeOptions;

Expand All @@ -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;

Expand Down Expand Up @@ -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', [
Expand Down Expand Up @@ -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' => ''
]);
Expand Down
5 changes: 2 additions & 3 deletions Block/Adminhtml/Banner/Edit/Tab/Render/GridImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public function __construct(
Context $context,
ImageModel $imageModel,
array $data = []
)
{
) {
$this->imageModel = $imageModel;

parent::__construct($context, $data);
Expand All @@ -72,4 +71,4 @@ public function render(DataObject $row)

return '';
}
}
}
3 changes: 1 addition & 2 deletions Block/Adminhtml/Banner/Edit/Tab/Render/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public function __construct(
Escaper $escaper,
UrlInterface $urlBuilder,
array $data
)
{
) {
$this->imageModel = $imageModel;

parent::__construct($factoryElement, $factoryCollection, $escaper, $urlBuilder, $data);
Expand Down
18 changes: 9 additions & 9 deletions Block/Adminhtml/Banner/Edit/Tab/Render/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -38,7 +39,7 @@ class Slider extends Multiselect
/**
* Authorization
*
* @var \Magento\Framework\AuthorizationInterface
* @var AuthorizationInterface
*/
public $authorization;

Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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 = [];
Expand Down Expand Up @@ -176,4 +176,4 @@ public function getAfterElementHtml()

return $html;
}
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/Banner/Edit/Tab/Render/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public function render(DataObject $row)

return $status === '1' ? 'Enable' : 'Disable';
}
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/Banner/Edit/Tab/Render/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ public function render(DataObject $row)

return $type;
}
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/Banner/Edit/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions Block/Adminhtml/Config/Field/Responsive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
10 changes: 6 additions & 4 deletions Block/Adminhtml/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
13 changes: 6 additions & 7 deletions Block/Adminhtml/Slider/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,9 +50,9 @@ public function __construct(
Registry $coreRegistry,
Context $context,
array $data = []
)
{
) {
$this->coreRegistry = $coreRegistry;

parent::__construct($context, $data);
}

Expand All @@ -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();
Expand Down Expand Up @@ -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()));
Expand All @@ -107,8 +108,6 @@ public function getHeaderText()
*/
public function getSlider()
{
$slider = $this->coreRegistry->registry('mpbannerslider_slider');

return $slider;
return $this->coreRegistry->registry('mpbannerslider_slider');
}
}
Loading

0 comments on commit 54ba83d

Please sign in to comment.