resolve() public method

Load snippet and resolves them by UUID.
public resolve ( string[] $uuids, string $webspaceKey, string $locale, string $shadowLocale = null ) : array
$uuids string[]
$webspaceKey string
$locale string
$shadowLocale string
return array
Ejemplo n.º 1
0
 public function getDefault($snippetType, $webspaceKey = null, $locale = null)
 {
     if (!$webspaceKey) {
         $webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
     }
     if (!$locale) {
         $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization();
     }
     $ids = [$this->defaultSnippetManager->loadIdentifier($webspaceKey, $snippetType)];
     // to filter null default snippet
     $ids = array_filter($ids);
     return $this->snippetResolver->resolve($ids, $webspaceKey, $locale);
 }
Ejemplo n.º 2
0
 /**
  * Returns snippets with given property value.
  */
 private function getSnippets(PropertyInterface $property)
 {
     /** @var PageBridge $page */
     $page = $property->getStructure();
     $webspaceKey = $page->getWebspaceKey();
     $locale = $page->getLanguageCode();
     $shadowLocale = null;
     if ($page->getIsShadow()) {
         $shadowLocale = $page->getShadowBaseLanguage();
     }
     $refs = $property->getValue();
     $ids = $this->getUuids($refs);
     $snippetType = $this->getParameterValue($property->getParams(), 'snippetType');
     $default = $this->getParameterValue($property->getParams(), 'default', false);
     if (empty($ids) && $snippetType && $default && $this->defaultEnabled) {
         $ids = [$this->defaultSnippetManager->loadIdentifier($webspaceKey, $snippetType)];
         // to filter null default snippet
         $ids = array_filter($ids);
     }
     return $this->snippetResolver->resolve($ids, $webspaceKey, $locale, $shadowLocale);
 }