Skip to content

Commit

Permalink
phpcs for magento 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Sep 30, 2019
1 parent 05c8b73 commit 1b9d8b4
Show file tree
Hide file tree
Showing 70 changed files with 1,054 additions and 397 deletions.
2 changes: 0 additions & 2 deletions Block/Adminhtml/Stores/Edit/Tab/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function __construct(
parent::__construct($context, $registry, $formFactory, $data);
}


protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('mailchimp_stores');
Expand Down Expand Up @@ -115,7 +114,6 @@ protected function _prepareForm()
]
);


$data = $model->getData();
$form->setValues($data);
$this->setForm($form);
Expand Down
1 change: 0 additions & 1 deletion Block/Adminhtml/Stores/Edit/Tab/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected function _prepareForm()
$form->setHtmlIdPrefix('stores_');
$form->setFieldNameSuffix('stores');


$fieldset = $form->addFieldset(
'base_fieldset',
['legend' => __('General')]
Expand Down
4 changes: 2 additions & 2 deletions Block/Adminhtml/Stores/Edit/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function _beforeToHtml()
'label' => __('General'),
'title' => __('General'),
'content' => $this->getLayout()->createBlock(
'Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab\Info'
Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab\Info::class
)->toHtml(),
'active' => true
]
Expand All @@ -52,7 +52,7 @@ protected function _beforeToHtml()
'label' => __('Address'),
'title' => __('Address'),
'content' => $this->getLayout()->createBlock(
'Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab\Address'
Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab\Address::class
)->toHtml(),
'active' => false
]
Expand Down
2 changes: 0 additions & 2 deletions Block/Adminhtml/System/Config/CreateWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract

public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{


$originalData = $element->getOriginalData();
$label = $originalData['button_label'];
$this->addData([
Expand Down
6 changes: 0 additions & 6 deletions Block/Adminhtml/System/Config/DeleteStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ protected function _construct()
$this->setTemplate('system/config/deletestore.phtml');
}

// protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
// {
// return $this->_toHtml();
// }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$originalData = $element->getOriginalData();
Expand All @@ -61,8 +57,6 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract

public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{


$originalData = $element->getOriginalData();
$label = $originalData['button_label'];
$this->addData([
Expand Down
7 changes: 4 additions & 3 deletions Block/Adminhtml/System/Config/Fieldset/Hint.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Fieldset;

class Hint extends \Magento\Backend\Block\Template implements \Magento\Framework\Data\Form\Element\Renderer\RendererInterface
class Hint extends \Magento\Backend\Block\Template implements
\Magento\Framework\Data\Form\Element\Renderer\RendererInterface
{
/**
* @var string
Expand Down Expand Up @@ -68,13 +69,13 @@ public function getModuleVersion()
{
return $this->_moduleVersion->getModuleVersion('Ebizmarts_MailChimp');
}
public function getHasApiKey() {
public function getHasApiKey()
{
$apikey = $this->_helper->getApiKey($this->_context->getStoreManager()->getStore()->getId());
if ($apikey) {
return true;
} else {
return false;
}

}
}
4 changes: 2 additions & 2 deletions Block/Adminhtml/System/Config/Form/Field/CustomerMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function _getVarsRenderer()
{
if (!$this->_varsRenderer) {
$this->_varsRenderer = $this->getLayout()->createBlock(
'Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field\VarsMap',
Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field\VarsMap::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
Expand All @@ -37,7 +37,7 @@ protected function _getMailchimpRenderer()
{
if (!$this->_mailchimpRenderer) {
$this->_mailchimpRenderer = $this->getLayout()->createBlock(
'Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field\MailchimpMap',
Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field\MailchimpMap::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
Expand Down
13 changes: 11 additions & 2 deletions Block/Adminhtml/System/Config/Form/Field/MailchimpMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,18 @@ protected function _getMailchimpTags()
$scope = 'default';
}

$api = $this->_helper->getApi($storeId,$scope);
$api = $this->_helper->getApi($storeId, $scope);
try {
$merge = $api->lists->mergeFields->getAll($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST, $storeId, $scope), null, null, \Ebizmarts\MailChimp\Helper\Data::MAX_MERGEFIELDS);
$merge = $api->lists->mergeFields->getAll(
$this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
$storeId,
$scope
),
null,
null,
\Ebizmarts\MailChimp\Helper\Data::MAX_MERGEFIELDS
);
foreach ($merge['merge_fields'] as $item) {
$ret[$item['tag']] = $item['tag'] . ' (' . $item['name'] . ' : ' . $item['type'] . ')';
}
Expand Down
6 changes: 0 additions & 6 deletions Block/Adminhtml/System/Config/ResetErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ protected function _construct()
$this->setTemplate('system/config/reseterrors.phtml');
}

// protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
// {
// return $this->_toHtml();
// }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$originalData = $element->getOriginalData();
Expand All @@ -61,8 +57,6 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract

public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{


$originalData = $element->getOriginalData();
$label = $originalData['button_label'];
$this->addData([
Expand Down
6 changes: 0 additions & 6 deletions Block/Adminhtml/System/Config/ResetStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ protected function _construct()
$this->setTemplate('system/config/resetstore.phtml');
}

// protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
// {
// return $this->_toHtml();
// }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$originalData = $element->getOriginalData();
Expand All @@ -61,8 +57,6 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract

public function getButtonHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{


$originalData = $element->getOriginalData();
$label = $originalData['button_label'];
$this->addData([
Expand Down
1 change: 0 additions & 1 deletion Controller/Adminhtml/Ecommerce/Getaccountdetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public function execute()
$options['error'] = ['label' => 'Error', 'value' => __('--- Invalid API Key ---')];
}


$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($options);
return $resultJson;
Expand Down
1 change: 1 addition & 0 deletions Controller/Adminhtml/Stores.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function __construct(
}
public function execute()
{
return 1;
}
protected function _isAllowed()
{
Expand Down
9 changes: 7 additions & 2 deletions Controller/Adminhtml/Stores/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function execute()
$apiKey = $param['apikey'];
$encrypt = $param['encrypt'];
try {
$api = $this->_helper->getApiByApiKey($apiKey,$encrypt);
$api = $this->_helper->getApiByApiKey($apiKey, $encrypt);
$stores = $api->ecommerce->stores->get(null, null, null, self::MAX_STORES);
$result = [];
foreach ($stores['stores'] as $store) {
Expand All @@ -58,7 +58,12 @@ public function execute()
continue;
}
$list = $api->lists->getLists($store['list_id']);
$result['stores'][] = ['id' => $store['id'], 'name' => $store['name'], 'list_name' => $list['name'], 'list_id' => $store['list_id']];
$result['stores'][] = [
'id' => $store['id'],
'name' => $store['name'],
'list_name' => $list['name'],
'list_id' => $store['list_id']
];
}
$result['valid'] = 1;
}
Expand Down
5 changes: 3 additions & 2 deletions Controller/Adminhtml/Stores/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function execute()
}
protected function _updateMailchimp($formData)
{
$api = $this->_helper->getApiByApiKey($formData['apikey'],true);
$api = $this->_helper->getApiByApiKey($formData['apikey'], true);
// set the address
$address = [];
$address['address1'] = $formData['address_address_one'];
Expand Down Expand Up @@ -87,7 +87,8 @@ protected function _updateMailchimp($formData)
);
} else {
$date = $this->_helper->getDateMicrotime();
$mailchimpStoreId = md5($name. '_' . $date);
$mailchimpStoreId = hash('md5', $name. '_' . $date);
//$mailchimpStoreId = md5($name. '_' . $date);
$is_sync = true;
$ret =$api->ecommerce->stores->add(
$mailchimpStoreId,
Expand Down
18 changes: 9 additions & 9 deletions Controller/Campaign/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Magento\Framework\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;


class Check extends \Magento\Framework\App\Action\Action
{
/**
Expand Down Expand Up @@ -50,28 +49,29 @@ public function execute()
{
$param = $this->getRequest()->getParams();
$mc_cid = null;
if(key_exists('mc_cid', $param)) {
if (key_exists('mc_cid', $param)) {
$mc_cid = $param['mc_cid'];
$magentoStoreId = $this->_storeManager->getStore()->getId();
$api = $this->_helper->getApi($magentoStoreId);
try {
$campaign =$api->campaigns->get($mc_cid);
$mailchimpList = $this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,$magentoStoreId);
if($mailchimpList == $campaign['recipients']['list_id']) {
$mailchimpList = $this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST,
$magentoStoreId
);
if ($mailchimpList == $campaign['recipients']['list_id']) {
$valid = 1;
} else {
$valid = 0;
}
} catch(\Exception $e) {
} catch (\Exception $e) {
$valid = 0;
}
}
else {
} else {
$valid = 0;
}
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData(['valid' => $valid]);
return $resultJson;

}
}
}
16 changes: 12 additions & 4 deletions Controller/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function execute()
try {
$subscriber->loadByEmail($order->getCustomerEmail());
if ($subscriber->getEmail()==$order->getCustomerEmail()) {
if($subscriber->getStatus()==\Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
if ($subscriber->getStatus()==\Magento\Newsletter\Model\Subscriber::STATUS_UNSUBSCRIBED) {
$subscriber->subscribe($subscriber->getEmail());
}
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
Expand All @@ -100,10 +100,18 @@ public function execute()
$this->_helper->log($e->getMessage());
}
$this->messageManager->addSuccessMessage(__('Thanks for share your interest with us'));
$this->_redirect($this->_helper->getBaserUrl($order->getStoreId(), \Magento\Framework\UrlInterface::URL_TYPE_WEB));
$this->_redirect($this->_helper->getBaserUrl(
$order->getStoreId(),
\Magento\Framework\UrlInterface::URL_TYPE_WEB
));
}
protected function _updateSubscriber($listId, $entityId, $sync_delta = null, $sync_error = null, $sync_modified = null)
{
protected function _updateSubscriber(
$listId,
$entityId,
$sync_delta = null,
$sync_error = null,
$sync_modified = null
) {
$this->_helper->saveEcommerceData(
$listId,
$entityId,
Expand Down
2 changes: 1 addition & 1 deletion Controller/WebHook/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function execute()
$chimpRequest->setDataRequest($this->_helper->serialize($request['data']));
$chimpRequest->setProcessed(false);
$chimpRequest->getResource()->save($chimpRequest);
} catch(\Exception $e) {
} catch (\Exception $e) {
$this->_helper->log($e->getMessage());
$this->_helper->log($request['data']);
}
Expand Down
12 changes: 7 additions & 5 deletions Cron/BatchesClean.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class BatchesClean
public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Ebizmarts\MailChimp\Model\MailChimpSyncBatches $_mailChimpSyncBatches
)
{
) {
$this->helper = $helper;
$this->mailChimpSyncBatches = $_mailChimpSyncBatches;
}
Expand All @@ -41,10 +40,13 @@ public function execute()
try {
$connection = $this->mailChimpSyncBatches->getResource()->getConnection();
$tableName = $this->mailChimpSyncBatches->getResource()->getMainTable();
$quoteInto = $connection->quoteInto('status IN("completed","canceled") and ( date_add(modified_date, interval ? month) < now() OR modified_date IS NULL)',1);
$quoteInto = $connection->quoteInto(
'status IN("completed","canceled") and ( date_add(modified_date, interval ? month) < now() OR modified_date IS NULL)',
1
);
$connection->delete($tableName, $quoteInto);
} catch( \Exception $e) {
} catch (\Exception $e) {
$this->helper->log($e->getMessage());
}
}
}
}
Loading

0 comments on commit 1b9d8b4

Please sign in to comment.