示例#1
0
 /**
  * Constructor.
  *
  * @param \Claroline\CoreBundle\Entity\Home\SubContent $first
  */
 public function __construct(SubContent $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;
     }
 }
示例#2
0
 /**
  * Create a new content.
  *
  * @return The id of the new content
  */
 public function createContent($translatedContent, $type = null, $father = null)
 {
     $id = isset($translatedContent['content']) && is_array($translatedContent['content']) ? $this->contentManager->createContent($translatedContent['content']) : null;
     $content = $id ? $this->content->find($id) : null;
     if (!is_null($content)) {
         if ($father) {
             $father = $this->content->find($father);
             $first = $this->subContent->findOneBy(['back' => null, 'father' => $father]);
             $subContent = new SubContent($first);
             $subContent->setFather($father);
             $subContent->SetChild($content);
             $this->manager->persist($subContent);
         } else {
             $type = $this->type->findOneBy(['name' => $type]);
             $first = $this->contentType->findOneBy(['back' => null, 'type' => $type]);
             $contentType = new Content2Type($first);
             $contentType->setContent($content);
             $contentType->setType($type);
             $this->manager->persist($contentType);
         }
         $this->manager->flush();
         return $content->getId();
     }
 }