protected function createTestContentType() { $contentTypeService = $this->repository->getContentTypeService(); $typeCreateStruct = $contentTypeService->newContentTypeCreateStruct('test-type'); $typeCreateStruct->names = array('eng-GB' => 'Test type name'); $typeCreateStruct->descriptions = array('eng-GB' => 'Test type description'); $typeCreateStruct->remoteId = 'test-type-remoteid'; $typeCreateStruct->creatorId = $this->repository->getCurrentUserReference()->getUserId(); $typeCreateStruct->creationDate = $this->getDateTime(0); $typeCreateStruct->mainLanguageCode = 'eng-GB'; $typeCreateStruct->nameSchema = '<test_required_empty>'; $typeCreateStruct->urlAliasSchema = '<test_required_empty>'; $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('test_required_empty', 'ezstring'); $fieldCreate->names = array('eng-GB' => 'Test required empty'); $fieldCreate->descriptions = array('eng-GB' => 'Required field with empty default value'); $fieldCreate->fieldGroup = 'test-field-group'; $fieldCreate->position = 1; $fieldCreate->isTranslatable = false; $fieldCreate->isRequired = true; $fieldCreate->isInfoCollector = false; $fieldCreate->isSearchable = true; $fieldCreate->defaultValue = ''; //$validator = new StringLengthValidator(); //$validator->maxStringLength = 64; //$fieldCreate->validatorConfiguration = array( $validator ); $fieldCreate->validatorConfiguration = array('StringLengthValidator' => array('maxStringLength' => 64)); //$fieldCreate->fieldSettings $typeCreateStruct->addFieldDefinition($fieldCreate); $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('test_required_not_empty', 'ezstring'); $fieldCreate->names = array('eng-GB' => 'Test required not empty'); $fieldCreate->descriptions = array('eng-GB' => 'Required field with default value not empty'); $fieldCreate->fieldGroup = 'test-field-group'; $fieldCreate->position = 2; $fieldCreate->isTranslatable = false; $fieldCreate->isRequired = true; $fieldCreate->isInfoCollector = false; $fieldCreate->isSearchable = true; $fieldCreate->defaultValue = 'dummy default data'; //$fieldCreate->validators //$fieldCreate->fieldSettings $typeCreateStruct->addFieldDefinition($fieldCreate); $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('test_translatable', 'ezstring'); $fieldCreate->names = array('eng-GB' => 'Test translatable'); $fieldCreate->descriptions = array('eng-GB' => 'Translatable field'); $fieldCreate->fieldGroup = 'test-field-group'; $fieldCreate->position = 3; $fieldCreate->isTranslatable = true; $fieldCreate->isRequired = false; $fieldCreate->isInfoCollector = false; $fieldCreate->isSearchable = true; $fieldCreate->defaultValue = ''; //$fieldCreate->validators //$fieldCreate->fieldSettings $typeCreateStruct->addFieldDefinition($fieldCreate); $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('test_untranslatable', 'ezstring'); $fieldCreate->names = array('eng-GB' => 'Test not translatable'); $fieldCreate->descriptions = array('eng-GB' => 'Untranslatable field'); $fieldCreate->fieldGroup = 'test-field-group'; $fieldCreate->position = 4; $fieldCreate->isTranslatable = false; $fieldCreate->isRequired = false; $fieldCreate->isInfoCollector = false; $fieldCreate->isSearchable = true; $fieldCreate->defaultValue = ''; //$fieldCreate->validators //$fieldCreate->fieldSettings $typeCreateStruct->addFieldDefinition($fieldCreate); $contentTypeDraft = $contentTypeService->createContentType($typeCreateStruct, array($contentTypeService->loadContentTypeGroup(1))); $contentTypeId = $contentTypeDraft->id; $contentTypeService->publishContentTypeDraft($contentTypeDraft); return $contentTypeService->loadContentType($contentTypeId); }