protected function internalCreate(CreateStruct $createStruct, $contentTypeId = null)
    {
        foreach ($createStruct->fieldDefinitions as $fieldDef) {
            if (!is_int($fieldDef->position)) {
                throw new InvalidArgumentException(
                    'position',
                    "'" . var_export($fieldDef->position, true) .
                    "' is wrong value in class FieldDefinition, an integer 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;
    }
protected function internalCreate(CreateStruct $createStruct, $contentTypeId = null)
    {
        foreach ($createStruct->fieldDefinitions as $fieldDef) {
            if (!is_int($fieldDef->position)) {
                throw new InvalidArgumentException(
                    'position',
                    "'" . var_export($fieldDef->position, true) .
                    "' is wrong value in class FieldDefinition, an integer 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;
    }
protected function internalCreate ( CreateStruct $ createStruct , $ contentTypeId = null ) { foreach ( $ createStruct -> fieldDefinitions as $ fieldDef ) { if ( ! is_int ( $ fieldDef -> position ) ) { throw new InvalidArgumentException ( 'position' , "'" . var_export ( $ fieldDef -> position , true ) . "' is wrong value in class FieldDefinition, an integer 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 ; }
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
Internal method for creating ContentType .