コード例 #1
0
ファイル: CmsCommandsController.php プロジェクト: dvlpp/sharp
 /**
  * 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);
 }
コード例 #2
0
ファイル: CmsController.php プロジェクト: dvlpp/sharp
 /**
  * List all entities of a given category/entity with pagination, search, and sorting.
  *
  * @param $categoryName
  * @param $entityName
  * @param Request $request
  * @return mixed
  * @throws \Dvlpp\Sharp\Exceptions\EntityConfigurationNotFoundException
  */
 public function listEntities($categoryName, $entityName, Request $request)
 {
     if ($qs = $this->restoreQuerystringForListEntities($categoryName, $entityName, $request)) {
         // We saved an old "input", which means we need to display the list
         // with some pagination, or sorting, or search config. We simply redirect
         // with the correct querystring based on old input
         return redirect()->route('cms.list', array_merge(["category" => $categoryName, "entity" => $entityName], $qs));
     } else {
         // Save input (we can use it later, see up)
         $this->saveQuerystringForListEntities($categoryName, $entityName, $request);
     }
     // Find Entity config (from sharp CMS config file)
     $entity = SharpCmsConfig::findEntity($categoryName, $entityName);
     // Instantiate the entity repository
     $repo = app($entity->repository);
     // Grab entities (input is managed there, for search, pagination, ...)
     $entitiesList = new SharpEntitiesList($entity, $repo, $request);
     // And return the View
     return view('sharp::cms.entityList', ['instances' => $entitiesList->getInstances(), 'category' => SharpCmsConfig::findCategory($categoryName), 'entity' => $entity, 'entityKey' => $entityName, 'totalCount' => $entitiesList->getCount(), 'pagination' => $entitiesList->getPagination(), 'subLists' => $entitiesList->getSublists(), 'subList' => $entitiesList->getCurrentSublistId(), 'listFilters' => ["contents" => $entitiesList->getListFilterContents(), "currents" => $entitiesList->getListFilterCurrents()], 'sortedColumn' => $entitiesList->getSortedColumn(), 'sortedDirection' => $entitiesList->getSortedDirection()]);
 }
コード例 #3
0
ファイル: CmsController.php プロジェクト: oimken/sharp
 /**
  * List all entities of a given category/entity with pagination, search, and sorting.
  *
  * @param $categoryName
  * @param $entityName
  * @return mixed
  */
 public function listEntities($categoryName, $entityName)
 {
     if (!sizeof(Input::all()) && Session::get("listViewInput_{$categoryName}_{$entityName}")) {
         // We have saved an old "input", which means we need to display the list
         // with some pagination, or sorting, or search config. We simply redirect
         // with the correct querystring based on old input
         $input = Session::get("listViewInput_{$categoryName}_{$entityName}");
         return redirect()->route('cms.list', array_merge(["category" => $categoryName, "entity" => $entityName], $input));
     } else {
         // Save input (we can use it later, see up)
         Session::flash("listViewInput_{$categoryName}_{$entityName}", Input::only('page', 'sort', 'dir', 'search', 'sub'));
     }
     // Find Entity config (from sharp CMS config file)
     $entity = SharpCmsConfig::findEntity($categoryName, $entityName);
     // Instantiate the entity repository
     $repo = App::make($entity->repository);
     // Grab entities (input is managed there, for search, pagination, ...)
     $entitiesList = new SharpEntitiesList($entity, $repo);
     // And return the View
     return view('sharp::cms.entityList', ['instances' => $entitiesList->getInstances(), 'category' => SharpCmsConfig::findCategory($categoryName), 'entity' => $entity, 'entityKey' => $entityName, 'totalCount' => $entitiesList->getCount(), 'pagination' => $entitiesList->getPagination(), 'subLists' => $entitiesList->getSublists(), 'subList' => $entitiesList->getCurrentSublistId(), 'sortedColumn' => $entitiesList->getSortedColumn(), 'sortedDirection' => $entitiesList->getSortedDirection()]);
 }