예제 #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;
 }
예제 #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;
 }
예제 #3
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $this->localeResolver->resolveLocale();
     $request = $event->getRequest();
     $request->setLocale($this->localeResolver->getLocale());
 }
예제 #4
0
 /**
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $this->translator->translate($entity, $this->localeResolver->getLocale());
 }