Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed Oct 1, 2020
1 parent 07726d8 commit 03ec50e
Show file tree
Hide file tree
Showing 58 changed files with 1,496 additions and 1,464 deletions.
68 changes: 34 additions & 34 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
---
name: Bug report
about: Technical issue with the extension
labels: 'Issue'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Preconditions (*)
<!---
Provide the exact Magento version (example: 2.4.0) and any important information on the environment where bug is reproducible.
-->
1.
2.

### Steps to reproduce (*)
<!---
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
-->
1.
2.

### Expected result (*)
<!--- Tell us what do you expect to happen. -->
1. [Screenshots, logs or description]
2.

### Actual result (*)
<!--- Tell us what happened instead. Include error messages and issues. -->
1. [Screenshots, logs or description]
2.
---
name: Bug report
about: Technical issue with the extension
labels: 'Issue'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Preconditions (*)
<!---
Provide the exact Magento version (example: 2.4.0) and any important information on the environment where bug is reproducible.
-->
1.
2.

### Steps to reproduce (*)
<!---
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
-->
1.
2.

### Expected result (*)
<!--- Tell us what do you expect to happen. -->
1. [Screenshots, logs or description]
2.

### Actual result (*)
<!--- Tell us what happened instead. Include error messages and issues. -->
1. [Screenshots, logs or description]
2.
38 changes: 19 additions & 19 deletions .github/ISSUE_TEMPLATE/developer-experience-issue.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
name: Developer experience issue
about: Issues related to customization, extensibility, modularity
labels: 'Experience'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Summary (*)
<!--- Describe the issue you are experiencing. Include general information, error messages, environments, and so on. -->

### Examples (*)
<!--- Provide code examples or a patch with a test (recommended) to clearly indicate the problem. -->

### Proposed solution
<!--- Suggest your potential solutions for this issue. -->
---
name: Developer experience issue
about: Issues related to customization, extensibility, modularity
labels: 'Experience'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Summary (*)
<!--- Describe the issue you are experiencing. Include general information, error messages, environments, and so on. -->

### Examples (*)
<!--- Provide code examples or a patch with a test (recommended) to clearly indicate the problem. -->

### Proposed solution
<!--- Suggest your potential solutions for this issue. -->
44 changes: 22 additions & 22 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
name: Feature request
about: Request feature for development
labels: 'Feature Request'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Description (*)
<!--- Describe the feature you would like to add. -->

### Expected behavior (*)
<!--- What is the expected behavior of this feature? How is it going to work? -->

### Benefits
<!--- How do you think this feature would improve the extension? -->

### Additional information
<!--- What other information can you provide about the desired feature? -->
---
name: Feature request
about: Request feature for development
labels: 'Feature Request'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Description (*)
<!--- Describe the feature you would like to add. -->

### Expected behavior (*)
<!--- What is the expected behavior of this feature? How is it going to work? -->

### Benefits
<!--- How do you think this feature would improve the extension? -->

### Additional information
<!--- What other information can you provide about the desired feature? -->
82 changes: 41 additions & 41 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
<!---
Thank you for contributing to Mageplaza extension.
To help us process this pull request we recommend that you add the following information:
- Summary of the pull request,
- Issue(s) related to the changes made,
- Manual testing scenarios
Fields marked with (*) are required. Please don't remove the template.
-->

<!--- Please provide a general summary of the Pull Request in the Title above -->

### Description (*)
<!---
Please provide a description of the changes proposed in the pull request.
Letting us know what has changed and why it needed changing will help us validate this pull request.
-->

### Related Pull Requests
<!-- related pull request placeholder -->

### Fixed Issues (if relevant)
<!---
If relevant, please provide a list of fixed issues in the format magento/magento2#<issue_number>.
There could be 1 or more issues linked here and it will help us find some more information about the reasoning behind this change.
-->
1. Fixes mageplaza/magento-2-smtp#<issue_number>

### Manual testing scenarios (*)
<!---
Please provide a set of unambiguous steps to test the proposed code change.
Giving us manual testing scenarios will help with the processing and validation process.
-->
1. ...
2. ...

### Questions or comments
<!---
If relevant, here you can ask questions or provide comments on your pull request for the reviewer
For example if you need assistance with writing tests or would like some feedback on one of your development ideas
-->

<!---
Thank you for contributing to Mageplaza extension.
To help us process this pull request we recommend that you add the following information:
- Summary of the pull request,
- Issue(s) related to the changes made,
- Manual testing scenarios
Fields marked with (*) are required. Please don't remove the template.
-->

<!--- Please provide a general summary of the Pull Request in the Title above -->

### Description (*)
<!---
Please provide a description of the changes proposed in the pull request.
Letting us know what has changed and why it needed changing will help us validate this pull request.
-->

### Related Pull Requests
<!-- related pull request placeholder -->

### Fixed Issues (if relevant)
<!---
If relevant, please provide a list of fixed issues in the format magento/magento2#<issue_number>.
There could be 1 or more issues linked here and it will help us find some more information about the reasoning behind this change.
-->
1. Fixes mageplaza/magento-2-smtp#<issue_number>

### Manual testing scenarios (*)
<!---
Please provide a set of unambiguous steps to test the proposed code change.
Giving us manual testing scenarios will help with the processing and validation process.
-->
1. ...
2. ...

### Questions or comments
<!---
If relevant, here you can ask questions or provide comments on your pull request for the reviewer
For example if you need assistance with writing tests or would like some feedback on one of your development ideas
-->

15 changes: 8 additions & 7 deletions Block/AbandonedCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public function __construct(
HelperAbandonedCart $helperAbandonedCart,
array $data = []
) {
$this->_productRepository = $productRepository;
$this->priceCurrency = $priceCurrency;
$this->taxHelper = $context->getTaxData();
$this->quoteFactory = $quoteFactory;
$this->helperAbandonedCart = $helperAbandonedCart;
$this->_productRepository = $productRepository;
$this->priceCurrency = $priceCurrency;
$this->taxHelper = $context->getTaxData();
$this->quoteFactory = $quoteFactory;
$this->helperAbandonedCart = $helperAbandonedCart;
parent::__construct($context, $data);
}

Expand All @@ -112,6 +112,7 @@ public function getHelperAbandonedCart()
{
return $this->helperAbandonedCart;
}

/**
* Get items in quote
*
Expand Down Expand Up @@ -139,7 +140,7 @@ public function getSubtotal($inclTax = false)
{
$subtotal = 0;
if ($quote = $this->getQuote()) {
$address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
$address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
$subtotal = $inclTax ? $address->getSubtotalInclTax() : $address->getSubtotal();
}

Expand Down Expand Up @@ -174,7 +175,7 @@ public function getProductImage(Item $item)
/** @var Product $product */
$product = $this->_productRepository->getById($productId);
/** @var Store $store */
$store = $this->_storeManager->getStore();
$store = $this->_storeManager->getStore();
$imageUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

return str_replace('\\', '/', $imageUrl);
Expand Down
1 change: 1 addition & 0 deletions Block/Adminhtml/AbandonedCart/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Smtp\Block\Adminhtml\AbandonedCart;

use Magento\Backend\Block\Widget\Form\Container;
Expand Down
41 changes: 22 additions & 19 deletions Block/Adminhtml/AbandonedCart/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Smtp\Block\Adminhtml\AbandonedCart\Edit;

use Exception;
use IntlDateFormatter;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Catalog\Helper\Data as CatalogHelper;
use Magento\Config\Model\Config\Source\Email\Identity;
use Magento\Config\Model\Config\Source\Email\Template;
use Magento\Customer\Api\GroupRepositoryInterface;
use Magento\Customer\Model\Address\Config as AddressConfig;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Registry;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address;
use Magento\Quote\Model\Quote\Item;
use Mageplaza\Smtp\Model\Source\AbandonedCartStatus;
use Magento\Catalog\Helper\Data as CatalogHelper;
use Magento\Config\Model\Config\Source\Email\Identity;
use Magento\Config\Model\Config\Source\Email\Template;
use Magento\Tax\Model\Config as TaxConfig;
use Mageplaza\Smtp\Model\ResourceModel\Log\CollectionFactory as LogCollectionFactory;
use Mageplaza\Smtp\Helper\AbandonedCart;
use Magento\Customer\Api\GroupRepositoryInterface;
use Mageplaza\Smtp\Model\ResourceModel\Log\CollectionFactory as LogCollectionFactory;
use Mageplaza\Smtp\Model\Source\AbandonedCartStatus;

/**
* Class Form
Expand Down Expand Up @@ -128,13 +131,13 @@ public function __construct(
GroupRepositoryInterface $groupRepository,
array $data = []
) {
$this->addressConfig = $addressConfig;
$this->priceCurrency = $priceCurrency;
$this->emailIdentity = $emailIdentity;
$this->emailTemplate = $emailTemplate;
$this->taxConfig = $taxConfig;
$this->logCollectionFactory = $logCollectionFactory;
$this->helperAbandonedCart = $helperAbandonedCart;
$this->addressConfig = $addressConfig;
$this->priceCurrency = $priceCurrency;
$this->emailIdentity = $emailIdentity;
$this->emailTemplate = $emailTemplate;
$this->taxConfig = $taxConfig;
$this->logCollectionFactory = $logCollectionFactory;
$this->helperAbandonedCart = $helperAbandonedCart;
$this->groupRepository = $groupRepository;

parent::__construct($context, $registry, $formFactory, $data);
Expand Down Expand Up @@ -186,7 +189,7 @@ public function getHelperAbandonedCart()
*/
public function getSubtotal(Quote $quote, $inclTax = false)
{
$address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
$address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
$subtotal = $inclTax ? $address->getSubtotalInclTax() : $address->getSubtotal();

return $this->formatPrice($subtotal, $quote->getId());
Expand Down Expand Up @@ -222,10 +225,10 @@ public function getSentDateLogs($ids)
foreach ($collection as $log) {
$logDatesHtml .= $this->formatDate(
$log->getCreatedAt(),
\IntlDateFormatter::MEDIUM,
IntlDateFormatter::MEDIUM,
true
);
$logDatesHtml.='</br>';
$logDatesHtml .= '</br>';
}
}
}
Expand Down Expand Up @@ -354,13 +357,13 @@ public function isSingleStoreMode()
* @param Quote $quote
*
* @return string
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws NoSuchEntityException
*/
public function getStoreName(Quote $quote)
{
$storeId = $quote->getStoreId();
$store = $this->_storeManager->getStore($storeId);
$name = [$store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()];
$store = $this->_storeManager->getStore($storeId);
$name = [$store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()];

return implode('<br/>', $name);
}
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/Log/ClearButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function __construct(UrlInterface $urlBuilder)
public function getButtonData()
{
return [
'label' => __('Clear All Logs'),
'class' => 'primary',
'on_click' => 'deleteConfirm(\'' . __(
'label' => __('Clear All Logs'),
'class' => 'primary',
'on_click' => 'deleteConfirm(\'' . __(
'Are you sure you want to clear all email logs?'
) . '\', \'' . $this->_urlBuilder->getUrl('*/*/clear') . '\')',
'sort_order' => 10,
Expand Down
Loading

0 comments on commit 03ec50e

Please sign in to comment.