Beispiel #1
0
 /**
  * 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();
     }
 }
Beispiel #2
0
 /**
  * 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');
 }
Beispiel #3
0
 /**
  * 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;
 }