Skip to content

Commit

Permalink
Update customer email address
Browse files Browse the repository at this point in the history
  • Loading branch information
srenon committed Mar 28, 2019
1 parent 6fef637 commit 43b78bd
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 114 deletions.
41 changes: 34 additions & 7 deletions Block/Adminhtml/Email/Edit.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,48 @@

namespace MagePal\EditOrderEmail\Block\Adminhtml\Email;

class Edit extends \Magento\Backend\Block\Template
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Registry;
use Magento\Sales\Api\Data\OrderInterface;
use MagePal\EditOrderEmail\Helper\Data;

class Edit extends Template
{
/**
* Core registry
*
* @var \Magento\Framework\Registry
* @var Registry
*/
protected $coreRegistry = null;

/**
* @var \Magento\Framework\AuthorizationInterface
* MagePal Helper
*
* @var Data
*/
protected $_helper;

/**
* @var Context $context
* @var Registry $coreRegistry
* @var AuthorizationInterface
* @var Data $helper
*/
protected $authorization;

public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\AuthorizationInterface $authorization,
Context $context,
Registry $coreRegistry,
AuthorizationInterface $authorization,
Data $helper,
array $data = []
) {
parent::__construct($context, $data);
$this->coreRegistry = $coreRegistry;
$this->authorization = $authorization;
$this->_helper = $helper;
}

/**
Expand All @@ -48,9 +67,17 @@ public function getOrderId()
return $this->getRequest()->getParam('order_id');
}

/**
* @return int
*/
public function getAutocheckEmail()
{
return $this->_helper->getConfigValue('magepal_editorderemail/general/update_customer_email');
}

public function getEmailAddress()
{
/** @var \Magento\Sales\Api\Data\OrderInterface $order */
/** @var OrderInterface $order */
if ($order = $this->coreRegistry->registry('sales_order')) {
return $order->getCustomerEmail();
}
Expand Down
49 changes: 30 additions & 19 deletions Block/Adminhtml/System/Config/Form/Composer/Version.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,45 @@

namespace MagePal\EditOrderEmail\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 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 DeploymentConfig $deploymentConfig
* @param ComponentRegistrarInterface $componentRegistrar
* @param ReadFactory $readFactory
*/
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;
Expand All @@ -46,11 +57,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();
Expand All @@ -60,11 +71,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();
}
Expand Down Expand Up @@ -93,12 +104,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
);

Expand All @@ -110,7 +121,7 @@ public function getComposerVersion($moduleName)
$data = json_decode($composerJsonData);
return !empty($data->version) ? $data->version : __('Unknown');
}
} catch (\Exception $e) {
} catch (Exception $e) {
//
}

Expand Down
28 changes: 17 additions & 11 deletions Block/Adminhtml/System/Config/Form/Module/Version.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@

namespace MagePal\EditOrderEmail\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 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);
Expand All @@ -32,11 +38,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();
Expand All @@ -46,11 +52,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();
}
Expand Down
Loading

0 comments on commit 43b78bd

Please sign in to comment.