eZ\Publish\Core\Persistence\Legacy\Content\Mapper::createRelationFromCreateStruct PHP Method

createRelationFromCreateStruct() public method

Creates a Content from the given $struct.
public createRelationFromCreateStruct ( eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $struct ) : eZ\Publish\SPI\Persistence\Content\Relation
$struct eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct
return eZ\Publish\SPI\Persistence\Content\Relation
    public function createRelationFromCreateStruct(RelationCreateStruct $struct)
    {
        $relation = new Relation();
        $relation->destinationContentId = $struct->destinationContentId;
        $relation->sourceContentId = $struct->sourceContentId;
        $relation->sourceContentVersionNo = $struct->sourceContentVersionNo;
        $relation->sourceFieldDefinitionId = $struct->sourceFieldDefinitionId;
        $relation->type = $struct->type;
        return $relation;
    }

Usage Example

コード例 #1
0
ファイル: Handler.php プロジェクト: Pixy/ezpublish-kernel
 /**
  * Creates a relation between $sourceContentId in $sourceContentVersionNo
  * and $destinationContentId with a specific $type.
  *
  * @todo Should the existence verifications happen here or is this supposed to be handled at a higher level?
  *
  * @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct
  *
  * @return \eZ\Publish\SPI\Persistence\Content\Relation
  */
 public function addRelation(RelationCreateStruct $createStruct)
 {
     $relation = $this->mapper->createRelationFromCreateStruct($createStruct);
     $relation->id = $this->contentGateway->insertRelation($createStruct);
     return $relation;
 }