Devise\Pages\PagesRepository::getRouteList PHP Method

getRouteList() public method

Get the route list for all the non admin pages
public getRouteList ( ) : Collection
return Collection
    public function getRouteList()
    {
        $primaryLanguageId = $this->Config->get('devise.languages.primary_language_id');
        $routes = $this->Page->where('dvs_admin', '<>', 1)->where('language_id', $primaryLanguageId)->orderBy('slug')->get();
        $list = array();
        $slugName = null;
        foreach ($routes as $route) {
            $arr = explode('/', $route->slug);
            array_pop($arr);
            $routeName = implode(' ', $arr);
            if ($routeName != $slugName && $routeName != '') {
                $slugName = ucwords($routeName);
                $list[$slugName][$route->route_name] = $route->title;
            } else {
                $list[$route->route_name] = $route->title;
            }
        }
        return $list;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Creates a json object that we use for editing a
  * devise page
  *
  * @return string
  */
 public function toJSON()
 {
     // Occurs when there are no data-devise tags on the page
     if (!$this->initialized) {
         $data = new \StdClass();
         $data->database = new \StdClass();
         $data->nodes = [];
         $data->csrfToken = $this->csrfToken;
         return $this->jsonEncode($data);
     }
     $pageVersionId = $this->pageVersionId;
     $pageId = $this->pageId;
     $languageId = $this->languageId;
     $csrfToken = $this->csrfToken;
     $route = Route::getCurrentRoute();
     $params = $route ? $route->parameters() : [];
     $availableLanguages = $this->PagesRepository->availableLanguagesForPage($pageId, $params);
     $pageRoutes = $this->PagesRepository->getRouteList();
     $pageVersions = $this->PagesRepository->getPageVersions($pageId, $pageVersionId);
     $collections = $this->filterTags('collection');
     $fields = $this->filterTags('field');
     $models = $this->filterTags('model');
     $attributes = $this->filterTags('attribute');
     $creators = $this->filterTags('creator');
     $nodes = $this->buildNodes($collections, $fields, $models, $attributes, $creators);
     $database = $this->database;
     return $this->jsonEncode(compact('nodes', 'pageId', 'pageVersionId', 'languageId', 'csrfToken', 'availableLanguages', 'pageRoutes', 'pageVersions', 'database'));
 }