Ejemplo n.º 1
0
 /**
  * Put a content in a region of home page as left, right, footer or header, this is useful for menus.
  *
  * @return string The word "true" useful in ajax
  */
 public function contentToRegion($region, $content)
 {
     $regions = $this->contentRegion->findBy(['content' => $content]);
     if (count($regions) === 1 && $regions[0]->getRegion()->getName() === $region->getName()) {
         $this->deleteRegions($content, $regions);
     } else {
         $this->deleteRegions($content, $regions);
         $first = $this->contentRegion->findOneBy(['back' => null, 'region' => $region]);
         $contentRegion = new Content2Region($first);
         $contentRegion->setRegion($region);
         $contentRegion->setContent($content);
         $this->manager->persist($contentRegion);
         $this->manager->flush();
     }
 }