getPortalInformations() public method

Returns the portal informations managed by this WebspaceManger.
public getPortalInformations ( string $environment ) : PortalInformation[]
$environment string
return Sulu\Component\Webspace\PortalInformation[]
コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function resolveForPreview($webspaceKey, $locale)
 {
     // take first portal url
     $portalInformation = $this->webspaceManager->getPortalInformations($this->environment);
     $portalUrl = array_keys($portalInformation)[0];
     return ['request' => ['webspaceKey' => $webspaceKey, 'locale' => $locale, 'defaultLocale' => $locale, 'portalUrl' => $portalUrl, 'resourceLocatorPrefix' => '', 'resourceLocator' => '', 'get' => $this->requestStack->getCurrentRequest()->query->all(), 'post' => $this->requestStack->getCurrentRequest()->request->all(), 'analyticsKey' => $this->previewDefaults['analyticsKey']]];
 }
コード例 #2
0
ファイル: PortalLoaderTest.php プロジェクト: Silwereth/sulu
 public function testLoad()
 {
     $importedRouteCollection = new RouteCollection();
     $importedRouteCollection->add('route1', new Route('/example/route1'));
     $importedRouteCollection->add('route2', new Route('/route2'));
     $portal1 = new Portal();
     $portal1->setKey('sulu_lo');
     $portal2 = new Portal();
     $portal2->setKey('sulu_com');
     $portalInformations = [new PortalInformation(null, null, $portal1, null, 'sulu.io/de'), new PortalInformation(null, null, $portal2, null, 'sulu.com')];
     $this->loaderResolver->resolve(Argument::any(), Argument::any())->willReturn($this->loader->reveal());
     $this->loader->load(Argument::any(), Argument::any())->willReturn($importedRouteCollection);
     $this->webspaceManager->getPortalInformations(Argument::any())->willReturn($portalInformations);
     $routeCollection = $this->portalLoader->load('', 'portal');
     $this->assertCount(4, $routeCollection);
     $routes = $routeCollection->getIterator();
     $this->assertArrayHasKey('sulu.io/de.route1', $routes);
     $this->assertArrayHasKey('sulu.io/de.route2', $routes);
     $this->assertArrayHasKey('sulu.com.route1', $routes);
     $this->assertArrayHasKey('sulu.com.route2', $routes);
     $this->assertEquals('/de/example/route1', $routeCollection->get('sulu.io/de.route1')->getPath());
     $this->assertEquals('/de/route2', $routeCollection->get('sulu.io/de.route2')->getPath());
     $this->assertEquals('/example/route1', $routeCollection->get('sulu.com.route1')->getPath());
     $this->assertEquals('/route2', $routeCollection->get('sulu.com.route2')->getPath());
 }
コード例 #3
0
ファイル: PortalLoader.php プロジェクト: ollietb/sulu
 /**
  * @param $importedRoute
  * @param $importedRouteName
  */
 private function generatePortalRoutes(Route $importedRoute, $importedRouteName)
 {
     foreach ($this->webspaceManager->getPortalInformations($this->environment) as $portalInformation) {
         $route = clone $importedRoute;
         $route->setHost($portalInformation->getHost());
         $route->setPath($portalInformation->getPrefix() . $route->getPath());
         $this->collection->add($portalInformation->getUrl() . '.' . $importedRouteName, $route);
     }
 }
コード例 #4
0
 public function testResolveForPreviewWithRequestParameter()
 {
     $this->webspaceManager->getPortalInformations('dev')->willReturn(['sulu.io/de' => []]);
     $request = new \Symfony\Component\HttpFoundation\Request(['test' => 1], ['test' => 2]);
     $this->requestStack->getCurrentRequest()->willReturn($request);
     $result = $this->resolver->resolveForPreview('sulu_io', 'de');
     $this->assertEquals(['request' => ['webspaceKey' => 'sulu_io', 'locale' => 'de', 'defaultLocale' => 'de', 'portalUrl' => 'sulu.io/de', 'resourceLocatorPrefix' => '', 'resourceLocator' => '', 'get' => ['test' => 1], 'post' => ['test' => 2], 'analyticsKey' => 'UA-SULU-Test']], $result);
 }
コード例 #5
0
ファイル: WebsiteRequestProcessor.php プロジェクト: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public function process(Request $request, RequestAttributes $requestAttributes)
 {
     $host = $request->getHttpHost();
     $url = $host . $request->getPathInfo();
     foreach ($this->webspaceManager->getPortalInformations($this->environment) as $portalInformation) {
         $portalUrl = $this->replacer->replaceHost($portalInformation->getUrl(), $host);
         $portalInformation->setUrl($portalUrl);
         $portalRedirect = $this->replacer->replaceHost($portalInformation->getRedirect(), $host);
         $portalInformation->setRedirect($portalRedirect);
     }
     $portalInformations = $this->webspaceManager->findPortalInformationsByUrl($url, $this->environment);
     if (count($portalInformations) === 0) {
         return new RequestAttributes();
     }
     usort($portalInformations, function (PortalInformation $a, PortalInformation $b) {
         if ($a->getPriority() === $b->getPriority()) {
             return strlen($a->getUrl()) < strlen($b->getUrl());
         }
         return $a->getPriority() < $b->getPriority();
     });
     /** @var PortalInformation $portalInformation */
     $portalInformation = reset($portalInformations);
     return new RequestAttributes(['portalInformation' => $portalInformation]);
 }
コード例 #6
0
 /**
  * @return array
  */
 protected function getUrls()
 {
     $request = $this->requestStack->getCurrentRequest();
     $urls = [];
     if ($request->get('_route')) {
         $portalInformations = $this->webspaceManager->getPortalInformations($this->environment);
         $routeParams = $request->get('_route_params');
         $routeName = $request->get('_route');
         foreach ($portalInformations as $portalInformation) {
             if ($portalInformation->getPortalKey() === $this->requestAnalyzer->getPortal()->getKey() && $portalInformation->getType() === RequestAnalyzerInterface::MATCH_TYPE_FULL) {
                 if (isset($routeParams['prefix'])) {
                     $routeParams['prefix'] = $portalInformation->getPrefix();
                 }
                 $url = $this->router->generate($routeName, $routeParams, true);
                 $urls[$portalInformation->getLocale()] = $url;
             }
         }
     }
     return $urls;
 }
コード例 #7
0
 public function testResolveForPreview()
 {
     $this->webspaceManager->getPortalInformations('dev')->willReturn(['sulu.io/de' => []]);
     $result = $this->resolver->resolveForPreview('sulu_io', 'de');
     $this->assertEquals(['request' => ['webspaceKey' => 'sulu_io', 'locale' => 'de', 'defaultLocale' => 'de', 'portalUrl' => 'sulu.io/de', 'resourceLocatorPrefix' => '', 'resourceLocator' => '', 'get' => [], 'post' => [], 'analyticsKey' => 'UA-SULU-Test']], $result);
 }