-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for 2.3.x and code refactoring
- Loading branch information
Showing
16 changed files
with
249 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,39 +2,56 @@ | |
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Composer; | ||
|
||
class Version extends \Magento\Config\Block\System\Config\Form\Field | ||
use Exception; | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\App\DeploymentConfig; | ||
use Magento\Framework\Component\ComponentRegistrar; | ||
use Magento\Framework\Component\ComponentRegistrarInterface; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Filesystem\Directory\ReadFactory; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* Class Version | ||
* @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Composer | ||
*/ | ||
class Version extends Field | ||
{ | ||
|
||
/** | ||
* @var \Magento\Framework\App\DeploymentConfig | ||
* @var DeploymentConfig | ||
*/ | ||
protected $deploymentConfig; | ||
|
||
/** | ||
* @var \Magento\Framework\Component\ComponentRegistrarInterface | ||
* @var ComponentRegistrarInterface | ||
*/ | ||
protected $componentRegistrar; | ||
|
||
/** | ||
* @var \Magento\Framework\Filesystem\Directory\ReadFactory | ||
* @var ReadFactory | ||
*/ | ||
protected $readFactory; | ||
|
||
/** | ||
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig | ||
* @param \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar | ||
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory | ||
* @param Context $context | ||
* @param DeploymentConfig $deploymentConfig | ||
* @param ComponentRegistrarInterface $componentRegistrar | ||
* @param ReadFactory $readFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\App\DeploymentConfig $deploymentConfig, | ||
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar, | ||
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, | ||
Context $context, | ||
DeploymentConfig $deploymentConfig, | ||
ComponentRegistrarInterface $componentRegistrar, | ||
ReadFactory $readFactory, | ||
array $data = [] | ||
) { | ||
$this->deploymentConfig = $deploymentConfig; | ||
|
@@ -46,11 +63,11 @@ public function __construct( | |
/** | ||
* Render button | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @throws LocalizedException | ||
*/ | ||
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
public function render(AbstractElement $element) | ||
{ | ||
// Remove scope label | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
|
@@ -60,11 +77,11 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele | |
/** | ||
* Return element html | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
return 'v' . $this->getVersion(); | ||
} | ||
|
@@ -93,12 +110,12 @@ public function getModuleName() | |
* Get module composer version | ||
* | ||
* @param $moduleName | ||
* @return \Magento\Framework\Phrase|string|void | ||
* @return Phrase|string|void | ||
*/ | ||
public function getComposerVersion($moduleName) | ||
{ | ||
$path = $this->componentRegistrar->getPath( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
ComponentRegistrar::MODULE, | ||
$moduleName | ||
); | ||
|
||
|
@@ -110,7 +127,7 @@ public function getComposerVersion($moduleName) | |
$data = json_decode($composerJsonData); | ||
return !empty($data->version) ? $data->version : __('Unknown'); | ||
} | ||
} catch (\Exception $e) { | ||
} catch (Exception $e) { | ||
// | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
/** | ||
|
@@ -12,17 +12,35 @@ | |
*/ | ||
namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
class OrderIncrement extends \Magento\Config\Block\System\Config\Form\Field | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\DataObject; | ||
use Magento\Sales\Model\Order; | ||
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
|
||
/** | ||
* Class OrderIncrement | ||
* @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field | ||
*/ | ||
class OrderIncrement extends Field | ||
{ | ||
|
||
/** | ||
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory | ||
* @var CollectionFactory | ||
*/ | ||
protected $orderCollectionFactory; | ||
|
||
/** | ||
* OrderIncrement constructor. | ||
* @param Context $context | ||
* @param CollectionFactory $orderCollectionFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, | ||
Context $context, | ||
CollectionFactory $orderCollectionFactory, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
|
@@ -32,16 +50,16 @@ public function __construct( | |
/** | ||
* Get the grid and scripts contents | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
$this->setElement($element); | ||
|
||
if (!$element->getEscapedValue()) { | ||
|
||
/** @var \Magento\Sales\Model\Order $order */ | ||
/** @var Order $order */ | ||
$order = $this->getLastOrder(); | ||
|
||
if ($order->getId()) { | ||
|
@@ -53,7 +71,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract | |
} | ||
|
||
/** | ||
* @return \Magento\Store\Api\Data\StoreInterface|null | ||
* @return StoreInterface|null | ||
*/ | ||
public function getCurrentStore() | ||
{ | ||
|
@@ -70,7 +88,7 @@ public function getCurrentStore() | |
} | ||
|
||
/** | ||
* @return \Magento\Framework\DataObject | ||
* @return DataObject | ||
*/ | ||
public function getLastOrder() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,20 @@ | |
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Url; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
|
||
/** | ||
* Class Locations Backend system config array field renderer | ||
* Class Preview | ||
* @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field | ||
*/ | ||
class Preview extends Field | ||
{ | ||
|
@@ -20,19 +25,19 @@ class Preview extends Field | |
protected $_template = 'MagePal_PreviewCheckoutSuccessPage::system/config/form/field/preview.phtml'; | ||
|
||
/** | ||
* @var \Magento\Framework\Url | ||
* @var Url | ||
*/ | ||
protected $urlHelper; | ||
|
||
/** | ||
* Preview constructor. | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Url $urlHelper | ||
* @param Context $context | ||
* @param Url $urlHelper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Url $urlHelper, | ||
Context $context, | ||
Url $urlHelper, | ||
array $data = [] | ||
) { | ||
$this->urlHelper = $urlHelper; | ||
|
@@ -41,10 +46,10 @@ public function __construct( | |
|
||
|
||
/** | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
public function render(AbstractElement $element) | ||
{ | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
|
||
|
@@ -54,29 +59,29 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele | |
} | ||
|
||
/** | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _renderValue(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
protected function _renderValue(AbstractElement $element) | ||
{ | ||
return $this->_getElementHtml($element); | ||
} | ||
|
||
/** | ||
* Get the grid and scripts contents | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
$this->setElement($element); | ||
|
||
return $this->_toHtml(); | ||
} | ||
|
||
/** | ||
* @return \Magento\Store\Api\Data\StoreInterface|null | ||
* @return StoreInterface|null | ||
*/ | ||
public function getCurrentStore() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,37 @@ | |
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Module; | ||
|
||
class Version extends \Magento\Config\Block\System\Config\Form\Field | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Module\ModuleListInterface; | ||
|
||
/** | ||
* Class Version | ||
* @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Module | ||
*/ | ||
class Version extends Field | ||
{ | ||
|
||
/** | ||
* @var \Magento\Framework\Module\ModuleListInterface | ||
* @var ModuleListInterface | ||
*/ | ||
protected $_moduleList; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Module\ModuleListInterface $moduleList | ||
* @param Context $context | ||
* @param ModuleListInterface $moduleList | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Module\ModuleListInterface $moduleList, | ||
Context $context, | ||
ModuleListInterface $moduleList, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
|
@@ -32,11 +42,11 @@ public function __construct( | |
/** | ||
* Render button | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @throws LocalizedException | ||
*/ | ||
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
public function render(AbstractElement $element) | ||
{ | ||
// Remove scope label | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
|
@@ -46,11 +56,11 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele | |
/** | ||
* Return element html | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @param AbstractElement $element | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
return 'v' . $this->getVersion(); | ||
} | ||
|
Oops, something went wrong.