protected function storeValues(array $values, $entity, Property $property, Metadata $metadata)
 {
     $return = null;
     if (!$entity instanceof Route) {
         return null;
     }
     foreach ($values as $locale => $value) {
         if ($this->defaultLocale === $locale) {
             $return = $value;
         } else {
             $translationRoute = $this->getRepository('EnhavoTranslationBundle:TranslationRoute')->findOneBy(['type' => $entity->getType(), 'typeId' => $entity->getTypeId()]);
             if ($translationRoute === null || $entity->getType() === null || $entity->getTypeId() === null) {
                 $route = new Route();
                 $route->setContent($entity->getContent());
                 $translationRoute = new TranslationRoute();
                 $translationRoute->setLocale($locale);
                 $translationRoute->setRoute($route);
                 $this->updateRefIds[] = $translationRoute;
             }
             /** @var Route $route */
             $route = $translationRoute->getRoute();
             $route->setStaticPrefix($value);
             $translationRoute->setPath($value);
         }
     }
     return $return;
 }
示例#2
0
 public function updateTranslationRoute(Routeable $routeable, $locale, $staticPrefix)
 {
     $route = $routeable->getRoute();
     $return = null;
     if (!$route instanceof Route) {
         return null;
     }
     $translationRoute = $this->em->getRepository('EnhavoTranslationBundle:TranslationRoute')->findOneBy(['type' => $route->getType(), 'typeId' => $route->getTypeId(), 'locale' => $locale]);
     if ($translationRoute === null) {
         $route = new Route();
         $route->setContent($routeable);
         $translationRoute = new TranslationRoute();
         $translationRoute->setLocale($locale);
         $translationRoute->setRoute($route);
         $this->em->persist($translationRoute);
     }
     /** @var Route $route */
     $route = $translationRoute->getRoute();
     $route->setStaticPrefix($staticPrefix);
     $translationRoute->setPath($staticPrefix);
     $this->em->flush();
     $this->routeManager->update($route);
     $translationRoute->setType($route->getType());
     $translationRoute->setTypeId($route->getTypeId());
     $this->em->flush();
     return $translationRoute;
 }
示例#3
0
 public function createRoute(Routeable $content, $staticPrefix)
 {
     $route = new Route();
     $route->setStaticPrefix($staticPrefix);
     $route->setContent($content);
     $this->update($route);
     $content->setRoute($route);
     return $route;
 }