contao/import — Issue #3311: System::triggerHook
Author: aschempp
Created: 2011-11-29 21:19:28+00:00
State: open
Labels: Feature, framework

I'd like to see a generic hook trigger function in the system class.

```
class System
{
protected function triggerHook($strName, $arrParameters=array(), $strGroup='TL_HOOKS')
{
if (isset($GLOBALS[$strGroup][$strName]) && is_array($GLOBALS[$strGroup][$strName]))
{
foreach ($GLOBALS[$strGroup][$strName] as $callback)
{
$this->import($callback[0]);
call_user_func_array(array($this->$callback[0], $callback[1]), $arrParameters);
}
}
}
}
```

I haven't tested this, and I'm not sure if the callback works with an imported object. I also dislike to use the `import()` function, especially for non-system classes, but I think you get the point :-)

Related issues: #1074

--- _Originally created on July 27th, 2011, at 09:36am (ID 3311)_