Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #20 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
haitv282 authored Dec 18, 2019
2 parents b18fcbf + f90df67 commit bf6dda0
Show file tree
Hide file tree
Showing 58 changed files with 2,915 additions and 2,886 deletions.
26 changes: 13 additions & 13 deletions .github/no-response.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 7
# Label requiring a response
responseRequiredLabel: waiting-customer-response
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there has been no response
to our request for more information from the original author. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further.
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 7
# Label requiring a response
responseRequiredLabel: waiting-customer-response
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there has been no response
to our request for more information from the original author. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further.
31 changes: 17 additions & 14 deletions Block/Adminhtml/Hook/Edit/Tab/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public function __construct(
Authentication $authentication,
array $data = []
) {
$this->fieldFactory = $fieldFactory;
$this->method = $method;
$this->contentType = $contentType;
$this->fieldFactory = $fieldFactory;
$this->method = $method;
$this->contentType = $contentType;
$this->authentication = $authentication;

parent::__construct($context, $registry, $formFactory, $data);
Expand Down Expand Up @@ -135,47 +135,47 @@ protected function _prepareForm()
'values' => $this->authentication->toOptionArray(),

]);
$username = $fieldset->addField('username', 'text', [
$username = $fieldset->addField('username', 'text', [
'name' => 'username',
'label' => __('Username'),
'title' => __('Username'),
]);
$realm = $fieldset->addField('realm', 'text', [
$realm = $fieldset->addField('realm', 'text', [
'name' => 'realm',
'label' => __('Realm'),
'title' => __('Realm'),
]);
$password = $fieldset->addField('password', 'password', [
$password = $fieldset->addField('password', 'password', [
'name' => 'password',
'label' => __('Password'),
'title' => __('Password'),
]);
$nonce = $fieldset->addField('nonce', 'text', [
$nonce = $fieldset->addField('nonce', 'text', [
'name' => 'nonce',
'label' => __('Nonce'),
'title' => __('Nonce'),
]);
$algorithm = $fieldset->addField('algorithm', 'text', [
$algorithm = $fieldset->addField('algorithm', 'text', [
'name' => 'algorithm',
'label' => __('Algorithm'),
'title' => __('Algorithm'),
]);
$qop = $fieldset->addField('qop', 'text', [
$qop = $fieldset->addField('qop', 'text', [
'name' => 'qop',
'label' => __('qop'),
'title' => __('qop'),
]);
$nonceCount = $fieldset->addField('nonce_count', 'text', [
$nonceCount = $fieldset->addField('nonce_count', 'text', [
'name' => 'nonce_count',
'label' => __('Nonce Count'),
'title' => __('Nonce Count'),
]);
$clientNonce = $fieldset->addField('client_nonce', 'text', [
$clientNonce = $fieldset->addField('client_nonce', 'text', [
'name' => 'client_nonce',
'label' => __('Client Nonce'),
'title' => __('Client Nonce'),
]);
$opaque = $fieldset->addField('opaque', 'text', [
$opaque = $fieldset->addField('opaque', 'text', [
'name' => 'opaque',
'label' => __('Opaque'),
'title' => __('Opaque'),
Expand All @@ -201,7 +201,10 @@ protected function _prepareForm()
'name' => 'body',
'label' => __('Body'),
'title' => __('Body'),
'note' => __('Supports <a href="%1" target="_blank">Liquid template</a>', 'https://shopify.github.io/liquid/')
'note' => __(
'Supports <a href="%1" target="_blank">Liquid template</a>',
'https://shopify.github.io/liquid/'
)
])->setRenderer($rendererBlock);

$refField = $this->fieldFactory->create([
Expand Down Expand Up @@ -286,7 +289,7 @@ public function isHidden()
*/
public function getFormHtml()
{
$formHtml = parent::getFormHtml();
$formHtml = parent::getFormHtml();
$childHtml = $this->getChildHtml();

return $formHtml . $childHtml;
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Hook/Edit/Tab/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
array $data = []
) {
$this->enabledisable = $enableDisable;
$this->systemStore = $systemStore;
$this->systemStore = $systemStore;

parent::__construct($context, $registry, $formFactory, $data);
}
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/Hook/Edit/Tab/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function __construct(
Status $status,
array $data = []
) {
$this->_status = $status;
$this->coreRegistry = $coreRegistry;
$this->_status = $status;
$this->coreRegistry = $coreRegistry;
$this->historyCollectionFactory = $historyCollectionFactory;

parent::__construct($context, $backendHelper, $data);
Expand All @@ -96,7 +96,7 @@ public function _construct()
*/
protected function _prepareCollection()
{
$hook = $this->getHook();
$hook = $this->getHook();
$collection = $this->historyCollectionFactory->create();
$collection = $collection->addFieldToFilter('hook_id', $hook->getId());
$this->setCollection($collection);
Expand Down
24 changes: 12 additions & 12 deletions Block/Adminhtml/Hook/Edit/Tab/Renderer/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ public function __construct(
Subscriber $subscriber,
array $data = []
) {
$this->liquidFilters = $liquidFilters;
$this->orderFactory = $orderFactory;
$this->invoiceResource = $invoiceResource;
$this->shipmentResource = $shipmentResource;
$this->creditmemoResource = $creditmemoResource;
$this->hookFactory = $hookFactory;
$this->liquidFilters = $liquidFilters;
$this->orderFactory = $orderFactory;
$this->invoiceResource = $invoiceResource;
$this->shipmentResource = $shipmentResource;
$this->creditmemoResource = $creditmemoResource;
$this->hookFactory = $hookFactory;
$this->orderStatusResource = $orderStatusResource;
$this->customerResource = $customerResource;
$this->customerResource = $customerResource;
$this->catalogEavAttribute = $catalogEavAttribute;
$this->categoryFactory = $categoryFactory;
$this->quoteResource = $quoteResource;
$this->subscriber = $subscriber;
$this->categoryFactory = $categoryFactory;
$this->quoteResource = $quoteResource;
$this->subscriber = $subscriber;

parent::__construct($context, $data);
}
Expand All @@ -183,8 +183,8 @@ public function getHookType()
$type = $this->_request->getParam('type');
if (!$type) {
$hookId = $this->getRequest()->getParam('hook_id');
$hook = $this->hookFactory->create()->load($hookId);
$type = $hook->getHookType();
$hook = $this->hookFactory->create()->load($hookId);
$type = $hook->getHookType();
}
if (!$type) {
$type = 'order';
Expand Down
29 changes: 26 additions & 3 deletions Block/Adminhtml/LiquidFilters.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,37 @@ public function getFilters()
];

$customFilter = [
'count' => ['label' => __('Count'), 'params' => []],
'price' => ['label' => __('Price'), 'params' => []],
'ifEmpty' => ['label' => __('If Empty'), 'params' => [['label' => __('Default'), 'defVal' => '']]],
'count' => ['label' => __('Count'), 'params' => []],
'price' => ['label' => __('Price'), 'params' => []],
'ifEmpty' => ['label' => __('If Empty'), 'params' => [['label' => __('Default'), 'defVal' => '']]],
'phone_correct' => ['label' => __('Correct phone number'), 'params' => []],
];

return array_merge($filters, $customFilter);
}

/**
* @param $phoneNum
*
* @return string|string[]|null
*/
public function phone_correct($phoneNum)
{
if (strncmp($phoneNum, '0031', 4) === 0) {
return $phoneNum;
}

if (strncmp($phoneNum, '+31', 3) === 0) {
return preg_replace('/\+31/', '0031', $phoneNum, 1);
}

if (strncmp($phoneNum, '0', 1) === 0) {
return preg_replace('/0/', '0031', $phoneNum, 1);
}

return $phoneNum;
}

/**
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/ManageHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function _getAddProductButtonOptions()
$splitButtonOptions[$hookType['value']] = [
'label' => $hookType['label'],
'onclick' => "setLocation('" . $this->getUrl('mpwebhook/managehooks/new', [
'type' => $hookType['value']
'type' => $hookType['value']
]) . "')",
'default' => $hookType['value'] === 'new_order',
];
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://www.mageplaza.com/releases/webhook
https://www.mageplaza.com/releases/webhook
2 changes: 1 addition & 1 deletion Controller/Adminhtml/AbstractManageHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
Registry $coreRegistry,
Context $context
) {
$this->hookFactory = $hookFactory;
$this->hookFactory = $hookFactory;
$this->coreRegistry = $coreRegistry;

parent::__construct($context);
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/AbstractManageLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(
Context $context
) {
$this->historyFactory = $historyFactory;
$this->coreRegistry = $coreRegistry;
$this->coreRegistry = $coreRegistry;

parent::__construct($context);
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Logs/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Delete extends AbstractManageLogs
public function execute()
{
$resultRedirect = $this->resultRedirectFactory->create();
$log = $this->initLog();
$log = $this->initLog();
if ($log->getId()) {
try {
/** @var History $log */
Expand Down
6 changes: 3 additions & 3 deletions Controller/Adminhtml/Logs/Replay.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(
Data $helperData
) {
$this->hookFactory = $hookFactory;
$this->helperData = $helperData;
$this->helperData = $helperData;

parent::__construct($historyFactory, $coreRegistry, $context);
}
Expand All @@ -79,12 +79,12 @@ public function __construct(
public function execute()
{
$resultRedirect = $this->resultRedirectFactory->create();
$log = $this->initLog();
$log = $this->initLog();
$resultRedirect->setPath('mpwebhook/logs');
if ($log->getId()) {
try {
$hookId = $log->getHookId();
$hook = $this->hookFactory->create()->load($hookId);
$hook = $this->hookFactory->create()->load($hookId);
if (!$hook->getId()) {
$this->messageManager->addError('The Hook no longer exits');

Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/ManageHooks/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Delete extends AbstractManageHooks
public function execute()
{
$resultRedirect = $this->resultRedirectFactory->create();
$hook = $this->initHook();
$hook = $this->initHook();
if ($hook->getId()) {
try {
/** @var Hook $hook */
Expand Down
14 changes: 7 additions & 7 deletions Controller/Adminhtml/ManageHooks/InlineEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ public function execute()
{
/** @var Json $resultJson */
$resultJson = $this->jsonFactory->create();
$error = false;
$messages = [];
$hookItems = $this->getRequest()->getParam('items', []);
$error = false;
$messages = [];
$hookItems = $this->getRequest()->getParam('items', []);
if (!empty($hookItems) && !$this->getRequest()->getParam('isAjax')) {
return $resultJson->setData([
'messages' => [__('Please correct the data sent.')],
'error' => true,
]);
}

$key = array_keys($hookItems);
$key = array_keys($hookItems);
$hookId = !empty($key) ? (int) $key[0] : '';
/** @var Hook $hook */
$hook = $this->hookFactory->create()->load($hookId);
Expand All @@ -97,16 +97,16 @@ public function execute()
$hook->save();
} catch (LocalizedException $e) {
$messages[] = $this->getErrorWithHookId($hook, $e->getMessage());
$error = true;
$error = true;
} catch (RuntimeException $e) {
$messages[] = $this->getErrorWithHookId($hook, $e->getMessage());
$error = true;
$error = true;
} catch (Exception $e) {
$messages[] = $this->getErrorWithHookId(
$hook,
__('Something went wrong while saving the Post.')
);
$error = true;
$error = true;
}

return $resultJson->setData([
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/ManageHooks/MassDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(
Filter $filter,
CollectionFactory $collectionFactory
) {
$this->filter = $filter;
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;

parent::__construct($context);
Expand Down
6 changes: 3 additions & 3 deletions Controller/Adminhtml/ManageHooks/MassStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(
Filter $filter,
CollectionFactory $collectionFactory
) {
$this->filter = $filter;
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;

parent::__construct($context);
Expand All @@ -76,8 +76,8 @@ public function __construct(
*/
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$status = (int) $this->getRequest()->getParam('status');
$collection = $this->filter->getCollection($this->collectionFactory->create());
$status = (int) $this->getRequest()->getParam('status');
$hookUpdated = 0;
foreach ($collection as $hook) {
try {
Expand Down
10 changes: 5 additions & 5 deletions Cron/AbandonedCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function __construct(
QuoteFactory $quoteFactory,
Data $helper
) {
$this->logger = $logger;
$this->logger = $logger;
$this->quoteFactory = $quoteFactory;
$this->helper = $helper;
$this->helper = $helper;
}

/**
Expand All @@ -78,9 +78,9 @@ public function execute()
}

$abandonedTime = (int) $this->helper->getConfigGeneral('abandoned_time');
$update = (new DateTime())->sub(new DateInterval("PT{$abandonedTime}H"));
$updateTo = clone $update;
$updateFrom = $update->sub(new DateInterval("PT1H"));
$update = (new DateTime())->sub(new DateInterval("PT{$abandonedTime}H"));
$updateTo = clone $update;
$updateFrom = $update->sub(new DateInterval("PT1H"));

/** @var Collection $quoteCollection */
$quoteCollection = $this->quoteFactory->create()->getCollection()
Expand Down
Loading

0 comments on commit bf6dda0

Please sign in to comment.