Mercurial > hg > isophonics-drupal-site
comparison core/modules/field/src/Entity/FieldConfig.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
160 $default_settings = $field_type_manager->getDefaultFieldSettings($storage_definition->getType()); | 160 $default_settings = $field_type_manager->getDefaultFieldSettings($storage_definition->getType()); |
161 $this->settings = array_intersect_key($this->settings, $default_settings) + $default_settings; | 161 $this->settings = array_intersect_key($this->settings, $default_settings) + $default_settings; |
162 | 162 |
163 if ($this->isNew()) { | 163 if ($this->isNew()) { |
164 // Notify the entity storage. | 164 // Notify the entity storage. |
165 $entity_manager->onFieldDefinitionCreate($this); | 165 \Drupal::service('field_definition.listener')->onFieldDefinitionCreate($this); |
166 } | 166 } |
167 else { | 167 else { |
168 // Some updates are always disallowed. | 168 // Some updates are always disallowed. |
169 if ($this->entity_type != $this->original->entity_type) { | 169 if ($this->entity_type != $this->original->entity_type) { |
170 throw new FieldException("Cannot change an existing field's entity_type."); | 170 throw new FieldException("Cannot change an existing field's entity_type."); |
174 } | 174 } |
175 if ($storage_definition->uuid() != $this->original->getFieldStorageDefinition()->uuid()) { | 175 if ($storage_definition->uuid() != $this->original->getFieldStorageDefinition()->uuid()) { |
176 throw new FieldException("Cannot change an existing field's storage."); | 176 throw new FieldException("Cannot change an existing field's storage."); |
177 } | 177 } |
178 // Notify the entity storage. | 178 // Notify the entity storage. |
179 $entity_manager->onFieldDefinitionUpdate($this, $this->original); | 179 \Drupal::service('field_definition.listener')->onFieldDefinitionUpdate($this, $this->original); |
180 } | 180 } |
181 | 181 |
182 parent::preSave($storage); | 182 parent::preSave($storage); |
183 } | 183 } |
184 | 184 |
221 /** | 221 /** |
222 * {@inheritdoc} | 222 * {@inheritdoc} |
223 */ | 223 */ |
224 public static function postDelete(EntityStorageInterface $storage, array $fields) { | 224 public static function postDelete(EntityStorageInterface $storage, array $fields) { |
225 // Clear the cache upfront, to refresh the results of getBundles(). | 225 // Clear the cache upfront, to refresh the results of getBundles(). |
226 \Drupal::entityManager()->clearCachedFieldDefinitions(); | 226 \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); |
227 | 227 |
228 // Notify the entity storage. | 228 // Notify the entity storage. |
229 foreach ($fields as $field) { | 229 foreach ($fields as $field) { |
230 if (!$field->deleted) { | 230 if (!$field->deleted) { |
231 \Drupal::entityManager()->onFieldDefinitionDelete($field); | 231 \Drupal::service('field_definition.listener')->onFieldDefinitionDelete($field); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 // If this is part of a configuration synchronization then the following | 235 // If this is part of a configuration synchronization then the following |
236 // configuration updates are not necessary. | 236 // configuration updates are not necessary. |
294 */ | 294 */ |
295 public function getFieldStorageDefinition() { | 295 public function getFieldStorageDefinition() { |
296 if (!$this->fieldStorage) { | 296 if (!$this->fieldStorage) { |
297 $field_storage_definition = NULL; | 297 $field_storage_definition = NULL; |
298 | 298 |
299 $field_storage_definitions = $this->entityManager()->getFieldStorageDefinitions($this->entity_type); | 299 $field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($this->entity_type); |
300 if (isset($field_storage_definitions[$this->field_name])) { | 300 if (isset($field_storage_definitions[$this->field_name])) { |
301 $field_storage_definition = $field_storage_definitions[$this->field_name]; | 301 $field_storage_definition = $field_storage_definitions[$this->field_name]; |
302 } | 302 } |
303 // If this field has been deleted, try to find its field storage | 303 // If this field has been deleted, try to find its field storage |
304 // definition in the deleted fields repository. | 304 // definition in the deleted fields repository. |