本文整理匯總了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;
}