Exemplo n.º 1
0
 /**
  * Create a new content.
  *
  * Here pre and post insert event are fired
  *
  * @param $defaultFolderId
  * @throws \Exception
  */
 public function create($defaultFolderId)
 {
     $con = Propel::getWriteConnection(ContentTableMap::DATABASE_NAME);
     $con->beginTransaction();
     $this->dispatchEvent(TheliaEvents::BEFORE_CREATECONTENT, new ContentEvent($this));
     try {
         $this->save($con);
         $cf = new ContentFolder();
         $cf->setContentId($this->getId())->setFolderId($defaultFolderId)->setDefaultFolder(1)->save($con);
         $this->setPosition($this->getNextPosition())->save($con);
         $con->commit();
         $this->dispatchEvent(TheliaEvents::AFTER_CREATECONTENT, new ContentEvent($this));
     } catch (\Exception $ex) {
         $con->rollback();
         throw $ex;
     }
 }