How to combine translatable and sluggable from DoctrineExtensions?

I installed https://github.com/stof/StofDoctrineExtensionsBundle and used both Translitable and Sluggable in a specific field in the Country entity:

...
class Country
{
    ...
    /**
     * @Gedmo\Translatable
     * @Gedmo\Slug(fields={"name"})
     * @ORM\Column(length=255, nullable=false)
     */
    private $slug;

The page URL should be ... / country / france for English users and ... / land / frankreich for German users.

In the controller, I get slug in a specific language and is filtered using this local specific slug. I want to get a country object.

I did not find anything here or in the docs on how to do this.

Thanks for any hint on how to solve this!

+5
source share
1 answer

. ORM TranslationWalker, , . !

:

...
->createQuery('SELECT...FROM MyFooBundle:Country c WHERE c.slug = :slug...)
->setParameter('slug', $slug)
->setHint(
    \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
    'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
)
->getSingleResult();

: (.. , / ), gedmo.listener.translatable setTranslationFallback ( doctrine_extensions.yml).

+3

All Articles