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;
}