insertContentObject() abstract public method

Inserts a new content object.
abstract public insertContentObject ( eZ\Publish\SPI\Persistence\Content\CreateStruct $struct, mixed $currentVersionNo = 1 ) : integer
$struct eZ\Publish\SPI\Persistence\Content\CreateStruct
$currentVersionNo mixed
return integer ID
 /**
  * Inserts a new content object.
  *
  * @param \eZ\Publish\SPI\Persistence\Content\CreateStruct $struct
  * @param mixed $currentVersionNo
  *
  * @return int ID
  */
 public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1)
 {
     try {
         return $this->innerGateway->insertContentObject($struct, $currentVersionNo);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }
Example #2
0
 /**
  * Creates a new Content entity in the storage engine.
  *
  * The values contained inside the $content will form the basis of stored
  * entity.
  *
  * Will contain always a complete list of fields.
  *
  * @param \eZ\Publish\SPI\Persistence\Content\CreateStruct $struct Content creation struct.
  * @param mixed $versionNo Used by self::copy() to maintain version numbers
  *
  * @return \eZ\Publish\SPI\Persistence\Content Content value object
  */
 protected function internalCreate(CreateStruct $struct, $versionNo = 1)
 {
     $content = new Content();
     $content->fields = $struct->fields;
     $content->versionInfo = $this->mapper->createVersionInfoFromCreateStruct($struct, $versionNo);
     $content->versionInfo->contentInfo->id = $this->contentGateway->insertContentObject($struct, $versionNo);
     $content->versionInfo->id = $this->contentGateway->insertVersion($content->versionInfo, $struct->fields);
     $contentType = $this->contentTypeHandler->load($struct->typeId);
     $this->fieldHandler->createNewFields($content, $contentType);
     // Create node assignments
     foreach ($struct->locations as $location) {
         $location->contentId = $content->versionInfo->contentInfo->id;
         $location->contentVersion = $content->versionInfo->versionNo;
         $this->locationGateway->createNodeAssignment($location, $location->parentId, LocationGateway::NODE_ASSIGNMENT_OP_CODE_CREATE);
     }
     // Create names
     foreach ($content->versionInfo->names as $language => $name) {
         $this->contentGateway->setName($content->versionInfo->contentInfo->id, $content->versionInfo->versionNo, $name, $language);
     }
     return $content;
 }