/** * Create a simple associative array with a UrlAlias. * * @param RZ\Roadiz\Core\Entities\UrlAlias $urlAlias * * @return array */ public static function toArray($urlAlias) { $data = []; $data['alias'] = $urlAlias->getAlias(); return $data; }
/** * @param RZ\Roadiz\Core\Entities\UrlAlias $urlAlias * @param AuthorizationChecker|null $authorizationChecker When not null, only PUBLISHED node * will be request or with a lower status * * @return RZ\Roadiz\Core\Entities\Node|null */ public function findOneWithUrlAlias($urlAlias, AuthorizationChecker $authorizationChecker = null) { $txtQuery = 'SELECT n, ns, t FROM RZ\\Roadiz\\Core\\Entities\\Node n INNER JOIN n.nodeSources ns INNER JOIN ns.urlAliases uas INNER JOIN ns.translation t WHERE uas.id = :urlalias_id'; $this->alterQueryWithAuthorizationChecker($txtQuery, $authorizationChecker); $query = $this->_em->createQuery($txtQuery)->setParameter('urlalias_id', (int) $urlAlias->getId()); if (null !== $authorizationChecker) { $query->setParameter('status', Node::PUBLISHED); } try { return $query->getSingleResult(); } catch (\Doctrine\ORM\NoResultException $e) { return null; } }