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); }
/** * 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); }