getStructures() public method

Return all the structures of the given type.
public getStructures ( string $type = Structure::TYPE_PAGE ) : Sulu\Component\Content\Compat\StructureInterface[]
$type string
return Sulu\Component\Content\Compat\StructureInterface[]
Exemplo n.º 1
0
 public function warmUp($cacheDir)
 {
     // warmup the pages
     $this->structureManager->getStructures(Structure::TYPE_PAGE);
     // warm up the snippets
     $this->structureManager->getStructures(Structure::TYPE_SNIPPET);
 }
Exemplo n.º 2
0
 /**
  * Returns and caches structures for given webspace.
  *
  * @param string $webspaceKey
  *
  * @return array
  */
 protected function loadStructures($webspaceKey)
 {
     $structures = [];
     $keys = [];
     foreach ($this->structureManager->getStructures() as $page) {
         /* @var PageBridge $page */
         $template = sprintf('%s.html.twig', $page->getView());
         if ($this->templateExists($template)) {
             $keys[] = $page->getKey();
             $structures[] = $page;
         }
     }
     $this->cache->save($webspaceKey, $keys);
     return $structures;
 }
Exemplo n.º 3
0
 private function loadStructures($webspaceKey)
 {
     $before = $this->activeTheme->getName();
     $webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey);
     $this->activeTheme->setName($webspace->getTheme()->getKey());
     $structures = [];
     $keys = [];
     foreach ($this->structureManager->getStructures() as $page) {
         /* @var PageBridge $page */
         $template = sprintf('%s.html.twig', $page->getView());
         if ($this->templateExists($template)) {
             $keys[] = $page->getKey();
             $structures[] = $page;
         }
     }
     $this->activeTheme->setName($before);
     $this->cache->save($webspaceKey, $keys);
     return $structures;
 }
Exemplo n.º 4
0
 /**
  * Append mapping for url to given query-builder.
  *
  * @param QueryBuilder $queryBuilder
  * @param string[] $locales
  */
 private function appendUrlMapping(QueryBuilder $queryBuilder, $locales)
 {
     $structures = $this->structureManager->getStructures(Structure::TYPE_PAGE);
     $urlNames = [];
     foreach ($structures as $structure) {
         if (!$structure->hasTag('sulu.rlp')) {
             continue;
         }
         $propertyName = $structure->getPropertyByTagName('sulu.rlp')->getName();
         if (!in_array($propertyName, $urlNames)) {
             $this->appendSingleMapping($queryBuilder, $propertyName, $locales);
             $urlNames[] = $propertyName;
         }
     }
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function fetchStructure($userId, $contentUuid, $webspaceKey, $locale)
 {
     $id = $this->getId($userId, $contentUuid, $locale);
     $classId = $this->getId($userId, $contentUuid, $locale, 'class');
     if ($this->contains($userId, $contentUuid, $webspaceKey, $locale)) {
         $class = $this->dataCache->fetch($classId);
         $data = $this->dataCache->fetch($id);
         try {
             return $this->serializer->deserialize($data, $class, $this->serializeType);
         } catch (\ReflectionException $e) {
             // load all cache classes
             $this->structureManager->getStructures();
             // try again
             return $this->serializer->deserialize($data, $class, $this->serializeType);
         }
     } else {
         return false;
     }
 }