Skip to content

Commit

Permalink
modifications from phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Nov 6, 2018
1 parent 8b808c8 commit 0c5d379
Show file tree
Hide file tree
Showing 55 changed files with 385 additions and 403 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Customer/Edit/Tabs/Mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ public function isAjaxLoaded()
{
return false;
}
}
}
9 changes: 5 additions & 4 deletions Block/Adminhtml/Customer/Edit/Tabs/View/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Magento\Framework\Registry $registry,
array $data)
{
array $data
) {

parent::__construct($context, $data);
$this->helper = $helper;
$this->subscriberFactory = $subscriberFactory;
Expand All @@ -55,6 +56,6 @@ public function getInterest()
$subscriber = $this->subscriberFactory->create();
$customerId = $this->registry->registry(\Magento\Customer\Controller\RegistryConstants::CURRENT_CUSTOMER_ID);
$subscriber->loadByCustomerId($customerId);
return $this->helper->getSubscriberInterest($subscriber->getSubscriberId(),$subscriber->getStoreId());
return $this->helper->getSubscriberInterest($subscriber->getSubscriberId(), $subscriber->getStoreId());
}
}
}
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 @@ -13,7 +13,7 @@

namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field;

class CustomerMap extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
class CustomerMap extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
/**
* @var VarsMap
Expand Down Expand Up @@ -72,4 +72,4 @@ protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
$optionExtraAttr
);
}
}
}
12 changes: 6 additions & 6 deletions Block/Adminhtml/System/Config/Form/Field/MailchimpMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field;

class MailchimpMap extends \Magento\Framework\View\Element\Html\Select
class MailchimpMap extends \Magento\Framework\View\Element\Html\Select
{
/**
* @var \Ebizmarts\MailChimp\Helper\Data
Expand All @@ -35,9 +35,9 @@ public function __construct(
\Magento\Framework\View\Element\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data=[]
)
{
array $data = []
) {

parent::__construct($context, $data);
$this->_helper = $helper;
$this->_storeManager = $storeManager;
Expand All @@ -52,7 +52,7 @@ protected function _getMailchimpTags()
foreach ($merge['merge_fields'] as $item) {
$ret[$item['tag']] = $item['tag'] . ' (' . $item['name'] . ' : ' . $item['type'] . ')';
}
} catch(\Mailchimp_Error $e) {
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
return $ret;
Expand All @@ -76,4 +76,4 @@ public function _toHtml()
}
return parent::_toHtml();
}
}
}
12 changes: 6 additions & 6 deletions Block/Adminhtml/System/Config/Form/Field/VarsMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Form\Field;

class VarsMap extends \Magento\Framework\View\Element\Html\Select
class VarsMap extends \Magento\Framework\View\Element\Html\Select
{
/**
* @var \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory
Expand All @@ -28,9 +28,9 @@ class VarsMap extends \Magento\Framework\View\Element\Html\Select
public function __construct(
\Magento\Framework\View\Element\Context $context,
\Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attCollection,
array $data=[]
)
{
array $data = []
) {

parent::__construct($context, $data);
$this->_attCollection = $attCollection;
}
Expand All @@ -42,7 +42,7 @@ protected function _getCustomerAtt()
/**
* @var $item \Magento\Customer\Model\Attribute
*/
foreach($collection as $item) {
foreach ($collection as $item) {
$ret[$item->getId()] = $item->getFrontendLabel();
}

Expand All @@ -69,4 +69,4 @@ public function _toHtml()
}
return parent::_toHtml();
}
}
}
3 changes: 2 additions & 1 deletion Block/Adminhtml/System/Config/OauthWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'button_url' => $this->authorizeRequestUrl(),
'html_id' => $element->getHtmlId(),
]);
return parent::_toHtml();;
return parent::_toHtml();
;
}
public function authorizeRequestUrl()
{
Expand Down
11 changes: 5 additions & 6 deletions Block/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function __construct(
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
array $data
)
{
) {

parent::__construct($context, $data);
$this->_checkoutSession = $checkoutSession;
$this->_helper = $helper;
Expand All @@ -65,12 +65,12 @@ public function getInterest()
$subscriber = $this->_subscriberFactory->create();
$subscriber->loadByEmail($order->getCustomerEmail());

return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(),$subscriber->getStoreId());
return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(), $subscriber->getStoreId());
}
protected function getValues($category)
{
$rc =[];
foreach($category as $c) {
foreach ($category as $c) {
$rc[] = ['value'=>$c['id'],'label'=>$c['name']];
}
return $rc;
Expand All @@ -88,5 +88,4 @@ public function getFormUrl()
$order = $this->_checkoutSession->getLastRealOrder();
return $this->_helper->getSuccessInterestUrl($order->getStoreId());
}

}
}
10 changes: 4 additions & 6 deletions Block/Newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Ebizmarts\MailChimp\Block;


class Newsletter extends \Magento\Framework\View\Element\Template
{
/**
Expand Down Expand Up @@ -43,8 +42,8 @@ public function __construct(
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Ebizmarts\MailChimp\Helper\Data $helper,
array $data
)
{
) {

parent::__construct($context, $data);
$this->_helper = $helper;
$this->subscriberFactory = $subscriberFactory;
Expand All @@ -56,11 +55,10 @@ public function getInterest()
$subscriber = $this->subscriberFactory->create();
$subscriber->loadByCustomerId($this->customerSession->getCustomerId());
// $subscriber = $this->getSubscriptionObject();
return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(),$subscriber->getStoreId());
return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(), $subscriber->getStoreId());
}
public function getFormUrl()
{
return $this->getUrl('mailchimp/accountmanage/save');
}

}
}
10 changes: 4 additions & 6 deletions Controller/Adminhtml/Ecommerce/CreateWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManagerInterface,
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Config\Model\ResourceModel\Config $config
)
{
) {

parent::__construct($context);
$this->resultJsonFactory = $resultJsonFactory;
$this->helper = $helper;
Expand All @@ -62,7 +62,7 @@ public function execute()
$apiKey = $params['apikey'];
$listId = $params['listId'];
$return = $this->helper->createWebHook($apiKey, $listId);
if(isset($return['message'])) {
if (isset($return['message'])) {
$valid = 0;
$message = $return['message'];
}
Expand All @@ -72,11 +72,9 @@ public function execute()
'valid' => (int)$valid,
'message' => $message,
]);

}
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
}

}
}
8 changes: 4 additions & 4 deletions Controller/Adminhtml/Ecommerce/GetInterest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public function execute()
$param = $this->getRequest()->getParams();
$rc = [];
$error = 0;
if(array_key_exists('apikey',$param)&&array_key_exists('list',$param)) {
if (array_key_exists('apikey', $param) && array_key_exists('list', $param)) {
$apiKey = $param['apikey'];
$list = $param['list'];
try {
$api = $this->_helper->getApiByApiKey($apiKey);
$result = $api->lists->interestCategory->getAll($list);
if (is_array($result['categories'])&&count($result['categories'])) {
if (is_array($result['categories']) && count($result['categories'])) {
$rc = $result['categories'];
}
} catch(\Mailchimp_Error $e) {
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
$error = 1;
}
Expand All @@ -77,4 +77,4 @@ protected function _isAllowed()
{
return $this->_authorization->isAllowed('Ebizmarts_MailChimp::config_mailchimp');
}
}
}
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Errors/Getresponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function execute()
do {
$counter++;
$files = $this->_result->getBatchResponse($batchId, $errors->getStoreId());
if($files===false) {
if ($files===false) {
$fileContent = "Response was deleted from MailChimp servers";
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Lists/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function execute()
foreach ($lists['lists'] as $list) {
$result[] = ['id' => $list['id'], 'name' => $list['name']];
}
} catch(\Mailchimp_Error $e) {
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
$resultJson = $this->_resultFactory->create(ResultFactory::TYPE_JSON);
Expand Down
4 changes: 2 additions & 2 deletions Controller/Adminhtml/Stores/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public function execute()

// Restore previously entered form data from session
$data = $this->_session->getStoreData(true);
if(isset($data['name'])) {
if (isset($data['name'])) {
$data['name'] = preg_replace('/ \(Warning: not connected\)/', '', $data['name']);
}
if (!empty($data)) {
$model->setData($data);
}
if(isset($model['name'])) {
if (isset($model['name'])) {
$model['name'] = preg_replace('/ \(Warning: not connected\)/', '', $model['name']);
}
$this->_coreRegistry->register('mailchimp_stores', $model);
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Stores/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function execute()
$result = [];
foreach ($stores['stores'] as $store) {
if ($store['platform'] == \Ebizmarts\MailChimp\Helper\Data::PLATFORM) {
if($store['list_id']=='') {
if ($store['list_id']=='') {
continue;
}
$list = $api->lists->getLists($store['list_id']);
Expand Down
5 changes: 3 additions & 2 deletions Controller/Cart/Loadquote.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ public function execute()
$url = $this->_urlHelper->getUrl(
$this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_ABANDONEDCART_PAGE,
$magentoStoreId),
['mc_cid'=> $params['mc_cid']]
$magentoStoreId
),
['mc_cid'=> $params['mc_cid']]
);
} else {
$url = $this->_urlHelper->getUrl(
Expand Down
30 changes: 17 additions & 13 deletions Controller/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Ebizmarts\MailChimp\Controller\Checkout;



class Success extends \Magento\Framework\App\Action\Action
{
/**
Expand Down Expand Up @@ -60,8 +58,8 @@ public function __construct(
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
\Magento\Framework\Serialize\Serializer\Json $serializer
)
{
) {

$this->_pageFactory =$pageFactory;
$this->_helper = $helper;
$this->_checkoutSession = $checkoutSession;
Expand All @@ -83,8 +81,8 @@ public function execute()
$interestGroup = $this->_interestGroupFactory->create();
try {
$subscriber->loadByEmail($order->getCustomerEmail());
if($subscriber->getEmail()==$order->getCustomerEmail()) {
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(),$subscriber->getStoreId());
if ($subscriber->getEmail()==$order->getCustomerEmail()) {
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
$interestGroup->setGroupdata($this->_serializer->serialize($params));
$interestGroup->setSubscriberId($subscriber->getSubscriberId());
$interestGroup->setStoreId($subscriber->getStoreId());
Expand All @@ -95,22 +93,28 @@ public function execute()
} else {
$this->_subscriberFactory->create()->subscribe($order->getCustomerEmail());
$subscriber->loadByEmail($order->getCustomerEmail());
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(),$subscriber->getStoreId());
$interestGroup->getBySubscriberIdStoreId($subscriber->getSubscriberId(), $subscriber->getStoreId());
$interestGroup->setGroupdata($this->_serializer->serialize($params));
$interestGroup->setSubscriberId($subscriber->getSubscriberId());
$interestGroup->setStoreId($subscriber->getStoreId());
$interestGroup->setUpdatedAt($this->_helper->getGmtDate());
$interestGroup->getResource()->save($interestGroup);
}
} catch(\Exception $e) {
} catch (\Exception $e) {
$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, \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER,
$sync_delta, $sync_error, $sync_modified);
$this->_helper->saveEcommerceData(
$listId,
$entityId,
\Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER,
$sync_delta,
$sync_error,
$sync_modified
);
}
}
}
Loading

0 comments on commit 0c5d379

Please sign in to comment.