getLocalization() public method

Returns the localization object for a given localization string.
public getLocalization ( string $localization ) : Localization | null
$localization string
return Sulu\Component\Localization\Localization | null
Exemplo n.º 1
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());
 }
Exemplo n.º 3
0
 /**
  * set localization for current request.
  *
  * @param string $locale
  */
 public function setLocalizationCode($locale)
 {
     $this->localization = $this->webspace->getLocalization($locale);
 }