Inheritance: implements Sulu\Component\Util\ArrayableInterface
 /**
  * @param Webspace $webspace
  * @param Portal   $portal
  */
 public function __construct(Webspace $webspace, Portal $portal)
 {
     $this->webspace = $webspace;
     $this->portal = $portal;
     $message = 'The portal "' . $portal->getKey() . '" in the webspace definition "' . $webspace->getKey() . '" ' . 'has not specified the required attributes (a default localization)';
     parent::__construct($message, 0);
 }
 /**
  * @param Webspace $webspace
  * @param Portal   $portal
  */
 public function __construct(Webspace $webspace, Portal $portal)
 {
     $this->webspace = $webspace;
     $this->portal = $portal;
     $message = 'The portal "' . $portal->getKey() . '" in the webspace definition "' . $webspace->getKey() . '" ' . 'has multiple default localizations';
     parent::__construct($message, 0);
 }
Example #3
0
 private function initializeWebspace(OutputInterface $output, Webspace $webspace)
 {
     $homePath = $this->pathBuilder->build(['%base%', $webspace->getKey(), '%content%']);
     $routesPath = $this->pathBuilder->build(['%base%', $webspace->getKey(), '%route%']);
     $webspaceLocales = [];
     foreach ($webspace->getAllLocalizations() as $localization) {
         $webspaceLocales[] = $localization->getLocalization();
     }
     if ($this->nodeManager->has($homePath)) {
         $homeDocument = $this->documentManager->find($homePath, 'fr', ['load_ghost_content' => false, 'auto_create' => true, 'path' => $homePath]);
         $existingLocales = $this->inspector->getLocales($homeDocument);
     } else {
         $homeDocument = new HomeDocument();
         $homeDocument->setTitle('Homepage');
         $homeDocument->setStructureType($webspace->getTheme()->getDefaultTemplate('homepage'));
         $homeDocument->setWorkflowStage(WorkflowStage::PUBLISHED);
         $existingLocales = [];
     }
     foreach ($webspaceLocales as $webspaceLocale) {
         $output->writeln(sprintf('<info>Homepage</info>: %s (%s)', $homePath, $webspaceLocale));
         if (in_array($webspaceLocale, $existingLocales)) {
             continue;
         }
         $this->nodeManager->createPath($routesPath . '/' . $webspaceLocale);
         $this->documentManager->persist($homeDocument, $webspaceLocale, ['path' => $homePath]);
     }
 }
 /**
  * @param Webspace $portal
  * @param string   $urlPattern
  */
 public function __construct(Webspace $portal, $urlPattern)
 {
     $this->webspace = $portal;
     $this->urlPattern = $urlPattern;
     $message = 'The url pattern "' . $urlPattern . '" in the webspace definition "' . $portal->getKey() . '" ' . 'has not specified the required attributes (either with xml attributes or as placeholders in the pattern)';
     parent::__construct($message, 0);
 }
 public function testResolve()
 {
     $webspace = new Webspace();
     $webspace->setKey('sulu_io');
     $portal = new Portal();
     $locale = new Localization();
     $locale->setLanguage('de');
     $locale->setDefault(true);
     $portal->addLocalization($locale);
     $localization = new Localization();
     $localization->setLanguage('de');
     $localization->setCountry('at');
     $requestAnalyzer = $this->prophesize('Sulu\\Component\\Webspace\\Analyzer\\WebsiteRequestAnalyzer');
     $requestAnalyzer->getWebspace()->willReturn($webspace);
     $requestAnalyzer->getCurrentLocalization()->willReturn($localization);
     $requestAnalyzer->getPortalUrl()->willReturn('sulu.io/de');
     $requestAnalyzer->getResourceLocatorPrefix()->willReturn('/de');
     $requestAnalyzer->getResourceLocator()->willReturn('/search');
     $requestAnalyzer->getGetParameters()->willReturn(['p' => 1]);
     $requestAnalyzer->getPostParameters()->willReturn([]);
     $requestAnalyzer->getPortal()->willReturn($portal);
     $requestAnalyzer->getAnalyticsKey()->willReturn('analyticsKey');
     $result = $this->resolver->resolve($requestAnalyzer->reveal());
     $this->assertEquals(['request' => ['webspaceKey' => 'sulu_io', 'locale' => 'de_at', 'defaultLocale' => 'de', 'portalUrl' => 'sulu.io/de', 'resourceLocatorPrefix' => '/de', 'resourceLocator' => '/search', 'get' => ['p' => 1], 'post' => [], 'analyticsKey' => 'analyticsKey']], $result);
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function getUrls(Webspace $webspace, $environment)
 {
     $urls = [];
     foreach ($webspace->getPortals() as $portal) {
         $urls = array_merge($urls, $portal->getEnvironment($environment)->getUrls());
     }
     return $urls;
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function getUrls(Webspace $webspace, $environment)
 {
     $urls = [];
     foreach ($this->customUrlManager->findUrls($webspace->getKey()) as $customUrl) {
         $urls[] = new Url($customUrl, $environment);
     }
     return $urls;
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 protected function doEnhance(CustomUrlBehavior $customUrl, Webspace $webspace, array $defaults, Request $request)
 {
     $seo = ['noFollow' => $customUrl->isNoFollow(), 'noIndex' => $customUrl->isNoIndex()];
     if ($customUrl->isCanonical()) {
         $resourceSegment = $customUrl->getTargetDocument()->getResourceSegment();
         $seo['canonicalUrl'] = $this->webspaceManager->findUrlByResourceLocator($resourceSegment, $defaults['_environment'], $customUrl->getTargetLocale(), $webspace->getKey());
     }
     return ['_seo' => $seo];
 }
Example #9
0
 private function getWebspace()
 {
     $webspace = new Webspace();
     $webspace->setName('test');
     $theme = new Theme();
     $theme->setKey('default');
     $webspace->setTheme($theme);
     return $webspace;
 }
Example #10
0
 /**
  * Adds the template for the given types as described in the XML document.
  *
  * The types can be arbitrary, so that another bundle can easily add a new type and use the information from the
  * webspace.
  *
  * @param Webspace $webspace
  *
  * @return Webspace
  */
 protected function generateTemplates(Webspace $webspace)
 {
     foreach ($this->xpath->query('/x:webspace/x:templates/x:template') as $templateNode) {
         /* @var \DOMNode $templateNode */
         $template = $templateNode->nodeValue;
         $type = $templateNode->attributes->getNamedItem('type')->nodeValue;
         $webspace->addTemplate($type, $template);
     }
     return $webspace;
 }
Example #11
0
 /**
  * Upgrade a single webspace.
  *
  * @param Webspace $webspace
  */
 private function upgradeWebspace(Webspace $webspace)
 {
     $sessionManager = $this->container->get('sulu.phpcr.session');
     $node = $sessionManager->getContentNode($webspace->getKey());
     foreach ($webspace->getAllLocalizations() as $localization) {
         $locale = $localization->getLocalization();
         $propertyName = $this->getPropertyName(self::SHADOW_ON_PROPERTY, $locale);
         $this->upgradeNode($node, $propertyName, $locale);
     }
 }
 private function upgradeNode(StructureBridge $page, Webspace $webspace, Localization $localization, OutputInterface $output, $depth = 0)
 {
     /** @var SessionManagerInterface $sessionManager */
     $sessionManager = $this->getContainer()->get('sulu.phpcr.session');
     $session = $sessionManager->getSession();
     $node = $session->getNodeByIdentifier($page->getUuid());
     /** @var RlpStrategyInterface $strategy */
     $strategy = $this->getContainer()->get('sulu.content.rlp.strategy.tree');
     /** @var ResourceLocator $resourceLocator */
     $resourceLocator = $this->getContainer()->get('sulu.content.type.resource_locator');
     if (!$page->hasTag('sulu.rlp')) {
         return;
     }
     $property = $page->getPropertyByTagName('sulu.rlp');
     if ($property->getContentTypeName() !== 'resource_locator' && $page->getNodeType() !== Structure::NODE_TYPE_CONTENT) {
         return;
     }
     $transProperty = new TranslatedProperty($property, $localization->getLocalization(), $this->getContainer()->getParameter('sulu.content.language.namespace'));
     try {
         // load value
         $rl = $strategy->loadByContent($node, $webspace->getKey(), $localization->getLocalization());
         // save value
         $property->setValue($rl);
         $resourceLocator->write($node, $transProperty, 1, $webspace->getKey(), $localization->getLocalization());
         $session->save();
         $prefix = '   ';
         for ($i = 0; $i < $depth; ++$i) {
             $prefix .= '-';
         }
         $output->writeln($prefix . '> "' . $page->getPropertyValue('title') . '": ' . $rl);
     } catch (ResourceLocatorNotFoundException $ex) {
     }
 }
Example #13
0
 /**
  * Returns key of webspace.
  */
 public function getWebspaceKey()
 {
     if (null === $this->webspace) {
         return;
     }
     return $this->webspace->getKey();
 }
Example #14
0
 private function initializeWebspace(OutputInterface $output, Webspace $webspace)
 {
     $homePath = $this->pathBuilder->build(['%base%', $webspace->getKey(), '%content%']);
     $routesPath = $this->pathBuilder->build(['%base%', $webspace->getKey(), '%route%']);
     $webspaceLocales = [];
     foreach ($webspace->getAllLocalizations() as $localization) {
         $webspaceLocales[] = $localization->getLocale();
     }
     $homeType = $webspace->getDefaultTemplate('home');
     $existingLocales = [];
     $homeDocument = null;
     if ($this->nodeManager->has($homePath)) {
         $homeDocument = $this->documentManager->find($homePath, null, ['load_ghost_content' => false, 'auto_create' => true, 'path' => $homePath]);
         $existingLocales = $this->inspector->getLocales($homeDocument);
     }
     foreach ($webspaceLocales as $webspaceLocale) {
         if (in_array($webspaceLocale, $existingLocales)) {
             $output->writeln(sprintf('  [ ] <info>homepage</info>: %s (%s)', $homePath, $webspaceLocale));
             continue;
         }
         $output->writeln(sprintf('  [+] <info>homepage</info>: [%s] %s (%s)', $homeType, $homePath, $webspaceLocale));
         $persistOptions = ['ignore_required' => true];
         if (!$homeDocument) {
             $homeDocument = new HomeDocument();
             $persistOptions['path'] = $homePath;
             $persistOptions['auto_create'] = true;
         } else {
             $homeDocument = $this->documentManager->find($homePath, $webspaceLocale, ['load_ghost_content' => false]);
         }
         $homeDocument->setTitle('Homepage');
         $homeDocument->setStructureType($homeType);
         $this->documentManager->persist($homeDocument, $webspaceLocale, $persistOptions);
         $this->documentManager->publish($homeDocument, $webspaceLocale);
         $routePath = $routesPath . '/' . $webspaceLocale;
         try {
             $routeDocument = $this->documentManager->find($routePath);
         } catch (DocumentNotFoundException $e) {
             $routeDocument = $this->documentManager->create('route');
         }
         $routeDocument->setTargetDocument($homeDocument);
         $this->documentManager->persist($routeDocument, $webspaceLocale, ['path' => $routePath, 'auto_create' => true]);
         $this->documentManager->publish($routeDocument, $webspaceLocale);
     }
     $this->documentManager->flush();
 }
Example #15
0
 protected function setUp()
 {
     parent::setUp();
     $this->requestAnalyzer = $this->prophesize(RequestAnalyzerInterface::class);
     $webspace = new Webspace();
     $webspace->setKey('sulu_test');
     $locale = new Localization();
     $locale->setLanguage('en');
     $portal = new Portal();
     $portal->setDefaultLocalization($locale);
     $this->requestAnalyzer->getWebspace()->willReturn($webspace);
     $this->requestAnalyzer->getPortal()->willReturn($portal);
     $this->requestAnalyzer->getCurrentLocalization()->willReturn($locale);
     $this->contentPath = $this->prophesize(ContentPathInterface::class);
     $this->contentPath->getContentPath('/test', 'sulu_test', 'de')->willReturn('/de/test');
     $this->contentPath->getContentPath('/test-en', 'sulu_test', 'en')->willReturn('/en/test-en');
     $this->contentPath->getContentPath('/test-en-us', 'sulu_test', 'en-us')->willReturn('/en/test-en-us');
     $this->contentPath->getContentPath('/test-en-us', 'sulu_test', 'en_us')->willReturn('/en/test-en-us');
     $this->contentPath->getContentPath('/test-fr', 'sulu_test', 'fr')->willReturn('/fr/test-fr');
 }
Example #16
0
 public function testFindLocalization()
 {
     $localeDe = $this->getLocalization('de');
     $localeDeAt = $this->getLocalization('de', 'at');
     $localeDeCh = $this->getLocalization('de', 'ch');
     $localeDe->addChild($localeDeAt);
     $localeDe->addChild($localeDeCh);
     $localeEn = $this->getLocalization('en');
     $this->webspace->addLocalization($localeDe);
     $this->webspace->addLocalization($localeEn);
     $result = $this->webspace->getLocalization('de');
     $this->assertEquals('de', $result->getLocalization());
     $result = $this->webspace->getLocalization('de_at');
     $this->assertEquals('de_at', $result->getLocalization());
     $result = $this->webspace->getLocalization('de_ch');
     $this->assertEquals('de_ch', $result->getLocalization());
     $result = $this->webspace->getLocalization('en');
     $this->assertEquals('en', $result->getLocalization());
     $result = $this->webspace->getLocalization('en_us');
     $this->assertEquals(null, $result);
 }
 /**
  * It should return any localizations if neither parent nor children.
  */
 public function testWebspaceAnyLocalization()
 {
     $this->inspector->getWebspace($this->document->reveal())->willReturn(self::FIX_WEBSPACE);
     $this->inspector->getLocales($this->document->reveal())->willReturn(['de']);
     $this->webspace->getLocalization(self::FIX_LOCALE)->willReturn($this->localization1->reveal());
     $this->localization1->getLocalization()->willReturn('en');
     $this->localization2->getLocalization()->willReturn('de');
     $this->hydrateEvent->getOption('load_ghost_content', true)->willReturn(true);
     $this->localization1->getParent()->willReturn(null);
     $this->localization1->getChildren()->willReturn([]);
     $this->webspace->getLocalizations()->willReturn([$this->localization2->reveal()]);
     $this->registry->updateLocale($this->document->reveal(), 'de', 'en')->shouldBeCalled();
     $this->hydrateEvent->setLocale('de')->shouldBeCalled();
     $this->subscriber->handleHydrate($this->hydrateEvent->reveal());
 }
Example #18
0
 /**
  * Validate webspace default segment.
  *
  * @throws Exception\WebspaceDefaultSegmentNotFoundException
  * @throws Exception\InvalidWebspaceDefaultSegmentException
  */
 protected function validateWebspaceDefaultSegment()
 {
     // check if there are duplicate defaults in the webspaces segments
     $segments = $this->webspace->getSegments();
     if ($segments) {
         $webspaceDefaultSegmentFound = false;
         foreach ($segments as $webspaceSegment) {
             if ($webspaceSegment->isDefault()) {
                 // throw an exception, if a new default segment is found, although there already is one
                 if ($webspaceDefaultSegmentFound) {
                     throw new InvalidWebspaceDefaultSegmentException($this->webspace);
                 }
                 $webspaceDefaultSegmentFound = true;
             }
         }
         if (!$webspaceDefaultSegmentFound) {
             throw new WebspaceDefaultSegmentNotFoundException($this->webspace);
         }
     }
 }
Example #19
0
 protected function prepareWebspaceManager()
 {
     if ($this->webspaceManager !== null) {
         return;
     }
     $this->webspace = new Webspace();
     $this->webspace->setKey('sulu_io');
     $local1 = new Localization();
     $local1->setLanguage('en');
     $local2 = new Localization();
     $local2->setLanguage('en');
     $local2->setCountry('us');
     $this->webspace->setLocalizations([$local1, $local2]);
     $this->webspace->setName('Default');
     $theme = new Theme();
     $theme->setKey('test');
     $theme->addDefaultTemplate('page', 'default');
     $this->webspace->setTheme($theme);
     $this->webspace->setNavigation(new Navigation([new NavigationContext('main', []), new NavigationContext('footer', [])]));
     $this->webspaceManager = $this->getMock('Sulu\\Component\\Webspace\\Manager\\WebspaceManagerInterface');
     $this->webspaceManager->expects($this->any())->method('findWebspaceByKey')->will($this->returnValue($this->webspace));
 }
 /**
  * @param Webspace $webspace
  */
 public function __construct(Webspace $webspace)
 {
     $this->webspace = $webspace;
     $message = 'The webspace definition for "' . $webspace->getKey() . '" has no default localization';
     parent::__construct($message, 0);
 }
Example #21
0
 /**
  * @param Webspace $webspace
  */
 public function __construct(Webspace $webspace, $customUrl)
 {
     parent::__construct('The custom-url "' . $customUrl . '" for "' . $webspace->getKey() . '" has no placeholder');
     $this->customUrl = $customUrl;
     $this->webspace = $webspace;
 }
 /**
  * @param Webspace $webspace
  */
 public function __construct(Webspace $webspace)
 {
     parent::__construct('The webspace definition for "' . $webspace->getKey() . '" has locales which are not used in any portal');
     $this->webspace = $webspace;
 }
 public function testGetCollectionMovedResourceLocator()
 {
     // Set up test
     $path = '/qwertz/';
     $prefix = '/de';
     $uuid = 1;
     $portal = new Portal();
     $portal->setKey('portal');
     $theme = new Theme();
     $theme->setKey('theme');
     $webspace = new Webspace();
     $webspace->setTheme($theme);
     $portal->setWebspace($webspace);
     $localization = new Localization();
     $localization->setLanguage('de');
     $structure = $this->getStructureMock($uuid);
     $requestAnalyzer = $this->getRequestAnalyzerMock($portal, $path, $prefix, $localization, RequestAnalyzerInterface::MATCH_TYPE_FULL, 'sulu.lo', 'sulu.lo/en-us');
     $activeTheme = $this->getActiveThemeMock();
     $contentMapper = $this->getContentMapperMock();
     $contentMapper->expects($this->any())->method('loadByResourceLocator')->will($this->throwException(new ResourceLocatorMovedException('/new-test', '123-123-123')));
     $portalRouteProvider = new ContentRouteProvider($contentMapper, $requestAnalyzer, $activeTheme);
     $request = $this->getRequestMock($path);
     // Test the route provider
     $routes = $portalRouteProvider->getRouteCollectionForRequest($request);
     $this->assertCount(1, $routes);
     $route = $routes->getIterator()->current();
     $this->assertEquals('SuluWebsiteBundle:Default:redirect', $route->getDefaults()['_controller']);
     $this->assertEquals('/de/new-test', $route->getDefaults()['url']);
 }
 /**
  * @param Webspace $webspace
  */
 public function __construct(Webspace $webspace)
 {
     $this->webspace = $webspace;
     $message = 'The webspace definition for "' . $webspace->getKey() . '" has has multiple default segment';
     parent::__construct($message, 0);
 }
 private function upgradeNode(NodeInterface $node, Webspace $webspace, Localization $localization, OutputInterface $output, $depth = 0)
 {
     $locale = $localization->getLocale();
     $localizedTemplatePropertyName = $this->propertyEncoder->localizedSystemName('template', $locale);
     if (!$node->hasProperty($localizedTemplatePropertyName)) {
         return;
     }
     $structureMetadata = $this->structureMetadataFactory->getStructureMetadata($this->metadataFactory->getMetadataForPhpcrNode($node)->getAlias(), $node->getPropertyValue($localizedTemplatePropertyName));
     $property = $structureMetadata->getPropertyByTagName('sulu.rlp');
     if (!$property) {
         return;
     }
     $nodeType = $node->getPropertyValue($this->propertyEncoder->localizedSystemName('nodeType', $locale));
     if ($property->getContentTypeName() !== 'resource_locator' && $nodeType !== Structure::NODE_TYPE_CONTENT) {
         return;
     }
     $baseRoutePath = $this->sessionManager->getRoutePath($webspace->getKey(), $localization->getLocale());
     foreach ($node->getReferences('sulu:content') as $routeProperty) {
         if (strpos($routeProperty->getPath(), $baseRoutePath) !== 0) {
             continue;
         }
         $routeNode = $routeProperty->getParent();
         if ($routeNode->getPropertyValue('sulu:history') === true) {
             continue;
         }
         $resourceLocator = substr($routeNode->getPath(), strlen($baseRoutePath));
         if ($resourceLocator) {
             // only set if resource locator is not empty
             // if the resource locator is empty it is the homepage, whose url should not be changed
             $node->setProperty($this->propertyEncoder->localizedContentName($property->getName(), $locale), $resourceLocator);
             $prefix = '   ';
             for ($i = 0; $i < $depth; ++$i) {
                 $prefix .= '-';
             }
             $title = $node->getPropertyValue($this->propertyEncoder->localizedContentName('title', $locale));
             $output->writeln($prefix . '> "' . $title . '": ' . $resourceLocator);
         }
         break;
     }
 }
Example #26
0
 /**
  * Dump given webspace.
  *
  * @param Webspace $webspace
  */
 private function dumpWebspace(Webspace $webspace)
 {
     foreach ($webspace->getAllLocalizations() as $localization) {
         $this->output->writeln(sprintf(' - %s (%s)', $webspace->getKey(), $localization->getLocale()));
         $this->dumpPortalInformations($this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($webspace->getKey(), $localization->getLocale(), $this->environment));
     }
 }
 /**
  * @param Webspace $webspace
  */
 private function buildPortals(Webspace $webspace)
 {
     foreach ($webspace->getPortals() as $portal) {
         $this->portals[] = $portal;
         $this->buildEnvironments($portal);
     }
 }
 protected function setUp()
 {
     parent::setUp();
     $this->contentMapper = $this->prophesize('Sulu\\Component\\Content\\Mapper\\ContentMapperInterface');
     $this->requestAnalyzer = $this->prophesize('Sulu\\Component\\Webspace\\Analyzer\\RequestAnalyzerInterface');
     $this->contentTypeManager = $this->prophesize('Sulu\\Component\\Content\\ContentTypeManagerInterface');
     $this->structureManager = $this->prophesize('Sulu\\Component\\Content\\Compat\\StructureManagerInterface');
     $this->sessionManager = $this->prophesize('Sulu\\Component\\PHPCR\\SessionManager\\SessionManagerInterface');
     $this->session = $this->prophesize('PHPCR\\SessionInterface');
     $this->node = $this->prophesize('PHPCR\\NodeInterface');
     $this->parentNode = $this->prophesize('PHPCR\\NodeInterface');
     $this->startPageNode = $this->prophesize('PHPCR\\NodeInterface');
     $webspace = new Webspace();
     $webspace->setKey('sulu_test');
     $locale = new Localization();
     $locale->setCountry('us');
     $locale->setLanguage('en');
     $this->requestAnalyzer->getWebspace()->willReturn($webspace);
     $this->requestAnalyzer->getCurrentLocalization()->willReturn($locale);
     $this->contentTypeManager->get('text_line')->willReturn(new TextLine(''));
     $this->sessionManager->getSession()->willReturn($this->session->reveal());
     $this->sessionManager->getContentNode('sulu_test')->willReturn($this->startPageNode->reveal());
     $this->session->getNodeByIdentifier('123-123-123')->willReturn($this->node->reveal());
     $this->session->getNodeByIdentifier('321-321-321')->willReturn($this->parentNode->reveal());
     $this->node->getIdentifier()->willReturn('123-123-123');
     $this->node->getParent()->willReturn($this->parentNode->reveal());
     $this->node->getDepth()->willReturn(4);
     $this->parentNode->getIdentifier()->willReturn('321-321-321');
     $this->parentNode->getDepth()->willReturn(3);
     $this->startPageNode->getDepth()->willReturn(3);
     $this->structureResolver = new StructureResolver($this->contentTypeManager->reveal(), $this->structureManager->reveal());
 }
Example #29
0
 /**
  * @dataProvider provideAnalyzeWithFormat
  */
 public function testAnalyzeWithFormat($config, $expected = [])
 {
     $webspace = new Webspace();
     $webspace->setKey('sulu');
     $portal = new Portal();
     $portal->setKey('sulu');
     $localization = new Localization();
     $localization->setCountry('at');
     $localization->setLanguage('de');
     $portalInformation = new PortalInformation($config['match_type'], $webspace, $portal, $localization, $config['portal_url'], null, $config['redirect']);
     $this->prepareWebspaceManager($portalInformation);
     $requestFormat = false;
     $request = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $request->request = new ParameterBag(['post' => 1]);
     $request->query = new ParameterBag(['get' => 1]);
     $request->expects($this->any())->method('getHost')->will($this->returnValue('sulu.lo'));
     $request->expects($this->any())->method('getPathInfo')->will($this->returnValue($config['path_info']));
     $request->expects($this->once())->method('setLocale')->with('de_at');
     if ($expected['format']) {
         $request->expects($this->once())->method('setRequestFormat')->will($this->returnCallback(function ($format) use(&$requestFormat) {
             $requestFormat = $format;
         }));
     }
     $request->expects($this->once())->method('getRequestFormat')->will($this->returnCallback(function () use(&$requestFormat) {
         return $requestFormat;
     }));
     $this->requestAnalyzer->analyze($request);
     $this->assertEquals('de_at', $this->requestAnalyzer->getCurrentLocalization()->getLocalization());
     $this->assertEquals('sulu', $this->requestAnalyzer->getWebspace()->getKey());
     $this->assertEquals('sulu', $this->requestAnalyzer->getPortal()->getKey());
     $this->assertEquals(null, $this->requestAnalyzer->getSegment());
     $this->assertEquals($expected['portal_url'], $this->requestAnalyzer->getPortalUrl());
     $this->assertEquals($expected['redirect'], $this->requestAnalyzer->getRedirect());
     $this->assertEquals($expected['resource_locator'], $this->requestAnalyzer->getResourceLocator());
     $this->assertEquals($expected['resource_locator_prefix'], $this->requestAnalyzer->getResourceLocatorPrefix());
     $this->assertEquals($expected['format'], $request->getRequestFormat());
     $this->assertEquals(['post' => 1], $this->requestAnalyzer->getPostParameters());
     $this->assertEquals(['get' => 1], $this->requestAnalyzer->getGetParameters());
 }
 /**
  * Extract custom-url and add them to serialization.
  *
  * @param Webspace $webspace
  * @param Context $context
  * @param JsonSerializationVisitor $visitor
  */
 private function appendCustomUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor)
 {
     $customUrls = [];
     foreach ($webspace->getPortals() as $portal) {
         $customUrls = array_merge($customUrls, $this->getCustomUrlsForEnvironment($portal, $portal->getEnvironment($this->environment), $context));
     }
     $customUrls = $context->accept($customUrls);
     $visitor->addData('customUrls', $customUrls);
 }