HookSystem.php in X Autoload 7.5
File
tests/src/VirtualDrupal/HookSystem.php
View source
<?php
namespace Drupal\xautoload\Tests\VirtualDrupal;
class HookSystem {
private $moduleImplements;
function __construct(DrupalStatic $drupalStatic, Cache $cache, ModuleList $moduleList) {
$this->moduleImplements = new ModuleImplements($drupalStatic, $cache, $moduleList, $this);
}
function moduleInvokeAll($hook) {
$args = func_get_args();
assert($hook === array_shift($args));
foreach ($this
->moduleImplements($hook) as $extension) {
$function = $extension . '_' . $hook;
if (function_exists($function)) {
call_user_func_array($function, $args);
}
}
}
function drupalAlter($hook, &$data) {
$args = func_get_args();
assert($hook === array_shift($args));
assert($data === array_shift($args));
while (count($args) < 3) {
$args[] = NULL;
}
foreach ($this
->moduleImplements($hook . '_alter') as $extension) {
$function = $extension . '_' . $hook . '_alter';
$function($data, $args[0], $args[1], $args[2]);
}
}
function moduleImplements($hook) {
return $this->moduleImplements
->moduleImplements($hook);
}
public function moduleImplementsReset() {
$this->moduleImplements
->reset();
}
}