Ejemplo n.º 1
0
 /**
  * @param ResourceEvent $resourceEvent
  */
 public function onSave(ResourceEvent $resourceEvent)
 {
     //        var_dump($resourceEvent);
     //        $module = $resourceEvent->getContainer()->getModule();
     $entities = $this->moduleRepository->setClass(new ResourceRepository())->findByAllResources();
     $entitiesToRemove = $this->objectManager->getRepository("BigfishCoreBundle:CacheRouting")->findAll();
     $flush = false;
     foreach ($entitiesToRemove as $remove) {
         $this->objectManager->remove($remove);
         $flush = true;
     }
     if ($flush) {
         $this->objectManager->flush();
     }
     $flush = false;
     foreach ($entities as $entity) {
         if (isset($entity["resource_id"])) {
             //
             $resource = $this->objectManager->getRepository("BigfishCoreBundle:Resource")->find($entity["resource_id"]);
             if ($resource) {
                 $routeData = $this->getParentsEntities($entities, $entity["resource_id"]);
                 $route = new CacheRouting();
                 $route->setResource($resource);
                 $route->setLanguage($this->languageManager->getObject());
                 $path = $this->validateSlug($entity["routerPath"], $routeData);
                 $route->setPath($path);
                 $this->objectManager->persist($route);
                 $flush = true;
             }
         }
     }
     if ($flush) {
         $this->objectManager->flush();
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $locale
  *
  * @return $this
  */
 public function setLanguage($locale)
 {
     $this->language = $this->languageManager->getObject($locale);
     return $this;
 }