getLastVersionNumber() 추상적인 공개 메소드

Returns last version number for content identified by $contentId.
abstract public getLastVersionNumber ( integer $contentId ) : integer
$contentId integer
리턴 integer
 /**
  * Returns last version number for content identified by $contentId
  *
  * @param int $contentId
  *
  * @return int
  */
 public function getLastVersionNumber($contentId)
 {
     try {
         return $this->innerGateway->getLastVersionNumber($contentId);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }
예제 #2
0
 /**
  * Creates a new draft version from $contentId in $version.
  *
  * Copies all fields from $contentId in $srcVersion and creates a new
  * version of the referred Content from it.
  *
  * Note: When creating a new draft in the old admin interface there will
  * also be an entry in the `eznode_assignment` created for the draft. This
  * is ignored in this implementation.
  *
  * @param mixed $contentId
  * @param mixed $srcVersion
  * @param mixed $userId
  *
  * @return \eZ\Publish\SPI\Persistence\Content
  */
 public function createDraftFromVersion($contentId, $srcVersion, $userId)
 {
     $content = $this->load($contentId, $srcVersion);
     // Create new version
     $content->versionInfo = $this->mapper->createVersionInfoForContent($content, $this->contentGateway->getLastVersionNumber($contentId) + 1, $userId);
     $content->versionInfo->id = $this->contentGateway->insertVersion($content->versionInfo, $content->fields);
     // Clone fields from previous version and append them to the new one
     $this->fieldHandler->createExistingFieldsInNewVersion($content);
     // Create relations for new version
     $relations = $this->contentGateway->loadRelations($contentId, $srcVersion);
     foreach ($relations as $relation) {
         $this->contentGateway->insertRelation(new RelationCreateStruct(array('sourceContentId' => $contentId, 'sourceContentVersionNo' => $content->versionInfo->versionNo, 'sourceFieldDefinitionId' => $relation['ezcontentobject_link_contentclassattribute_id'], 'destinationContentId' => $relation['ezcontentobject_link_to_contentobject_id'], 'type' => (int) $relation['ezcontentobject_link_relation_type'])));
     }
     // Create content names for new version
     foreach ($content->versionInfo->names as $language => $name) {
         $this->contentGateway->setName($contentId, $content->versionInfo->versionNo, $name, $language);
     }
     return $content;
 }