Returns the children of the localization.
public getChildren ( ) : |
||
리턴 |
/** * 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()); }
/** * Finds the next available child-localization in which the node has a translation. * * @param string[] $availableLocales * @param Localization $localization The localization to start the search for * * @return null|Localization */ private function findAvailableChildLocalization(array $availableLocales, Localization $localization) { $childrenLocalizations = $localization->getChildren(); if (!empty($childrenLocalizations)) { foreach ($childrenLocalizations as $childrenLocalization) { // return the localization if a translation exists in the child localization if (in_array($childrenLocalization->getLocale(), $availableLocales)) { return $childrenLocalization; } // recursively call this function for checking children return $this->findAvailableChildLocalization($availableLocales, $childrenLocalization); } } // return null if nothing was found return; }