Exemplo n.º 1
0
 /**
  * @param City $city
  *
  * @return $this
  */
 public function updateCity($city)
 {
     $locale = $this->locale;
     $em = $this->entityManager;
     /** @var TranslationRepository $translationRepo */
     $translationRepo = $em->getRepository('Gedmo\\Translatable\\Entity\\Translation');
     $availableLocales = array_keys($this->context->getValues('language'));
     $translations = $translationRepo->findTranslations($city);
     $names = array($locale => $city->getName());
     foreach ($translations as $transLocale => $transValue) {
         $names[$transLocale] = $transValue['name'];
     }
     foreach ($availableLocales as $availableLocale) {
         if (!isset($names[$availableLocale])) {
             $names[$availableLocale] = $city->getName();
         }
     }
     $newData = array('names' => $names);
     $document = $this->cityType->getDocument($city->getId());
     $data = $document->getData();
     $newData = array_merge($data, $newData);
     $document->setData($newData);
     $this->cityType->updateDocument($document);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @param TranslatableListener                                 $translationListener
  * @param Kernel                                               $kernel
  * @param \Bigfoot\Bundle\ContextBundle\Service\ContextService $context
  *
  * @internal param array $allowedLocales
  */
 public function __construct(TranslatableListener $translationListener, Kernel $kernel, ContextService $context)
 {
     $contexts = $context->getContexts();
     $this->translationListener = $translationListener;
     $this->kernel = $kernel;
     $this->defaultBackLocale = $contexts['language_back']['default_value'];
     $this->context = $context;
     $this->allowedLocales = array_keys($context->getValues('language_back'));
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @param AuthorizationChecker $securityContext
  * @param ContextService $context
  * @param EventDispatcherInterface $eventDispatcher
  */
 public function __construct(AuthorizationChecker $securityContext, ContextService $context, EventDispatcherInterface $eventDispatcher)
 {
     $this->authorizationChecker = $securityContext;
     $this->languages = $context->getValues('language_back');
     $this->eventDispatcher = $eventDispatcher;
 }