-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add composer support for Magento 2.3.x / code cleanup
- Loading branch information
Showing
20 changed files
with
267 additions
and
147 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 |
---|---|---|
@@ -1,26 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\GuestToCustomer\Block\Adminhtml\Order\View; | ||
|
||
class GuestToCustomerButtonList extends \Magento\Backend\Block\Widget\Button\ButtonList | ||
use Magento\Backend\Block\Widget\Button\ButtonList; | ||
use Magento\Backend\Block\Widget\Button\ItemFactory; | ||
use Magento\Framework\Registry; | ||
use Magento\Framework\UrlInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use MagePal\GuestToCustomer\Helper\Data; | ||
|
||
/** | ||
* Class GuestToCustomerButtonList | ||
* @package MagePal\GuestToCustomer\Block\Adminhtml\Order\View | ||
*/ | ||
class GuestToCustomerButtonList extends ButtonList | ||
{ | ||
/** | ||
* GuestToCustomerButtonList constructor. | ||
* @param \Magento\Backend\Block\Widget\Button\ItemFactory $itemFactory | ||
* @param \Magento\Framework\Registry $coreRegistry | ||
* @param \Magento\Framework\UrlInterface $urlBuilder | ||
* @param \MagePal\GuestToCustomer\Helper\Data $helperData | ||
* @param ItemFactory $itemFactory | ||
* @param Registry $coreRegistry | ||
* @param UrlInterface $urlBuilder | ||
* @param Data $helperData | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Widget\Button\ItemFactory $itemFactory, | ||
\Magento\Framework\Registry $coreRegistry, | ||
\Magento\Framework\UrlInterface $urlBuilder, | ||
\MagePal\GuestToCustomer\Helper\Data $helperData | ||
ItemFactory $itemFactory, | ||
Registry $coreRegistry, | ||
UrlInterface $urlBuilder, | ||
Data $helperData | ||
) { | ||
parent::__construct($itemFactory); | ||
|
||
/** @var \Magento\Sales\Api\Data\OrderInterface $order */ | ||
/** @var OrderInterface $order */ | ||
$order = $coreRegistry->registry('current_order'); | ||
|
||
if ($helperData->isEnabled() && $order && !$order->getCustomerId()) { | ||
|
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\GuestToCustomer\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\GuestToCustomer\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,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\GuestToCustomer\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\GuestToCustomer\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(); | ||
} | ||
|
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,28 +2,38 @@ | |
/** | ||
* 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\GuestToCustomer\Block\Customer; | ||
|
||
use Magento\Customer\Api\AccountManagementInterface; | ||
use Magento\Customer\Api\CustomerRepositoryInterface; | ||
use Magento\Customer\Api\Data\CustomerInterface; | ||
use Magento\Customer\Model\Session; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Newsletter\Model\Subscriber; | ||
use Magento\Newsletter\Model\SubscriberFactory; | ||
|
||
class LookupForm extends \Magento\Framework\View\Element\Template | ||
/** | ||
* Class LookupForm | ||
* @package MagePal\GuestToCustomer\Block\Customer | ||
*/ | ||
class LookupForm extends Template | ||
{ | ||
/** | ||
* @var \Magento\Newsletter\Model\Subscriber | ||
* @var Subscriber | ||
*/ | ||
protected $subscription; | ||
|
||
/** | ||
* @var \Magento\Customer\Model\Session | ||
* @var Session | ||
*/ | ||
protected $customerSession; | ||
|
||
/** | ||
* @var \Magento\Newsletter\Model\SubscriberFactory | ||
* @var SubscriberFactory | ||
*/ | ||
protected $subscriberFactory; | ||
|
||
|
@@ -37,10 +47,19 @@ class LookupForm extends \Magento\Framework\View\Element\Template | |
*/ | ||
protected $customerAccountManagement; | ||
|
||
/** | ||
* LookupForm constructor. | ||
* @param Context $context | ||
* @param Session $customerSession | ||
* @param SubscriberFactory $subscriberFactory | ||
* @param CustomerRepositoryInterface $customerRepository | ||
* @param AccountManagementInterface $customerAccountManagement | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Customer\Model\Session $customerSession, | ||
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, | ||
Context $context, | ||
Session $customerSession, | ||
SubscriberFactory $subscriberFactory, | ||
CustomerRepositoryInterface $customerRepository, | ||
AccountManagementInterface $customerAccountManagement, | ||
array $data = [] | ||
|
@@ -55,7 +74,7 @@ public function __construct( | |
/** | ||
* Return the Customer given the customer Id stored in the session. | ||
* | ||
* @return \Magento\Customer\Api\Data\CustomerInterface | ||
* @return CustomerInterface | ||
*/ | ||
public function getCustomer() | ||
{ | ||
|
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,28 +2,37 @@ | |
/** | ||
* Copyright © MagePal LLC, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
namespace MagePal\GuestToCustomer\Block\View\Element\Html\Link; | ||
|
||
use Magento\Framework\App\DefaultPathInterface; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use MagePal\GuestToCustomer\Helper\Data; | ||
|
||
/** | ||
* Class Current | ||
* @package MagePal\GuestToCustomer\Block\View\Element\Html\Link | ||
*/ | ||
class Current extends \Magento\Framework\View\Element\Html\Link\Current | ||
{ | ||
|
||
/* @var \MagePal\GuestToCustomer\Helper\Data*/ | ||
/* @var Data*/ | ||
protected $helperData; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param \Magento\Framework\View\Element\Template\Context $context | ||
* @param \MagePal\GuestToCustomer\Helper\Data $helperData | ||
* @param Context $context | ||
* @param DefaultPathInterface $defaultPath | ||
* @param array $data | ||
* @param Data $helperData | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Framework\App\DefaultPathInterface $defaultPath, | ||
Context $context, | ||
DefaultPathInterface $defaultPath, | ||
array $data = [], | ||
\MagePal\GuestToCustomer\Helper\Data $helperData | ||
Data $helperData | ||
) { | ||
parent::__construct($context, $defaultPath, $data); | ||
$this->helperData = $helperData; | ||
|
Oops, something went wrong.