Adds a portal to the webspace.
public addPortal ( |
||
$portal |
/** * Generate all the portals for the webspace. */ protected function generatePortals() { foreach ($this->xpath->query('/x:webspace/x:portals/x:portal') as $portalNode) { /** @var \DOMNode $portalNode */ $portal = new Portal(); $portal->setName($this->xpath->query('x:name', $portalNode)->item(0)->nodeValue); $portal->setKey($this->xpath->query('x:key', $portalNode)->item(0)->nodeValue); // set localization on portal $this->generatePortalLocalizations($portalNode, $portal); $this->webspace->addPortal($portal); $portal->setWebspace($this->webspace); // set environments $this->generateEnvironments($portalNode, $portal); } }
public function setUp() { $webspaces = []; $portals = []; $portalInformations = ['prod' => [], 'dev' => []]; $this->webspaceCollection = new WebspaceCollection(); // first portal $portal = new Portal(); $portal->setName('Portal1'); $portal->setKey('portal1'); $theme = new Theme(); $theme->setKey('portal1theme'); $environment = new Environment(); $url = new Url(); $url->setUrl('www.portal1.com'); $url->setLanguage('en'); $url->setCountry('us'); $environment->addUrl($url); $environment->setType('prod'); $url = new Url(); $url->setUrl('portal1.com'); $url->setRedirect('www.portal1.com'); $environment->addUrl($url); $portal->addEnvironment($environment); $localizationEnUs = new Localization(); $localizationEnUs->setCountry('us'); $localizationEnUs->setLanguage('en'); $localizationEnUs->setShadow('auto'); $localizationEnUs->setDefault(true); $localizationEnCa = new Localization(); $localizationEnCa->setCountry('ca'); $localizationEnCa->setLanguage('en'); $localizationEnCa->setDefault(false); $localizationEnUs->addChild($localizationEnCa); $localizationFrCa = new Localization(); $localizationFrCa->setCountry('ca'); $localizationFrCa->setLanguage('fr'); $localizationFrCa->setDefault(false); $portal->addLocalization($localizationEnUs); $portal->addLocalization($localizationEnCa); $portal->addLocalization($localizationFrCa); $portal->setDefaultLocalization($localizationEnUs); $portal->setResourceLocatorStrategy('tree'); $webspace = new Webspace(); $webspace->addLocalization($localizationEnUs); $webspace->addLocalization($localizationFrCa); $segmentSummer = new Segment(); $segmentSummer->setName('Summer'); $segmentSummer->setKey('s'); $segmentSummer->setDefault(true); $segmentWinter = new Segment(); $segmentWinter->setName('Winter'); $segmentWinter->setKey('w'); $segmentWinter->setDefault(false); $webspace->addSegment($segmentSummer); $webspace->addSegment($segmentWinter); $webspace->setTheme($theme); $webspace->addPortal($portal); $webspace->setKey('default'); $webspace->setName('Default'); $webspace->addPortal($portal); $webspace->setNavigation(new Navigation([new NavigationContext('main', [])])); $portals[] = $portal; $webspaces[] = $webspace; $portalInformations['prod']['www.portal1.com'] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_FULL, $webspace, $portal, $localizationEnUs, 'www.portal1.com', $segmentSummer); $portalInformations['dev']['portal1.lo'] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_FULL, $webspace, $portal, $localizationEnUs, 'portal1.lo', $segmentSummer); $this->webspaceCollection->setWebspaces($webspaces); $this->webspaceCollection->setPortals($portals); $this->webspaceCollection->setPortalInformations($portalInformations); }