Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1759 Cleanup before further optimizations #1762

Open
wants to merge 2 commits into
base: develop-2.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions Block/Adminhtml/Customer/Edit/Tabs/Mailchimp.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
<?php
/**
* MailChimp Magento Component
*
* @category Ebizmarts
* @package MailChimp
* @author Ebizmarts Team <[email protected]>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 11/29/17 1:55 PM
* @file: Mailchimp.php
*/

namespace Ebizmarts\MailChimp\Block\Adminhtml\Customer\Edit\Tabs;

use Magento\Customer\Controller\RegistryConstants;
use Magento\Ui\Component\Layout\Tabs\TabInterface;
use Magento\Backend\Block\Widget\Form;
use Magento\Backend\Block\Widget\Form\Generic;

class Mailchimp extends \Magento\Backend\Block\Template implements TabInterface
{
Expand All @@ -30,7 +17,6 @@ class Mailchimp extends \Magento\Backend\Block\Template implements TabInterface
protected $_coreRegistry;

/**
* Mailchimp constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Data\FormFactory $formFactory
Expand Down Expand Up @@ -80,6 +66,7 @@ public function canShowTab()
if ($this->getCustomerId()) {
return true;
}

return false;
}

Expand All @@ -91,12 +78,12 @@ public function isHidden()
if ($this->getCustomerId()) {
return false;
}

return true;
}

/**
* Tab class getter
*
* @return string
*/
public function getTabClass()
Expand All @@ -106,7 +93,6 @@ public function getTabClass()

/**
* Return URL link to Tab content
*
* @return string
*/
public function getTabUrl()
Expand All @@ -116,7 +102,6 @@ public function getTabUrl()

/**
* Tab should be loaded trough Ajax call
*
* @return bool
*/
public function isAjaxLoaded()
Expand Down
13 changes: 1 addition & 12 deletions Block/Adminhtml/Customer/Edit/Tabs/View/Customer.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
<?php
/**
* MailChimp Magento Component
*
* @category Ebizmarts
* @package MailChimp
* @author Ebizmarts Team <[email protected]>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 11/29/17 2:49 PM
* @file: Customer.php
*/


namespace Ebizmarts\MailChimp\Block\Adminhtml\Customer\Edit\Tabs\View;

Expand All @@ -30,7 +20,6 @@ class Customer extends \Magento\Backend\Block\Template
protected $registry;

/**
* Customer constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
Expand Down
19 changes: 4 additions & 15 deletions Block/Adminhtml/Stores/Edit.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
<?php
/**
* mc-magento2 Magento Component
*
* @category Ebizmarts
* @package mc-magento2
* @author Ebizmarts Team <[email protected]>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 4/10/17 1:08 PM
* @file: Edit.php
*/

namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores;

use Magento\Backend\Block\Widget\Form\Container;
use Magento\Backend\Block\Widget\Context;
use Magento\Backend\Block\Widget\Form\Container;
use Magento\Framework\Registry;

class Edit extends Container
Expand All @@ -23,8 +12,8 @@ class Edit extends Container
* @var Registry
*/
protected $_coreRegistry;

/**
* Edit constructor.
* @param Context $context
* @param Registry $registry
* @param array $data
Expand All @@ -34,10 +23,10 @@ public function __construct(
Registry $registry,
array $data = []
) {

$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}

protected function _construct()
{
$this->_objectId = 'id';
Expand Down Expand Up @@ -68,14 +57,14 @@ protected function _construct()

/**
* Retrieve text for header element depending on loaded news
*
* @return string
*/
public function getHeaderText()
{
$storeRegistry = $this->_coreRegistry->registry('mailchimp_stores');
if ($storeRegistry->getId()) {
$storeTitle = $this->escapeHtml($storeRegistry->getTitle());

return __("Edit Store '%1'", $storeTitle);
} else {
return __('Add Store');
Expand Down
13 changes: 1 addition & 12 deletions Block/Adminhtml/Stores/Edit/Form.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
<?php
/**
* mc-magento2 Magento Component
*
* @category Ebizmarts
* @package mc-magento2
* @author Ebizmarts Team <[email protected]>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 4/10/17 4:04 PM
* @file: Form.php
*/

namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit;

Expand All @@ -23,7 +12,7 @@ protected function _prepareForm()
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'id' => 'edit_form',
'action' => $this->getData('action'),
'method' => 'post'
]
Expand Down
60 changes: 26 additions & 34 deletions Block/Adminhtml/Stores/Edit/Tab/Address.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
<?php
/**
* mc-magento2 Magento Component
*
* @category Ebizmarts
* @package mc-magento2
* @author Ebizmarts Team <[email protected]>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 4/12/17 5:07 PM
* @file: Address.php
*/

namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab;

use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Backend\Block\Widget\Tab\TabInterface;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\Registry;

class Address extends Generic implements TabInterface
{
Expand All @@ -26,7 +16,6 @@ class Address extends Generic implements TabInterface
protected $_country;

/**
* Address constructor.
* @param Context $context
* @param Registry $registry
* @param FormFactory $formFactory
Expand All @@ -40,15 +29,14 @@ public function __construct(
\Magento\Directory\Model\Config\Source\Country $country,
array $data = []
) {

$this->_country = $country;
parent::__construct($context, $registry, $formFactory, $data);
}

protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('mailchimp_stores');
$form = $this->_formFactory->create();
$model = $this->_coreRegistry->registry('mailchimp_stores');
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('stores_');
$form->setFieldNameSuffix('stores');
$fieldset = $form->addFieldset(
Expand All @@ -66,51 +54,51 @@ protected function _prepareForm()
'address_address_one',
'text',
[
'name' => 'address_address_one',
'label' => __('Street'),
'required' => true
'name' => 'address_address_one',
'label' => __('Street'),
'required' => true
]
);
$fieldset->addField(
'address_address_two',
'text',
[
'name' => 'address_address_two',
'label' => __('Street'),
'required' => false
'name' => 'address_address_two',
'label' => __('Street'),
'required' => false
]
);
$fieldset->addField(
'address_city',
'text',
[
'name' => 'address_city',
'label' => __('City'),
'required' => true
'name' => 'address_city',
'label' => __('City'),
'required' => true
]
);
$fieldset->addField(
'address_postal_code',
'text',
[
'name' => 'address_postal_code',
'label' => __('Postal Code'),
'required' => false
'name' => 'address_postal_code',
'label' => __('Postal Code'),
'required' => false
]
);
$country = $this->_country->toOptionArray();
$countryArray = [''=> __('Select one')];
$countryArray = ['' => __('Select one')];
foreach ($country as $c) {
$countryArray[$c['value']] = $c['label'];
}
$fieldset->addField(
'address_country_code',
'select',
[
'name' => 'address_country_code',
'label' => __('Country'),
'required' => true,
'options' => $countryArray
'name' => 'address_country_code',
'label' => __('Country'),
'required' => true,
'options' => $countryArray
]
);

Expand All @@ -120,18 +108,22 @@ protected function _prepareForm()

return parent::_prepareForm();
}

public function getTabLabel()
{
return __('Store Address Info');
}

public function getTabTitle()
{
return __('Store Address Info');
}

public function canShowTab()
{
return true;
}

public function isHidden()
{
return false;
Expand Down
Loading