/** * @param array ein identifier array mit columnname => value der id-werte * @return string|id gibt den Identifier als Scalar Value zurück */ public static function _getIdentifierHash(array $identifiers) { if (count($identifiers) == 1) { return A::peek($identifiers); } elseif (count($identifiers) > 0) { ksort($identifiers); return implode('.', $identifiers); } else { throw new Exception('Kein Hash für leere identifiers möglich'); } }
public function findByUrl(array $queryPath, array $languages, &$matchedLocale) { $url = '/' . implode('/', $queryPath); $slug = A::peek($queryPath); $qb = $this->createQueryBuilder('node'); $qb->leftJoin('node.page', 'page'); $or = $qb->expr()->orX(); //$dql .= "WHERE node.slugFr = :slug OR node.slugDe = :slug "; foreach ($languages as $lang) { $or->add($qb->expr()->eq(sprintf('node.slug%s', ucfirst($lang)), ':slug')); } $qb->where($or); $candidates = $qb->getQuery()->setParameters(array('slug' => $slug))->getResult(); if (count($candidates) > 0) { // lets search for the full path of matching url foreach ($candidates as $node) { $path = $this->getPath($node); foreach ($languages as $locale) { if ($this->createUrl($path, $locale) === $url) { $matchedLocale = $locale; return $node; } } } } throw new RequestMatchingException('URL cannot be found in navigation: ' . $url); }