/** * Parse URL searching nodeName. * * Cannot use securityAuthorizationChecker here as firewall * has not been hit yet. * * @param array &$tokens * @param Translation $translation * * @return RZ\Roadiz\Core\Entities\Node */ protected function parseNode(array &$tokens, Translation $translation) { if (!empty($tokens[0])) { /* * If the only url token is for language, return Home page */ if (in_array($tokens[0], Translation::getAvailableLocales()) && count($tokens) == 1) { if ($this->theme->getHomeNode() !== null) { $node = $this->theme->getHomeNode(); if ($translation !== null) { return $this->repository->findWithTranslation($node->getId(), $translation); } else { return $this->repository->findWithDefaultTranslation($node->getId()); } } return $this->repository->findHomeWithTranslation($translation); } else { $identifier = strip_tags($tokens[(int) (count($tokens) - 1)]); if ($identifier !== null && $identifier != '') { return $this->repository->findByNodeNameWithTranslation($identifier, $translation); } } } return null; }
/** * Parse URL searching nodeName. * * Cannot use securityAuthorizationChecker here as firewall * has not been hit yet. * * @param array &$tokens * @param Translation $translation * * @return RZ\Roadiz\Core\Entities\Node */ protected function parseNode(array &$tokens, Translation $translation) { if (!empty($tokens[0])) { /* * If the only url token is not for language */ if (count($tokens) > 1 || !in_array($tokens[0], Translation::getAvailableLocales())) { $identifier = strip_tags($tokens[(int) (count($tokens) - 1)]); if ($identifier !== null && $identifier != '') { return $this->repository->findByNodeNameWithTranslation($identifier, $translation); } } } return null; }