Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed Oct 13, 2020
1 parent e54bf3e commit 35538bb
Show file tree
Hide file tree
Showing 39 changed files with 5,001 additions and 5,001 deletions.
210 changes: 105 additions & 105 deletions Block/Adminhtml/Hook/Edit.php
Original file line number Diff line number Diff line change
@@ -1,105 +1,105 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Webhook
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Webhook\Block\Adminhtml\Hook;

use Magento\Backend\Block\Widget\Context;
use Magento\Backend\Block\Widget\Form\Container;
use Magento\Framework\Registry;
use Mageplaza\Webhook\Model\Hook;

/**
* Class Edit
* @package Mageplaza\Webhook\Block\Adminhtml\Hook
*/
class Edit extends Container
{
/**
* @var string
*/
protected $_objectId = 'hook_id';

/**
* Core registry
*
* @var Registry
*/
protected $coreRegistry;

/**
* constructor
*
* @param Registry $coreRegistry
* @param Context $context
* @param array $data
*/
public function __construct(
Registry $coreRegistry,
Context $context,
array $data = []
) {
$this->coreRegistry = $coreRegistry;

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

/**
* Initialize Hook edit block
*
* @return void
*/
protected function _construct()
{
$this->_blockGroup = 'Mageplaza_Webhook';
$this->_controller = 'adminhtml_hook';

parent::_construct();

$this->buttonList->add('save-and-continue', [
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => [
'event' => 'saveAndContinueEdit',
'target' => '#edit_form'
]
]
]
], -100);
}

/**
* Get form action URL
*
* @return string
*/
public function getFormActionUrl()
{
/** @var Hook $hook */
$hook = $this->coreRegistry->registry('mageplaza_webhook_hook');
if ($id = $hook->getId()) {
return $this->getUrl('*/*/save', ['hook_id' => $id]);
}

return parent::getFormActionUrl();
}
}
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Webhook
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Webhook\Block\Adminhtml\Hook;

use Magento\Backend\Block\Widget\Context;
use Magento\Backend\Block\Widget\Form\Container;
use Magento\Framework\Registry;
use Mageplaza\Webhook\Model\Hook;

/**
* Class Edit
* @package Mageplaza\Webhook\Block\Adminhtml\Hook
*/
class Edit extends Container
{
/**
* @var string
*/
protected $_objectId = 'hook_id';

/**
* Core registry
*
* @var Registry
*/
protected $coreRegistry;

/**
* constructor
*
* @param Registry $coreRegistry
* @param Context $context
* @param array $data
*/
public function __construct(
Registry $coreRegistry,
Context $context,
array $data = []
) {
$this->coreRegistry = $coreRegistry;

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

/**
* Initialize Hook edit block
*
* @return void
*/
protected function _construct()
{
$this->_blockGroup = 'Mageplaza_Webhook';
$this->_controller = 'adminhtml_hook';

parent::_construct();

$this->buttonList->add('save-and-continue', [
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => [
'event' => 'saveAndContinueEdit',
'target' => '#edit_form'
]
]
]
], -100);
}

/**
* Get form action URL
*
* @return string
*/
public function getFormActionUrl()
{
/** @var Hook $hook */
$hook = $this->coreRegistry->registry('mageplaza_webhook_hook');
if ($id = $hook->getId()) {
return $this->getUrl('*/*/save', ['hook_id' => $id]);
}

return parent::getFormActionUrl();
}
}
106 changes: 53 additions & 53 deletions Block/Adminhtml/Hook/Edit/Form.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Webhook
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Webhook\Block\Adminhtml\Hook\Edit;

use Magento\Backend\Block\Widget\Form\Generic;

/**
* Class Form
* @package Mageplaza\Webhook\Block\Adminhtml\Hook\Edit
*/
class Form extends Generic
{
/**
* @inheritdoc
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getData('action'),
'method' => 'post',
'enctype' => 'multipart/form-data'
]
]
);
$form->setUseContainer(true);
$this->setForm($form);

return parent::_prepareForm();
}
}
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Webhook
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Webhook\Block\Adminhtml\Hook\Edit;

use Magento\Backend\Block\Widget\Form\Generic;

/**
* Class Form
* @package Mageplaza\Webhook\Block\Adminhtml\Hook\Edit
*/
class Form extends Generic
{
/**
* @inheritdoc
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getData('action'),
'method' => 'post',
'enctype' => 'multipart/form-data'
]
]
);
$form->setUseContainer(true);
$this->setForm($form);

return parent::_prepareForm();
}
}
Loading

0 comments on commit 35538bb

Please sign in to comment.