diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php index 738b856..d3e0889 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php @@ -208,6 +208,13 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface { public $original = NULL; /** + * The plugin manager for entities. + * + * @var \Drupal\Core\Entity\EntityManager + */ + protected $entityManager; + + /** * Constructs a FieldInstance object. * * @param array $values @@ -272,6 +279,8 @@ public function __construct(array $values, $entity_type = 'field_instance') { throw new FieldException(format_string('Attempt to create an instance of field @field_id without a bundle.', array('@field_id' => $this->field->id))); } + $this->entityManager = \Drupal::entityManager(); + // 'Label' defaults to the field ID (mostly useful for field instances // created in tests). $values += array( @@ -352,7 +361,7 @@ public function save() { * In case of failures at the configuration storage level. */ protected function saveNew() { - $instance_controller = \Drupal::entityManager()->getStorageController($this->entityType); + $instance_controller = $this->entityManager->getStorageController($this->entityType); // Check that the field can be attached to this entity type. if (!empty($this->field->entity_types) && !in_array($this->entity_type, $this->field->entity_types)) { @@ -390,7 +399,7 @@ protected function saveNew() { * In case of failures at the configuration storage level. */ protected function saveUpdated() { - $instance_controller = \Drupal::entityManager()->getStorageController($this->entityType); + $instance_controller = $this->entityManager->getStorageController($this->entityType); $original = $instance_controller->loadUnchanged($this->getOriginalID()); $this->original = $original; @@ -538,8 +547,7 @@ public function isFieldTranslatable() { * {@inheritdoc} */ public function uri() { - $entity_manager = \Drupal::entityManager(); - $path = $entity_manager->getAdminPath($this->entity_type, $this->bundle); + $path = $this->entityManager->getAdminPath($this->entity_type, $this->bundle); return array( 'path' => $path . '/fields/' . $this->id(), 'options' => array(