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); }
/** * Return a response for the case where there is an referential integrity violation. * * It will return a 409 (Conflict) response with an array of structures which reference * the node and an array of "other" nodes (i.e. non-structures) which reference the node. * * @param string $webspace * @param NodeInterface[] $references * @param string $uuid * * @return Response */ private function getReferentialIntegrityResponse($webspace, $references, $uuid, $locale) { $data = ['structures' => [], 'other' => [], 'isDefault' => $this->defaultSnippetManager->isDefault($uuid)]; foreach ($references as $reference) { if ($reference->getParent()->isNodeType('sulu:page')) { $content = $this->contentMapper->load($reference->getParent()->getIdentifier(), $webspace, $locale, true); $data['structures'][] = $content->toArray(); } else { $data['other'][] = $reference->getParent()->getPath(); } } return new JsonResponse($data, 409); }
/** * 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); }