Ejemplo n.º 1
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     $path = $request->getPathInfo();
     $translationRoute = $this->em->getRepository('EnhavoTranslationBundle:TranslationRoute')->findOneBy(['path' => $path]);
     if ($translationRoute) {
         $this->localeResolver->setLocale($translationRoute->getLocale());
     }
     return;
 }
Ejemplo n.º 2
0
 public function fetch($slug, $class)
 {
     if ($this->localeResolver->isDefaultLocale()) {
         $entity = $this->em->getRepository($class)->findOneBy(['slug' => $slug]);
         return $entity;
     }
     $translation = $this->em->getRepository('EnhavoTranslationBundle:Translation')->findOneBy(['class' => $class, 'property' => 'slug', 'translation' => $slug, 'locale' => $this->localeResolver->getLocale()]);
     if ($translation !== null) {
         $id = $translation->getRefId();
         $entity = $this->em->getRepository($class)->find($id);
         return $entity;
     }
     return null;
 }
Ejemplo n.º 3
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $this->localeResolver->resolveLocale();
     $request = $event->getRequest();
     $request->setLocale($this->localeResolver->getLocale());
 }
Ejemplo n.º 4
0
 /**
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $this->translator->translate($entity, $this->localeResolver->getLocale());
 }