Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class ActionAdminControllerInitBefore extends Hook
{
/**
* @param array $params
*
* @return string
*/
public function execute(array $params = [])
{
return '';
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
class ActionAdminControllerSetMedia extends Hook
{
/**
* @return void
*/
public function execute(array $params = [])
{
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use Exception;
use PrestaShop\Module\PsAccounts\Service\AnalyticsService;
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
class ActionAdminLoginControllerLoginAfter extends Hook
{
/**
* @param array $params
*
* @return void
*
* @throws Exception
*/
public function execute(array $params = [])
{
if ($this->module->isShopEdition()) {
$this->trackLoginEvent($params['employee']);
}
}
/**
* @param \Employee $employee
*
* @return void
*
* @throws Exception
*/
protected function trackLoginEvent(\Employee $employee)
{
/** @var AnalyticsService $analyticsService */
$analyticsService = $this->module->getService(AnalyticsService::class);
/** @var PsAccountsService $psAccountsService */
$psAccountsService = $this->module->getService(PsAccountsService::class);
$account = $psAccountsService->getEmployeeAccount();
$uid = null;
if ($account) {
$uid = $account->getUid();
$email = $account->getEmail();
} else {
$email = $employee->email;
}
$analyticsService->identify($uid, null, $email);
$analyticsService->group($uid, (string) $psAccountsService->getShopUuid());
$analyticsService->trackUserSignedIntoBackOfficeLocally($uid, $email);
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use AdminLoginPsAccountsController;
use Exception;
use PrestaShop\Module\PsAccounts\Account\Command\UpdateBackOfficeUrlsCommand;
use PrestaShop\Module\PsAccounts\Adapter\Link;
use PrestaShop\Module\PsAccounts\Service\AnalyticsService;
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
use Tools;
class ActionAdminLoginControllerSetMedia extends Hook
{
/**
* @return void
*
* @throws Exception
*/
public function execute(array $params = [])
{
// Check and update URL if admin url changed (before login)
// Only check before login form is being submitted
$this->checkAndUpdateBackofficeUrl();
if (defined('_PS_VERSION_') &&
version_compare(_PS_VERSION_, '8', '>=')) {
if (version_compare(_PS_VERSION_, '9', '<')) {
$this->executeV8();
} else {
$this->executeV9();
}
}
}
/**
* @return void
*
* @throws Exception
*/
protected function executeV8()
{
$local = $this->isLocalLogin();
$this->trackEditionLoginPage($local);
if (!$local) {
$this->redirectLegacyAccountLoginController();
}
}
/**
* @return void
*
* @throws Exception
*/
protected function executeV9()
{
$local = $this->isLocalLogin();
$this->trackEditionLoginPage($local);
if (!$local) {
$this->redirectSymfonyAccountLoginController();
}
}
/**
* @return bool
*/
protected function isLocalLogin()
{
/** @var PsAccountsService $psAccountsService */
$psAccountsService = $this->module->getService(PsAccountsService::class);
return Tools::getValue('mode') === AdminLoginPsAccountsController::PARAM_MODE_LOCAL ||
!empty(Tools::getValue('reset_token')) ||
!$psAccountsService->getLoginActivated();
}
/**
* @return void
*/
protected function redirectLegacyAccountLoginController()
{
// /** @var Link $link */
// $link = $this->module->getService(Link::class);
// Tools::redirectLink($link->getAdminLink('AdminLoginPsAccounts', false));
(new AdminLoginPsAccountsController())->run();
exit;
}
/**
* @return void
*/
protected function redirectSymfonyAccountLoginController()
{
/** @var Link $link */
$link = $this->module->getService(Link::class);
header('Location: ' . $link->getAdminLink('SfAdminLoginPsAccounts', false));
exit;
}
/**
* @param bool $local
*
* @return void
*
* @throws Exception
*/
protected function trackEditionLoginPage($local = false)
{
if ($this->module->isShopEdition()) {
/** @var PsAccountsService $psAccountsService */
$psAccountsService = $this->module->getService(PsAccountsService::class);
$account = $psAccountsService->getEmployeeAccount();
$userId = $account ? $account->getUid() : null;
/** @var AnalyticsService $analytics */
$analytics = $this->module->getService(AnalyticsService::class);
if (!$local) {
$analytics->pageAccountsBoLogin($userId);
} else {
$analytics->pageLocalBoLogin($userId);
}
}
}
/**
* Check if admin URL changed and update if needed
*
* @return void
*/
protected function checkAndUpdateBackofficeUrl()
{
$this->commandBus->handle(new UpdateBackOfficeUrlsCommand());
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use PrestaShop\Module\PsAccounts\Repository\EmployeeAccountRepository;
class ActionObjectEmployeeDeleteAfter extends Hook
{
/**
* @param array $params
*
* @return void
*
* @throws \Exception
*/
public function execute(array $params = [])
{
try {
/** @var \Employee $employee */
$employee = $params['object'];
$repository = new EmployeeAccountRepository();
$employeeAccount = $repository->findByEmployeeId($employee->id);
if ($employeeAccount) {
$repository->delete($employeeAccount);
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use Exception;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
class ActionObjectShopAddAfter extends Hook
{
/**
* @param array $params
*
* @return bool
*
* @throws Exception
*/
public function execute(array $params = [])
{
/** @var ConfigurationRepository $configurationRepository */
$configurationRepository = $this->module->getService(ConfigurationRepository::class);
$configurationRepository->fixMultiShopConfig();
return true;
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use Exception;
use PrestaShop\Module\PsAccounts\Account\Command\CleanupIdentityCommand;
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
class ActionObjectShopDeleteAfter extends Hook
{
/**
* @param array $params
*
* @return bool
*
* @throws Exception
*/
public function execute(array $params = [])
{
/** @var ConfigurationRepository $configurationRepository */
$configurationRepository = $this->module->getService(ConfigurationRepository::class);
$configurationRepository->fixMultiShopConfig();
$this->commandBus->handle((new CleanupIdentityCommand($params['object']->id)));
return true;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class ActionObjectShopDeleteBefore extends Hook
{
/**
* @param array $params
*
* @return bool
*/
public function execute(array $params = [])
{
return true;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class ActionObjectShopUpdateAfter extends Hook
{
/**
* @param array $params
*
* @return bool
*/
public function execute(array $params = [])
{
return true;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class ActionObjectShopUrlUpdateAfter extends ActionObjectShopUpdateAfter
{
/**
* @param array $params
*
* @return bool
*/
public function execute(array $params = [])
{
return true;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use PrestaShop\Module\PsAccounts\Account\Token\Token;
class ActionShopAccessTokenRefreshAfter extends Hook
{
/**
* @param array $params
*
* @return void
*
* @throws \Exception
*/
public function execute(array $params = [])
{
/** @var Token $token */
$token = $params['token'];
// TODO: something with the token
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class ActionShopAccountLinkAfter extends Hook
{
/**
* @param array $params
*
* @return void
*/
public function execute(array $params = [])
{
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class ActionShopAccountUnlinkAfter extends Hook
{
/**
* @param array $params
*
* @return void
*/
public function execute(array $params = [])
{
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class DisplayAccountUpdateWarning extends Hook
{
/**
* @param array $params
*
* @return string
*/
public function execute(array $params = [])
{
return '';
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
class DisplayBackOfficeEmployeeMenu extends Hook
{
/**
* @param array $params
*
* @return void
*
* @throws \Exception
*/
public function execute(array $params = [])
{
if (class_exists('\PrestaShop\PrestaShop\Core\Action\ActionsBarButton')) {
$bar = $params['links'];
$link = $this->module->getParameter('ps_accounts.accounts_ui_url') . '?' . http_build_query([
'utm_source' => \Tools::getShopDomain(),
'utm_medium' => 'back-office',
'utm_campaign' => $this->module->name,
'utm_content' => 'headeremployeedropdownlink',
]);
$bar->add(
new \PrestaShop\PrestaShop\Core\Action\ActionsBarButton(
'', ['link' => $link, 'icon' => 'open_in_new'], $this->module->l('Manage your PrestaShop account')
)
);
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use Exception;
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
class DisplayBackOfficeHeader extends Hook
{
/**
* @return string
*
* @throws Exception
*/
public function execute(array $params = [])
{
try {
if (preg_match('/controller=AdminModules/', $_SERVER['REQUEST_URI']) &&
preg_match('/configure=ps_accounts/', $_SERVER['REQUEST_URI']) ||
preg_match('@modules/manage/action/configure/ps_accounts@', $_SERVER['REQUEST_URI'])
) {
return '';
}
/** @var PsAccountsService $psAccountsService */
$psAccountsService = $this->module->getService(PsAccountsService::class);
$this->module->getContext()->controller->addJs(
$this->module->getLocalPath() . 'views/js/notifications.js' .
'?ctx=' . urlencode($psAccountsService->getAdminAjaxUrl() . '&action=getNotifications') .
'&v=' . urlencode($this->module->version)
);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
return '';
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
/**
* @deprecated
*/
class DisplayDashboardTop extends Hook
{
/**
* @param array $params
*
* @return string
*/
public function execute(array $params = [])
{
return '';
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
use PrestaShop\Module\PsAccounts\Cqrs\CommandBus;
use PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger;
use Ps_accounts;
abstract class Hook
{
/**
* @var Ps_accounts
*/
protected $module;
/**
* @var CommandBus
*/
protected $commandBus;
/**
* @var Logger
*/
protected $logger;
/**
* @param Ps_accounts $module
*
* @throws \Exception
*/
public function __construct(Ps_accounts $module)
{
$this->module = $module;
$this->commandBus = $module->getService(CommandBus::class);
$this->logger = $module->getLogger();
}
/**
* @param array $params
*
* @return mixed
*/
abstract public function execute(array $params = []);
/**
* @return string
*/
public static function getName()
{
return lcfirst(preg_replace('/^.*\\\\/', '', static::class));
}
/**
* @return Ps_accounts
*/
public function getModule()
{
return $this->module;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
namespace PrestaShop\Module\PsAccounts\Hook;
trait HookableTrait
{
/**
* @param string $methodName
*
* @return mixed
*
* @throws \Exception
*/
private function executeHook($methodName, array $params = [])
{
$hookNamespace = __NAMESPACE__;
if (strpos($methodName, 'hook') === 0) {
$class = $hookNamespace . '\\' . ucfirst(preg_replace('/^hook/', '', $methodName));
$method = 'execute';
if (is_a($class, Hook::class, true)) {
$this->getLogger()->debug("execute hook : [{$class}]");
$hook = (new $class($this));
return $hook->$method($params);
}
}
return null;
}
/**
* @param string $name
* @param array $arguments
*
* @return mixed
*
* @throws \Exception
*/
public function __call($name, array $arguments)
{
return $this->executeHook($name, is_array($arguments[0]) ? $arguments[0] : []);
}
}

View File

@@ -0,0 +1,11 @@
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;