comparison core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
109 /** 109 /**
110 * Adds a new base field to the 'entity_test_update' entity type. 110 * Adds a new base field to the 'entity_test_update' entity type.
111 * 111 *
112 * @param string $type 112 * @param string $type
113 * (optional) The field type for the new field. Defaults to 'string'. 113 * (optional) The field type for the new field. Defaults to 'string'.
114 */ 114 * @param string $entity_type_id
115 protected function addBaseField($type = 'string') { 115 * (optional) The entity type ID the base field should be attached to.
116 * Defaults to 'entity_test_update'.
117 * @param bool $is_revisionable
118 * (optional) If the base field should be revisionable or not. Defaults to
119 * FALSE.
120 */
121 protected function addBaseField($type = 'string', $entity_type_id = 'entity_test_update', $is_revisionable = FALSE) {
116 $definitions['new_base_field'] = BaseFieldDefinition::create($type) 122 $definitions['new_base_field'] = BaseFieldDefinition::create($type)
117 ->setName('new_base_field') 123 ->setName('new_base_field')
124 ->setRevisionable($is_revisionable)
118 ->setLabel(t('A new base field')); 125 ->setLabel(t('A new base field'));
119 $this->state->set('entity_test_update.additional_base_field_definitions', $definitions); 126 $this->state->set($entity_type_id . '.additional_base_field_definitions', $definitions);
120 } 127 }
121 128
122 /** 129 /**
123 * Adds a long-named base field to the 'entity_test_update' entity type. 130 * Adds a long-named base field to the 'entity_test_update' entity type.
124 */ 131 */
165 $this->state->set('entity_test_update.entity_type', $entity_type); 172 $this->state->set('entity_test_update.entity_type', $entity_type);
166 } 173 }
167 174
168 /** 175 /**
169 * Removes the new base field from the 'entity_test_update' entity type. 176 * Removes the new base field from the 'entity_test_update' entity type.
170 */ 177 *
171 protected function removeBaseField() { 178 * @param string $entity_type_id
172 $this->state->delete('entity_test_update.additional_base_field_definitions'); 179 * (optional) The entity type ID the base field should be attached to.
180 */
181 protected function removeBaseField($entity_type_id = 'entity_test_update') {
182 $this->state->delete($entity_type_id . '.additional_base_field_definitions');
173 } 183 }
174 184
175 /** 185 /**
176 * Adds a single-field index to the base field. 186 * Adds a single-field index to the base field.
177 */ 187 */