setNavigation() public method

public setNavigation ( Navigation $navigation )
$navigation Navigation
Example #1
0
 /**
  * Parses the entire file and returns a webspace object.
  *
  * @param $file
  *
  * @return Webspace
  */
 protected function parseXml($file)
 {
     $this->xpath = new \DOMXPath($this->tryLoad($file));
     $this->xpath->registerNamespace('x', 'http://schemas.sulu.io/webspace/webspace');
     // set simple webspace properties
     $this->webspace = new Webspace();
     $this->webspace->setName($this->xpath->query('/x:webspace/x:name')->item(0)->nodeValue);
     $this->webspace->setKey($this->xpath->query('/x:webspace/x:key')->item(0)->nodeValue);
     $this->webspace->setTheme($this->generateTheme());
     $this->webspace->setNavigation($this->generateNavigation());
     $this->webspace->setResourceLocatorStrategy('tree_leaf_edit');
     $this->generateTemplates($this->webspace);
     $this->generateDefaultTemplates($this->webspace);
     // set security
     $this->generateSecurity();
     // set localizations on webspaces
     $this->generateWebspaceLocalizations();
     // set segments on webspaces
     $this->generateSegments();
     // set portals on webspaces
     $this->generatePortals();
     // validate the webspace, and throw exceptions if not valid
     $this->validate();
     return $this->webspace;
 }
Example #2
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));
 }
Example #3
0
 /**
  * @param $file
  *
  * @return Portal
  */
 private function parseXml($file)
 {
     // load xml file
     $xmlDoc = XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH);
     $this->xpath = new \DOMXPath($xmlDoc);
     $this->xpath->registerNamespace('x', 'http://schemas.sulu.io/webspace/webspace');
     // set simple webspace properties
     $this->webspace = new Webspace();
     $this->webspace->setName($this->xpath->query('/x:webspace/x:name')->item(0)->nodeValue);
     $this->webspace->setKey($this->xpath->query('/x:webspace/x:key')->item(0)->nodeValue);
     $this->webspace->setTheme($this->generateTheme());
     $this->webspace->setNavigation($this->generateNavigation());
     // set security
     $this->generateSecurity();
     // set localizations on webspaces
     $this->generateWebspaceLocalizations();
     // set segments on webspaces
     $this->generateSegments();
     // set portals on webspaces
     $this->generatePortals();
     // validate the webspace, and throw exceptions if not valid
     $this->validate();
     return $this->webspace;
 }
Example #4
0
 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);
 }