Ejemplo n.º 1
0
 /**
  * Builds a controller from a class name without building its actions
  * 
  * @param string $className
  * @return array
  */
 public function buildBaseController($className)
 {
     if (is_object($className)) {
         $className = get_class($className);
     }
     $annotations = $this->parseAnnotations($className);
     $class = new ReflectionClass($className);
     $controller = new ControllerDefinition();
     $controller->setClassName($className);
     // searches for the Controller annotation
     $annos = $annotations->getClassAnnotations(array(function ($a) {
         return $a instanceof \Nucleus\IService\Dashboard\Controller;
     }));
     if (!empty($annos)) {
         $anno = $annos[0];
         if ($anno->name) {
             $controller->setName($anno->name);
         }
         if ($anno->menu !== null) {
             $controller->setMenu($anno->menu);
         }
     }
     return array($controller, $annotations);
 }
Ejemplo n.º 2
0
 /**
  * Returns the schema for model actions
  *
  * @param ControllerDefinition $controller
  * @param ActionDefinition $action
  * @param ModelDefinition $model
  */
 public function getActionActionsSchema(ControllerDefinition $controller, ActionDefinition $action, ModelDefinition $model)
 {
     $self = $this;
     $controllerActions = $controller->getActionsForModel($model->getClassName());
     $modelActions = array();
     foreach ($model->getActions() as $a) {
         if ($a->isAppliedToModel()) {
             $modelActions[] = $a;
         } else {
             $controllerActions[] = $a;
         }
     }
     return array_merge(array_values(array_filter(array_map(function ($modelAction) use($controller, $action, $self) {
         if (!$self->accessControl->checkPermissions($modelAction->getPermissions())) {
             return false;
         }
         return array_merge($self->getLimitedActionSchema($modelAction), array('behaviors' => $self->getBehaviorsSchema($controller, $modelAction), 'name' => $action->getName() . '/' . $modelAction->getName(), 'controller' => $controller->getName(), 'url' => $self->routing->generate('dashboard.invokeModel', array('controllerName' => $controller->getName(), 'actionName' => $action->getName(), 'modelActionName' => $modelAction->getName()))));
     }, $modelActions))), array_values(array_filter(array_map(function ($action) use($controller, $self) {
         if (!$self->accessControl->checkPermissions($action->getPermissions())) {
             return false;
         }
         return array_merge($self->getLimitedActionSchema($action), array('behaviors' => $self->getBehaviorsSchema($controller, $action), 'controller' => $controller->getName(), 'url' => $self->routing->generate('dashboard.invoke', array('controllerName' => $controller->getName(), 'actionName' => $action->getName()))));
     }, $controllerActions))));
 }