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; }
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; }
public function updateRoute(Route $route) { if (!$route->getTypeId()) { $this->routeManager->update($route); $this->entityManager->flush(); } }
public function createRoute(Routeable $content, $staticPrefix) { $route = new Route(); $route->setStaticPrefix($staticPrefix); $route->setContent($content); $this->update($route); $content->setRoute($route); return $route; }
public function updateRoute(Route $route) { if (!$route->getTypeId()) { $content = $route->getContent(); $route->setTypeId($content->getId()); $route->setType($this->resolver->getType($content)); $route->setName(sprintf('dynamic_route_%s', $route->getId())); $this->entityManager->flush(); } }
public function update(Route $route) { $content = $route->getContent(); $route->setTypeId($content->getId()); $route->setType($this->routeContentResolver->getType($content)); $route->setName(sprintf('dynamic_route_%s', $route->getId())); }
protected function createRoute($url) { $route = new Route(); $route->setStaticPrefix($url); return $route; }