Skip to content

Commit

Permalink
Fixed PHPCS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Aug 7, 2020
1 parent c1e782c commit decb87f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion controllers/front/ajax.php
Expand Up @@ -17,7 +17,6 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Ps_ShoppingcartAjaxModuleFrontController extends ModuleFrontController
{
/**
Expand All @@ -27,6 +26,7 @@ class Ps_ShoppingcartAjaxModuleFrontController extends ModuleFrontController

/**
* @see FrontController::initContent()
*
* @return void
*/
public function initContent()
Expand Down
1 change: 0 additions & 1 deletion img/icon/index.php
Expand Up @@ -17,7 +17,6 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

Expand Down
1 change: 0 additions & 1 deletion img/index.php
Expand Up @@ -17,7 +17,6 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

Expand Down
1 change: 0 additions & 1 deletion index.php
Expand Up @@ -17,7 +17,6 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

Expand Down
90 changes: 48 additions & 42 deletions ps_shoppingcart.php
Expand Up @@ -44,10 +44,10 @@ public function __construct()
$this->bootstrap = true;
parent::__construct();

$this->displayName = $this->trans('Shopping cart', array(), 'Modules.Shoppingcart.Admin');
$this->description = $this->trans('Adds a block containing the customer\'s shopping cart.', array(), 'Modules.Shoppingcart.Admin');
$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_);
$this->controllers = array('ajax');
$this->displayName = $this->trans('Shopping cart', [], 'Modules.Shoppingcart.Admin');
$this->description = $this->trans('Adds a block containing the customer\'s shopping cart.', [], 'Modules.Shoppingcart.Admin');
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
$this->controllers = ['ajax'];
}

/**
Expand All @@ -73,9 +73,9 @@ private function getCartSummaryURL()
'cart',
null,
$this->context->language->id,
array(
[
'action' => 'show',
),
],
false,
null,
true
Expand All @@ -85,22 +85,24 @@ private function getCartSummaryURL()
/**
* @param string|null $hookName
* @param array<string,mixed> $params
*
* @return array<string,mixed>
*/
public function getWidgetVariables($hookName, array $params)
{
$cart_url = $this->getCartSummaryURL();

return array(
return [
'cart' => (new CartPresenter())->present(isset($params['cart']) ? $params['cart'] : $this->context->cart),
'refresh_url' => $this->context->link->getModuleLink('ps_shoppingcart', 'ajax', array(), null, null, null, true),
'refresh_url' => $this->context->link->getModuleLink('ps_shoppingcart', 'ajax', [], null, null, null, true),
'cart_url' => $cart_url,
);
];
}

/**
* @param string|null $hookName
* @param array<string,mixed> $params
*
* @return string
*/
public function renderWidget($hookName, array $params)
Expand All @@ -119,7 +121,9 @@ public function renderWidget($hookName, array $params)
* @param int $id_product
* @param int $id_product_attribute
* @param int $id_customization
*
* @return string
*
* @throws Exception
*/
public function renderModal(Cart $cart, $id_product, $id_product_attribute, $id_customization)
Expand All @@ -135,11 +139,11 @@ public function renderModal(Cart $cart, $id_product, $id_product_attribute, $id_
}
}

$this->smarty->assign(array(
$this->smarty->assign([
'product' => $product,
'cart' => $data,
'cart_url' => $this->getCartSummaryURL(),
));
]);

return $this->fetch('module:ps_shoppingcart/modal.tpl');
}
Expand All @@ -153,7 +157,7 @@ public function getContent()
if (Tools::isSubmit('submitBlockCart')) {
$ajax = Tools::getValue('PS_BLOCK_CART_AJAX');
if ($ajax != 0 && $ajax != 1) {
$output .= $this->displayError($this->trans('Ajax: Invalid choice.', array(), 'Modules.Shoppingcart.Admin'));
$output .= $this->displayError($this->trans('Ajax: Invalid choice.', [], 'Modules.Shoppingcart.Admin'));
} else {
Configuration::updateValue('PS_BLOCK_CART_AJAX', (int) ($ajax));
}
Expand All @@ -178,6 +182,7 @@ public function install()

/**
* Migrate data from 1.6 equivalent module (if applicable), then uninstall
*
* @return bool
*/
public function uninstallPrestaShop16Module()
Expand All @@ -189,12 +194,13 @@ public function uninstallPrestaShop16Module()
if ($oldModule) {
// This closure calls the parent class to prevent data to be erased
// It allows the new module to be configured without migration
$parentUninstallClosure = function() {
$parentUninstallClosure = function () {
return parent::uninstall();
};
$parentUninstallClosure = $parentUninstallClosure->bindTo($oldModule, get_class($oldModule));
$parentUninstallClosure();
}

return true;
}

Expand All @@ -203,38 +209,38 @@ public function uninstallPrestaShop16Module()
*/
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->trans('Settings', array(), 'Admin.Global'),
$fields_form = [
'form' => [
'legend' => [
'title' => $this->trans('Settings', [], 'Admin.Global'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
],
'input' => [
[
'type' => 'switch',
'label' => $this->trans('Ajax cart', array(), 'Modules.Shoppingcart.Admin'),
'label' => $this->trans('Ajax cart', [], 'Modules.Shoppingcart.Admin'),
'name' => 'PS_BLOCK_CART_AJAX',
'is_bool' => true,
'desc' => $this->trans('Activate Ajax mode for the cart (compatible with the default theme).', array(), 'Modules.Shoppingcart.Admin'),
'values' => array(
array(
'desc' => $this->trans('Activate Ajax mode for the cart (compatible with the default theme).', [], 'Modules.Shoppingcart.Admin'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->trans('Enabled', array(), 'Admin.Global'),
),
array(
'label' => $this->trans('Enabled', [], 'Admin.Global'),
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->trans('Disabled', array(), 'Admin.Global'),
),
),
),
),
'submit' => array(
'title' => $this->trans('Save', array(), 'Admin.Actions'),
),
),
);
'label' => $this->trans('Disabled', [], 'Admin.Global'),
],
],
],
],
'submit' => [
'title' => $this->trans('Save', [], 'Admin.Actions'),
],
],
];

$helper = new HelperForm();
$helper->show_toolbar = false;
Expand All @@ -248,22 +254,22 @@ public function renderForm()
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab
. '&module_name=' . $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
$helper->tpl_vars = [
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);
];

return $helper->generateForm(array($fields_form));
return $helper->generateForm([$fields_form]);
}

/**
* @return bool[]
*/
public function getConfigFieldsValues()
{
return array(
return [
'PS_BLOCK_CART_AJAX' => (bool) Tools::getValue('PS_BLOCK_CART_AJAX', Configuration::get('PS_BLOCK_CART_AJAX')),
);
];
}
}
1 change: 0 additions & 1 deletion translations/index.php
Expand Up @@ -17,7 +17,6 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

Expand Down

0 comments on commit decb87f

Please sign in to comment.