Return the (DocumentManager) Metadata for the given document.
public getMetadata ( object $document ) : Sulu\Component\DocumentManager\Metadata | ||
$document | object | |
Результат | Sulu\Component\DocumentManager\Metadata |
/** * Return a structure bridge corresponding to the given document. * * @param BasePageDocument $document * * @return PageBridge */ protected function documentToStructure(BasePageDocument $document) { $structure = $this->inspector->getStructureMetadata($document); $documentAlias = $this->inspector->getMetadata($document)->getAlias(); $structureBridge = $this->structureManager->wrapStructure($documentAlias, $structure); $structureBridge->setDocument($document); return $structureBridge; }
/** * Return the default structure for the given StructureBehavior implementing document. * * @param StructureBehavior $document * * @return string */ private function getDefaultStructureType(StructureBehavior $document) { $alias = $this->inspector->getMetadata($document)->getAlias(); $webspace = $this->webspaceManager->findWebspaceByKey($this->inspector->getWebspace($document)); if (!$webspace) { return $this->getDefaultStructureTypeFromConfig($alias); } return $webspace->getDefaultTemplate($alias); }
/** * Return a structure bridge corresponding to the given document. * * @param StructureBehavior $document * * @return StructureBridge * * @deprecated */ private function documentToStructure(StructureBehavior $document) { if (null === $document) { return; } $structure = $this->documentInspector->getStructureMetadata($document); $documentAlias = $this->documentInspector->getMetadata($document)->getAlias(); $structureBridge = $this->structureManager->wrapStructure($documentAlias, $structure); $structureBridge->setDocument($document); return $structureBridge; }
/** * Invalidates the structure of the given document. * * @param $document */ private function invalidateDocumentStructure($document) { $structureBridge = $this->structureManager->wrapStructure($this->documentInspector->getMetadata($document)->getAlias(), $this->documentInspector->getStructureMetadata($document)); $structureBridge->setDocument($document); $this->structureHandler->invalidateStructure($structureBridge); }
/** * Finds the correct route for the current request. * It loads the correct data with the content mapper. * * @param Request $request A request against which to match * * @return \Symfony\Component\Routing\RouteCollection with all Routes that * could potentially match $request. Empty collection if nothing can * match */ public function getRouteCollectionForRequest(Request $request) { $collection = new RouteCollection(); // no portal information without localization supported if ($this->requestAnalyzer->getCurrentLocalization() === null && $this->requestAnalyzer->getMatchType() !== RequestAnalyzerInterface::MATCH_TYPE_PARTIAL && $this->requestAnalyzer->getMatchType() !== RequestAnalyzerInterface::MATCH_TYPE_REDIRECT) { return $collection; } $htmlExtension = '.html'; $resourceLocator = $this->requestAnalyzer->getResourceLocator(); if ($this->requestAnalyzer->getMatchType() == RequestAnalyzerInterface::MATCH_TYPE_REDIRECT || $this->requestAnalyzer->getMatchType() == RequestAnalyzerInterface::MATCH_TYPE_PARTIAL) { // redirect webspace correctly with locale $collection->add('redirect_' . uniqid(), $this->getRedirectWebSpaceRoute()); } elseif ($request->getRequestFormat() === 'html' && substr($request->getPathInfo(), -strlen($htmlExtension)) === $htmlExtension) { // redirect *.html to * (without url) $collection->add('redirect_' . uniqid(), $this->getRedirectRoute($request, $this->getUrlWithoutEndingTrailingSlash($resourceLocator))); } else { // just show the page $portal = $this->requestAnalyzer->getPortal(); $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization(); $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($portal->getWebspace()->getKey()); try { // load content by url ignore ending trailing slash /** @var PageDocument $document */ $document = $this->documentManager->find($resourceLocatorStrategy->loadByResourceLocator(rtrim($resourceLocator, '/'), $portal->getWebspace()->getKey(), $locale), $locale, ['load_ghost_content' => false]); if (!$document->getTitle()) { // If the title is empty the document does not exist in this locale // Necessary because of https://github.com/sulu/sulu/issues/2724, otherwise locale could be checked return $collection; } if (preg_match('/\\/$/', $resourceLocator) && $this->requestAnalyzer->getResourceLocatorPrefix()) { // redirect page to page without slash at the end $collection->add('redirect_' . uniqid(), $this->getRedirectRoute($request, $this->requestAnalyzer->getResourceLocatorPrefix() . rtrim($resourceLocator, '/'))); } elseif ($document->getRedirectType() === RedirectType::INTERNAL) { // redirect internal link $redirectUrl = $this->requestAnalyzer->getResourceLocatorPrefix() . $document->getRedirectTarget()->getResourceSegment(); if ($request->getQueryString()) { $redirectUrl .= '?' . $request->getQueryString(); } $collection->add($document->getStructureType() . '_' . $document->getUuid(), $this->getRedirectRoute($request, $redirectUrl)); } elseif ($document->getRedirectType() === RedirectType::EXTERNAL) { $collection->add($document->getStructureType() . '_' . $document->getUuid(), $this->getRedirectRoute($request, $document->getRedirectExternal())); } elseif (!$this->checkResourceLocator()) { return $collection; } else { // convert the page to a StructureBridge because of BC /** @var PageBridge $structure */ $structure = $this->structureManager->wrapStructure($this->documentInspector->getMetadata($document)->getAlias(), $this->documentInspector->getStructureMetadata($document)); $structure->setDocument($document); // show the page $collection->add($document->getStructureType() . '_' . $document->getUuid(), $this->getStructureRoute($request, $structure)); } } catch (ResourceLocatorNotFoundException $exc) { // just do not add any routes to the collection } catch (ResourceLocatorMovedException $exc) { // old url resource was moved $collection->add($exc->getNewResourceLocatorUuid() . '_' . uniqid(), $this->getRedirectRoute($request, $this->requestAnalyzer->getResourceLocatorPrefix() . $exc->getNewResourceLocator())); } catch (RepositoryException $exc) { // just do not add any routes to the collection } } return $collection; }