private function getMultiSiteSettings() { $rootLocationId = $this->configResolver->getParameter('content.tree_root.location_id'); $defaultPage = $this->configResolver->getParameter('default_page'); if ($rootLocationId === null) { return array(); } $pathPrefix = trim($this->urlAliasGenerator->getPathPrefixByRootLocationId($rootLocationId), '/'); $pathPrefixExcludeItems = array_map(function ($value) { return trim($value, '/'); }, $this->configResolver->getParameter('content.tree_root.excluded_uri_prefixes')); return array('site.ini/SiteAccessSettings/PathPrefix' => $pathPrefix, 'site.ini/SiteAccessSettings/PathPrefixExclude' => $pathPrefixExcludeItems, 'logfile.ini/AccessLogFileSettings/PathPrefix' => $pathPrefix, 'site.ini/SiteSettings/IndexPage' => "/content/view/full/{$rootLocationId}/", 'site.ini/SiteSettings/DefaultPage' => $defaultPage !== null ? $defaultPage : "/content/view/full/{$rootLocationId}/", 'content.ini/NodeSettings/RootNode' => $rootLocationId); }
/** * @dataProvider providerTestDoGenerateRootLocation */ public function testDoGenerateRootLocation(URLAlias $urlAlias, $isOutsideAndNotExcluded, $expected, $pathPrefix) { $excludedPrefixes = array('/products', '/shared'); $rootLocationId = 456; $this->urlAliasGenerator->setRootLocationId($rootLocationId); $this->urlAliasGenerator->setExcludedUriPrefixes($excludedPrefixes); $location = new Location(array('id' => 123)); $rootLocation = new Location(array('id' => $rootLocationId)); $rootUrlAlias = new URLAlias(array('path' => $pathPrefix)); $this->locationService->expects($this->once())->method('loadLocation')->with($rootLocationId)->will($this->returnValue($rootLocation)); $this->urlAliasService->expects($this->once())->method('reverseLookup')->with($rootLocation)->will($this->returnValue($rootUrlAlias)); $this->urlAliasService->expects($this->once())->method('listLocationAliases')->with($location, false)->will($this->returnValue(array($urlAlias))); if ($isOutsideAndNotExcluded) { $this->logger->expects($this->once())->method('warning'); } $this->assertSame($expected, $this->urlAliasGenerator->doGenerate($location, array())); }
private function getMultiSiteSettings() { $rootLocationId = $this->configResolver->getParameter( 'content.tree_root.location_id' ); $indexPage = $this->configResolver->getParameter( 'index_page' ); $defaultPage = $this->configResolver->getParameter( 'default_page' ); if ( $rootLocationId === null ) { // return SiteSettings if there is no MultiSite (rootLocation is not defined) $result = array(); if ( $indexPage !== null ) { $result['site.ini/SiteSettings/IndexPage'] = $indexPage; } if ( $defaultPage !== null ) { $result['site.ini/SiteSettings/DefaultPage'] = $defaultPage; } return $result; } $pathPrefix = trim( $this->urlAliasGenerator->getPathPrefixByRootLocationId( $rootLocationId ), '/' ); $pathPrefixExcludeItems = array_map( function ( $value ) { return trim( $value, '/' ); }, $this->configResolver->getParameter( 'content.tree_root.excluded_uri_prefixes' ) ); return array( 'site.ini/SiteAccessSettings/PathPrefix' => $pathPrefix, 'site.ini/SiteAccessSettings/PathPrefixExclude' => $pathPrefixExcludeItems, 'logfile.ini/AccessLogFileSettings/PathPrefix' => $pathPrefix, 'site.ini/SiteSettings/IndexPage' => $indexPage !== null ? $indexPage : "/content/view/full/$rootLocationId/", 'site.ini/SiteSettings/DefaultPage' => $defaultPage !== null ? $defaultPage : "/content/view/full/$rootLocationId/", ); }
public function setContext(RequestContext $context) { $this->requestContext = $context; $this->generator->setRequestContext($context); }