- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/hook.php
- Класс: BitrixLandingHook
- Вызов: Hook::getList
static function getList($id, $type, array $data = array())
{
$hooks = array();
$classDir = self::HOOKS_PAGE_DIR;
$classNamespace = self::HOOKS_NAMESPACE;
$excludedHooks = BitrixLandingSiteType::getExcludedHooks();
// first read all hooks in base dir
foreach (self::getClassesFromDir($classDir) as $class)
{
if (in_array($class, $excludedHooks))
{
continue;
}
$classFull = __NAMESPACE__ . $classNamespace . $class;
if (class_exists($classFull))
{
$hooks[$class] = new $classFull(
self::$editMode,
!($type == self::ENTITY_TYPE_SITE)
);
}
}
// sort hooks
uasort($hooks, function($a, $b)
{
if ($a->getSort() == $b->getSort())
{
return 0;
}
return ($a->getSort() < $b->getSort()) ? -1 : 1;
});
// check custom exec
$event = new Event('landing', 'onHookExec');
$event->send();
foreach ($event->getResults() as $result)
{
if ($result->getType() != EventResult::ERROR)
{
if ($customExec = $result->getModified())
{
foreach ((array)$customExec as $code => $itemExec)
{
$code = mb_strtoupper($code);
if (isset($hooks[$code]) && is_callable($itemExec))
{
$hooks[$code]->setCustomExec($itemExec);
}
}
unset($code, $itemExec);
}
unset($customExec);
}
}
unset($event, $result);
// then fill hook with data
if (!empty($hooks) && $id > 0)
{
if (empty($data))
{
$data = self::getData($id, $type);
}
foreach ($hooks as $code => $hook)
{
if (isset($data[$code]))
{
$hook->setData($data[$code]);
}
}
}
return $hooks;
}