예제 #1
0
 public function generate(Routeable $routeable, $locale = null)
 {
     $properties = $this->routeGuesser->getContextProperties($routeable);
     foreach ($properties as $property) {
         $translation = $this->translator->getTranslation($routeable, $property, $locale);
         if (!empty($translation)) {
             return $this->slugifiy($translation);
         }
     }
     return $this->routeGuesser->guessUrl($routeable);
 }
예제 #2
0
 /**
  * Pass the image URL to the view
  *
  * @param FormView $view
  * @param FormInterface $form
  * @param array $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['translation'] = isset($options['translation']) && $options['translation'] === true;
     $view->vars['currentLocale'] = $this->defaultLocale;
     if ($view->vars['translation']) {
         $parent = $form->getParent();
         if ($parent instanceof Form) {
             $property = new Property($form->getPropertyPath());
             $entity = $parent->getConfig()->getDataClass();
             if (is_object($parent->getData())) {
                 $entity = $parent->getData();
             }
             $translations = $this->translator->getTranslations($entity, $property);
             if ($translations === null) {
                 $view->vars['translation'] = false;
                 return;
             }
             $view->vars['translations'] = $translations;
         }
     }
 }
예제 #3
0
 public function postSave()
 {
     $this->translator->updateReferences();
 }
예제 #4
0
 /**
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $this->translator->translate($entity, $this->localeResolver->getLocale());
 }