Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param \Claroline\CoreBundle\Entity\Home\Content2Region $first
  */
 public function __construct(Content2Region $first = null)
 {
     // the size may vary between 1 and 12 and corresponds to
     // bootstrap container col classes
     $this->size = 'content-12';
     if ($first) {
         $first->setBack($this);
         $this->next = $first;
         $this->back = null;
     } else {
         $this->next = null;
         $this->back = null;
     }
 }
Ejemplo n.º 2
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();
     }
 }