本文整理汇总了PHP中Nette\Application\UI\PresenterComponentReflection::parseAnnotation方法的典型用法代码示例。如果您正苦于以下问题:PHP PresenterComponentReflection::parseAnnotation方法的具体用法?PHP PresenterComponentReflection::parseAnnotation怎么用?PHP PresenterComponentReflection::parseAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\PresenterComponentReflection
的用法示例。
在下文中一共展示了PresenterComponentReflection::parseAnnotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkRequirements
/**
* This allows me to implement a basic access control for presenters.
*
* This method is called for every presenter run,
* once it's created before the presenter startup,
* and for every other lifecycle methods, like render, action and signals.
*/
public function checkRequirements($element)
{
$user = PresenterComponentReflection::parseAnnotation($element, 'User');
if ($user === FALSE) {
return;
// not protected
}
if (!$this->getUser()->isLoggedIn()) {
$this->forbiddenAccess();
}
}
示例2: getPersistentComponents
/**
* Returns array of persistent components.
* This default implementation detects components by class-level annotation @persistent(cmp1, cmp2).
* @return array
*/
public static function getPersistentComponents()
{
return (array) PresenterComponentReflection::parseAnnotation(new \ReflectionClass(get_called_class()), 'persistent');
}
示例3: getPersistentParams
/**
* Returns array of classes persistent parameters. They have public visibility and are non-static.
* This default implementation detects persistent parameters by annotation @persistent.
* @return array
*/
public static function getPersistentParams()
{
$rc = new \ReflectionClass(get_called_class());
$params = array();
foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC) as $rp) {
if (!$rp->isStatic() && PresenterComponentReflection::parseAnnotation($rp, 'persistent')) {
$params[] = $rp->getName();
}
}
return $params;
}