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

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed Dec 18, 2019
1 parent d6ac81f commit f90df67
Show file tree
Hide file tree
Showing 58 changed files with 2,938 additions and 2,932 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
101 changes: 51 additions & 50 deletions Block/Adminhtml/LiquidFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,89 +107,89 @@ public function count($subject)
public function getFilters()
{
$filters = [
'abs' => ['label' => __('Abs'), 'params' => []],
'append' => ['label' => __('Append'), 'params' => [['label' => __('Append'), 'defVal' => '']]],
'at_least' => ['label' => __('At Least'), 'params' => [['label' => __('At Least'), 'defVal' => '']]],
'at_most' => ['label' => __('At Most'), 'params' => [['label' => __('At Most'), 'defVal' => '']]],
'capitalize' => ['label' => __('Capitalize'), 'params' => []],
'ceil' => ['label' => __('Ceil'), 'params' => []],
'date' => ['label' => __('Date'), 'params' => [['label' => __('Date Format'), 'defVal' => '']]],
'default' => ['label' => __('Default'), 'params' => [['label' => __('Default'), 'defVal' => '']]],
'divided_by' => [
'label' => __('Divided By'),
'abs' => ['label' => __('Abs'), 'params' => []],
'append' => ['label' => __('Append'), 'params' => [['label' => __('Append'), 'defVal' => '']]],
'at_least' => ['label' => __('At Least'), 'params' => [['label' => __('At Least'), 'defVal' => '']]],
'at_most' => ['label' => __('At Most'), 'params' => [['label' => __('At Most'), 'defVal' => '']]],
'capitalize' => ['label' => __('Capitalize'), 'params' => []],
'ceil' => ['label' => __('Ceil'), 'params' => []],
'date' => ['label' => __('Date'), 'params' => [['label' => __('Date Format'), 'defVal' => '']]],
'default' => ['label' => __('Default'), 'params' => [['label' => __('Default'), 'defVal' => '']]],
'divided_by' => [
'label' => __('Divided By'),
'params' => [['label' => __('Divided By'), 'defVal' => '']]
],
'downcase' => ['label' => __('Lower Case'), 'params' => []],
'escape' => ['label' => __('Escape'), 'params' => []],
'escape_once' => ['label' => __('Escape once'), 'params' => []],
'floor' => ['label' => __('Floor'), 'params' => []],
'join' => ['label' => __('Join'), 'params' => [['label' => __('Join By'), 'defVal' => '']]],
'lstrip' => ['label' => __('Left Trim'), 'params' => []],
'minus' => ['label' => __('Minus'), 'params' => [['label' => __('Minus'), 'defVal' => '']]],
'modulo' => ['label' => __('Modulo'), 'params' => [['label' => __('Divided By'), 'defVal' => '']]],
'newline_to_br' => ['label' => __('Replace new line to <br'), 'params' => []],
'plus' => ['label' => __('Plus'), 'params' => [['label' => __('Plus'), 'defVal' => '']]],
'prepend' => ['label' => __('Prepend'), 'params' => [['label' => __('Prepend'), 'defVal' => '']]],
'remove' => ['label' => __('Remove'), 'params' => [['label' => __('Remove'), 'defVal' => '']]],
'remove_first' => [
'label' => __('Remove First'),
'downcase' => ['label' => __('Lower Case'), 'params' => []],
'escape' => ['label' => __('Escape'), 'params' => []],
'escape_once' => ['label' => __('Escape once'), 'params' => []],
'floor' => ['label' => __('Floor'), 'params' => []],
'join' => ['label' => __('Join'), 'params' => [['label' => __('Join By'), 'defVal' => '']]],
'lstrip' => ['label' => __('Left Trim'), 'params' => []],
'minus' => ['label' => __('Minus'), 'params' => [['label' => __('Minus'), 'defVal' => '']]],
'modulo' => ['label' => __('Modulo'), 'params' => [['label' => __('Divided By'), 'defVal' => '']]],
'newline_to_br' => ['label' => __('Replace new line to <br'), 'params' => []],
'plus' => ['label' => __('Plus'), 'params' => [['label' => __('Plus'), 'defVal' => '']]],
'prepend' => ['label' => __('Prepend'), 'params' => [['label' => __('Prepend'), 'defVal' => '']]],
'remove' => ['label' => __('Remove'), 'params' => [['label' => __('Remove'), 'defVal' => '']]],
'remove_first' => [
'label' => __('Remove First'),
'params' => [['label' => __('Remove'), 'defVal' => '']]
],
'replace' => [
'label' => __('Replace'),
'replace' => [
'label' => __('Replace'),
'params' => [
['label' => __('Search'), 'defVal' => ''],
['label' => __('Replace'), 'defVal' => '']
]
],
'replace_first' => [
'label' => __('Replace First'),
'replace_first' => [
'label' => __('Replace First'),
'params' => [
['label' => __('Search'), 'defVal' => ''],
['label' => __('Replace'), 'defVal' => '']
]
],
'reverse' => ['label' => __('Reverse Array'), 'params' => []],
'round' => ['label' => __('Round'), 'params' => [['label' => __('Count'), 'defVal' => '']]],
'rstrip' => ['label' => __('Right Trim'), 'params' => []],
'size' => ['label' => __('Array Size'), 'params' => []],
'slice' => [
'label' => __('Slice'),
'reverse' => ['label' => __('Reverse Array'), 'params' => []],
'round' => ['label' => __('Round'), 'params' => [['label' => __('Count'), 'defVal' => '']]],
'rstrip' => ['label' => __('Right Trim'), 'params' => []],
'size' => ['label' => __('Array Size'), 'params' => []],
'slice' => [
'label' => __('Slice'),
'params' => [
['label' => __('From'), 'defVal' => ''],
['label' => __('To'), 'defVal' => '']
]
],
'sort' => ['label' => __('Array Sort'), 'params' => []],
'strip' => ['label' => __('Trim Text'), 'params' => []],
'strip_html' => ['label' => __('Strip Html Tags'), 'params' => []],
'sort' => ['label' => __('Array Sort'), 'params' => []],
'strip' => ['label' => __('Trim Text'), 'params' => []],
'strip_html' => ['label' => __('Strip Html Tags'), 'params' => []],
'strip_newlines' => ['label' => __('Strip New Line'), 'params' => []],
'times' => ['label' => __('Times'), 'params' => [['label' => __('Times'), 'defVal' => '']]],
'truncate' => [
'label' => __('Truncate'),
'times' => ['label' => __('Times'), 'params' => [['label' => __('Times'), 'defVal' => '']]],
'truncate' => [
'label' => __('Truncate'),
'params' => [
['label' => __('Count'), 'Chars' => ''],
['label' => __('Append Last'), 'defVal' => '']
]
],
'truncatewords' => [
'label' => __('Truncate Words'),
'truncatewords' => [
'label' => __('Truncate Words'),
'params' => [
['label' => __('Words'), 'defVal' => ''],
['label' => __('Append Last'), 'defVal' => '']
]
],
'ucwords' => ['label' => __('Uppercase first character of each word '), 'params' => []],
'uniq' => ['label' => __('Unique Id Of Array'), 'params' => []],
'upcase' => ['label' => __('Upper Case'), 'params' => []],
'url_decode' => ['label' => __('Decode Url'), 'params' => []],
'url_encode' => ['label' => __('Encode Url'), 'params' => []]
'ucwords' => ['label' => __('Uppercase first character of each word '), 'params' => []],
'uniq' => ['label' => __('Unique Id Of Array'), 'params' => []],
'upcase' => ['label' => __('Upper Case'), 'params' => []],
'url_decode' => ['label' => __('Decode Url'), 'params' => []],
'url_encode' => ['label' => __('Encode Url'), 'params' => []]
];

$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' => []],
];

Expand All @@ -198,6 +198,7 @@ public function getFilters()

/**
* @param $phoneNum
*
* @return string|string[]|null
*/
public function phone_correct($phoneNum)
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
Loading

0 comments on commit f90df67

Please sign in to comment.