src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
public function getBestMatchForUrl($urlSlug, $locale)
    {
        $em = $this->getEntityManager();

        $rsm = new ResultSetMappingBuilder($em);
        $rsm->addRootEntityFromClassMetadata(
            'Kunstmaan\NodeBundle\Entity\NodeTranslation',
            'nt'
        );

        $query = $em
            ->createNativeQuery(
                'select nt.*
                from kuma_node_translations nt
                join kuma_nodes n on n.id = nt.node_id
                where n.deleted = 0 and nt.lang = :lang and locate(nt.url, :url) = 1
                order by length(nt.url) desc limit 1',
                $rsm
            );
        $query->setParameter('lang', $locale);
        $query->setParameter('url', $urlSlug);
        $translation = $query->getOneOrNullResult();

        return $translation;
    }
public function getBestMatchForUrl($urlSlug, $locale)
    {
        $em = $this->getEntityManager();

        $rsm = new ResultSetMappingBuilder($em);
        $rsm->addRootEntityFromClassMetadata(
            'Kunstmaan\NodeBundle\Entity\NodeTranslation',
            'nt'
        );

        $query = $em
            ->createNativeQuery(
                'select nt.*
                from kuma_node_translations nt
                join kuma_nodes n on n.id = nt.node_id
                where n.deleted = 0 and nt.lang = :lang and locate(nt.url, :url) = 1
                order by length(nt.url) desc limit 1',
                $rsm
            );
        $query->setParameter('lang', $locale);
        $query->setParameter('url', $urlSlug);
        $translation = $query->getOneOrNullResult();

        return $translation;
    }
public function getBestMatchForUrl ( $ urlSlug , $ locale ) { $ em = $ this -> getEntityManager ( ) ; $ rsm = new ResultSetMappingBuilder ( $ em ) ; $ rsm -> addRootEntityFromClassMetadata ( 'Kunstmaan\NodeBundle\Entity\NodeTranslation' , 'nt' ) ; $ query = $ em -> createNativeQuery ( 'select nt.*
                from kuma_node_translations nt
                join kuma_nodes n on n.id = nt.node_id
                where n.deleted = 0 and nt.lang = :lang and locate(nt.url, :url) = 1
                order by length(nt.url) desc limit 1' , $ rsm ) ; $ query -> setParameter ( 'lang' , $ locale ) ; $ query -> setParameter ( 'url' , $ urlSlug ) ; $ translation = $ query -> getOneOrNullResult ( ) ; return $ translation ; }
Find best match for given URL and locale

@param string $urlSlug The slug
@param string $locale  The locale

@return NodeTranslation
Find best match for given URL and locale