Maps properties from $struct to $type.
public createTypeFromCreateStruct ( eZ\Publish\SPI\Persistence\Content\Type\CreateStruct $createStruct ) : eZ\Publish\SPI\Persistence\Content\Type | ||
$createStruct | eZ\Publish\SPI\Persistence\Content\Type\CreateStruct | |
Результат | eZ\Publish\SPI\Persistence\Content\Type |
/** * @covers eZ\Publish\Core\Persistence\Legacy\Content\Type\Mapper::createTypeFromCreateStruct * * @return void */ public function testTypeFromCreateStruct() { $struct = $this->getContentTypeCreateStructFixture(); $mapper = new Mapper($this->getConverterRegistryMock()); $type = $mapper->createTypeFromCreateStruct($struct); foreach ($struct as $propName => $propVal) { $this->assertEquals($struct->{$propName}, $type->{$propName}, "Property \${$propName} not equal"); } }
/** * Internal method for creating ContentType * * Used by self::create(), self::createDraft() and self::copy() * * @param \eZ\Publish\SPI\Persistence\Content\Type\CreateStruct $createStruct * @param mixed|null $contentTypeId Used by self::createDraft() to retain ContentType id in the draft * * @return \eZ\Publish\SPI\Persistence\Content\Type */ protected function internalCreate( CreateStruct $createStruct, $contentTypeId = null ) { foreach ( $createStruct->fieldDefinitions as $fieldDef ) { if ( !is_int( $fieldDef->position ) || $fieldDef->position <= 0 ) throw new InvalidArgumentException( "position", "'" . var_export( $fieldDef->position, true ) . "' is wrong value in class FieldDefinition, an integer strictly greater than 0 is required." ); } $createStruct = clone $createStruct; $contentType = $this->mapper->createTypeFromCreateStruct( $createStruct ); $contentType->id = $this->contentTypeGateway->insertType( $contentType, $contentTypeId ); foreach ( $contentType->groupIds as $groupId ) { $this->contentTypeGateway->insertGroupAssignment( $groupId, $contentType->id, $contentType->status ); } foreach ( $contentType->fieldDefinitions as $fieldDef ) { $storageFieldDef = new StorageFieldDefinition(); $this->mapper->toStorageFieldDefinition( $fieldDef, $storageFieldDef ); $fieldDef->id = $this->contentTypeGateway->insertFieldDefinition( $contentType->id, $contentType->status, $fieldDef, $storageFieldDef ); } return $contentType; }