File manager - Edit - /home/asiatechinc/public_html/bhrhotelsindia.com/modules/Core/Helpers/HookManager.php
Back
<?php namespace Modules\Core\Helpers; class HookManager { protected static $inst; /** * Holds all registered actions. * * @var ActionManager */ protected $action; /** * Holds all registered filters. * * @var FilterManager */ protected $filter; /** * Construct the class. */ public function __construct(ActionManager $action,FilterManager $filter) { $this->action = $action; $this->filter = $filter; } /** * Get the action instance. * * @return ActionManager */ public function getAction() { return $this->action; } /** * Get the action instance. * * @return FilterManager */ public function getFilter() { return $this->filter; } /** * Add an action. * * @param string $hook Hook name * @param mixed $callback Function to execute * @param int $priority Priority of the action * @param int $arguments Number of arguments to accept */ public function addAction($hook, $callback, $priority = 20, $arguments = 1) { $this->action->listen($hook, $callback, $priority, $arguments); } /** * Remove an action. * * @param string $hook Hook name * @param mixed $callback Function to execute * @param int $priority Priority of the action */ public function removeAction($hook, $callback, $priority = 20) { $this->action->remove($hook, $callback, $priority); } /** * Remove all actions. * * @param string $hook Hook name */ public function removeAllActions($hook = null) { $this->action->removeAll($hook); } /** * Adds a filter. * * @param string $hook Hook name * @param mixed $callback Function to execute * @param int $priority Priority of the action * @param int $arguments Number of arguments to accept */ public function addFilter($hook, $callback, $priority = 20, $arguments = 1) { $this->filter->listen($hook, $callback, $priority, $arguments); } /** * Remove a filter. * * @param string $hook Hook name * @param mixed $callback Function to execute * @param int $priority Priority of the action */ public function removeFilter($hook, $callback, $priority = 20) { $this->filter->remove($hook, $callback, $priority); } /** * Remove all filters. * * @param string $hook Hook name */ public function removeAllFilters($hook = null) { $this->filter->removeAll($hook); } /** * Set a new action. * * Actions never return anything. It is merely a way of executing code at a specific time in your code. * * You can add as many parameters as you'd like. * * @param string $action Name of hook * @param mixed $parameter1 A parameter * @param mixed $parameter2 Another parameter * * @return void */ public function action() { $args = func_get_args(); $hook = $args[0]; unset($args[0]); $args = array_values($args); $this->action->fire($hook, $args); } /** * Set a new filter. * * Filters should always return something. The first parameter will always be the default value. * * You can add as many parameters as you'd like. * * @param string $action Name of hook * @param mixed $value The original filter value * @param mixed $parameter1 A parameter * @param mixed $parameter2 Another parameter * * @return void */ public function filter() { $args = func_get_args(); $hook = $args[0]; unset($args[0]); $args = array_values($args); return $this->filter->fire($hook, $args); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings