本文整理匯總了PHP中Method::setBeforeAdvices方法的典型用法代碼示例。如果您正苦於以下問題:PHP Method::setBeforeAdvices方法的具體用法?PHP Method::setBeforeAdvices怎麽用?PHP Method::setBeforeAdvices使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Method
的用法示例。
在下文中一共展示了Method::setBeforeAdvices方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadConfig
public function loadConfig(Model\Aop $aop)
{
foreach ($this->objectReflectionClass->getMethods() as $reflectionMethod) {
$annotations = $this->reader->getMethodAnnotations($reflectionMethod);
$beforeAdvices = [];
$afterAdvices = [];
$insteadAdvices = [];
$canceled = null;
$group = null;
switch (get_class($annotation)) {
case Annotation::After:
$afterAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
break;
case Annotation::Before:
$beforeAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
break;
case Annotation::Cancel:
$canceled = true;
break;
case Annotation::Group:
$group = $annotation->id;
break;
case Annotation::Instead:
$insteadAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
break;
}
$method = new Method();
if (!empty($beforeAdvices)) {
$method->setBeforeAdvices($beforeAdvices);
}
if (!empty($afterAdvices)) {
$method->setAfterAdvices($afterAdvices);
}
if (!empty($insteadAdvices)) {
$method->setInsteadAdvices($insteadAdvices);
}
if (isset($group)) {
$method->setGroup($group);
}
if (isset($canceled)) {
$method->setCanceled($canceled);
}
$aop->addMethod($method);
}
}