Exemplo n.º 1
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();
     }
 }