Ejemplo n.º 1
0
 /**
  * Execute a functional code action and return either a view, a file or nothing.
  *
  * @param $categoryName
  * @param $entityName
  * @param $commandKey
  * @return mixed
  */
 public function entitiesListCommand($categoryName, $entityName, $commandKey, Request $request)
 {
     // Find Entity config (from sharp CMS config file)
     $entity = SharpCmsConfig::findEntity($categoryName, $entityName);
     // Have to manage access auth here, because it can be managed from the config
     $granted = SharpAccessManager::granted('entity', $entity->commands->list->{$commandKey}->auth ?: "update", $entity->key);
     if (!$granted) {
         return redirect("/");
     }
     // Instantiate the entity repository
     $repo = app($entity->repository);
     // Grab request params (input is managed there, for search, pagination, ...)
     $entitiesList = new SharpEntitiesList($entity, $repo, $request);
     $entitiesListParams = $entitiesList->createParams();
     $commandReturn = $this->commandsManager->executeEntitiesListCommand($entity, $commandKey, $entitiesListParams);
     return $this->handleCommandReturn($entity->commands->list->{$commandKey}, $commandReturn, $categoryName, $entityName, $request);
 }