本文整理汇总了PHP中Wire::getHooks方法的典型用法代码示例。如果您正苦于以下问题:PHP Wire::getHooks方法的具体用法?PHP Wire::getHooks怎么用?PHP Wire::getHooks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wire
的用法示例。
在下文中一共展示了Wire::getHooks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHooksInfo
/**
* Get hooks debug info for the given Wire object
*
* @param Wire $obj
* @return array
*
*/
public function getHooksInfo(Wire $obj)
{
$hooks = array();
foreach ($obj->getHooks() as $hook) {
list($class, $priority) = explode(':', $hook['id']);
$key = '';
$value = '';
if ($hook['options']['before']) {
$key .= "before ";
}
if ($hook['options']['type'] == 'property') {
$key .= "property ";
} else {
if ($hook['options']['after']) {
if (method_exists($class, $hook['method']) || method_exists($class, '___' . $hook['method'])) {
$key .= "after ";
}
}
}
if ($hook['options']['type'] == 'property' || !$hook['options']['allInstances']) {
$key .= "{$class}" . '->' . "{$hook['method']}";
} else {
$key .= "{$class}::{$hook['method']}";
}
$filename = '';
if (!empty($hook['toObject'])) {
$value .= $hook['toObject']->className() . "->";
$ref = new ReflectionClass($hook['toObject']);
$filename = $ref->getFileName();
}
if (!empty($hook['toMethod'])) {
if (is_string($hook['toMethod'])) {
$value .= "{$hook['toMethod']}()";
} else {
if (is_callable($hook['toMethod'])) {
$ref = new ReflectionFunction($hook['toMethod']);
$filename = $ref->getFileName();
$value = "anonymous function()";
}
}
}
if ($filename) {
$value .= " in " . basename($filename);
}
if (!isset($hooks[$key])) {
$hooks[$key] = $value;
} else {
if (!is_array($hooks[$key])) {
$hooks[$key] = array($hooks[$key]);
}
$hooks[$key][] = $value;
}
}
return $hooks;
}