Mercurial > hg > isophonics-drupal-site
diff core/lib/Drupal/Core/Entity/Entity.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 | c2387f117808 |
line wrap: on
line diff
--- a/core/lib/Drupal/Core/Entity/Entity.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/lib/Drupal/Core/Entity/Entity.php Mon Apr 23 09:46:53 2018 +0100 @@ -89,6 +89,15 @@ } /** + * Gets the entity type bundle info service. + * + * @return \Drupal\Core\Entity\EntityTypeBundleInfoInterface + */ + protected function entityTypeBundleInfo() { + return \Drupal::service('entity_type.bundle.info'); + } + + /** * Gets the language manager. * * @return \Drupal\Core\Language\LanguageManagerInterface @@ -198,7 +207,7 @@ $bundle = $this->bundle(); // A bundle-specific callback takes precedence over the generic one for // the entity type. - $bundles = $this->entityManager()->getBundleInfo($this->getEntityTypeId()); + $bundles = $this->entityTypeBundleInfo()->getBundleInfo($this->getEntityTypeId()); if (isset($bundles[$bundle]['uri_callback'])) { $uri_callback = $bundles[$bundle]['uri_callback']; } @@ -344,11 +353,11 @@ */ public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { if ($operation == 'create') { - return $this->entityManager() + return $this->entityTypeManager() ->getAccessControlHandler($this->entityTypeId) ->createAccess($this->bundle(), $account, [], $return_as_object); } - return $this->entityManager() + return $this->entityTypeManager() ->getAccessControlHandler($this->entityTypeId) ->access($this, $operation, $account, $return_as_object); } @@ -374,7 +383,8 @@ * {@inheritdoc} */ public function save() { - return $this->entityManager()->getStorage($this->entityTypeId)->save($this); + $storage = $this->entityTypeManager()->getStorage($this->entityTypeId); + return $storage->save($this); } /** @@ -382,7 +392,7 @@ */ public function delete() { if (!$this->isNew()) { - $this->entityManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]); + $this->entityTypeManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]); } } @@ -407,7 +417,7 @@ * {@inheritdoc} */ public function getEntityType() { - return $this->entityManager()->getDefinition($this->getEntityTypeId()); + return $this->entityTypeManager()->getDefinition($this->getEntityTypeId()); } /** @@ -508,24 +518,30 @@ * {@inheritdoc} */ public static function load($id) { - $entity_manager = \Drupal::entityManager(); - return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->load($id); + $entity_type_repository = \Drupal::service('entity_type.repository'); + $entity_type_manager = \Drupal::entityTypeManager(); + $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(get_called_class())); + return $storage->load($id); } /** * {@inheritdoc} */ public static function loadMultiple(array $ids = NULL) { - $entity_manager = \Drupal::entityManager(); - return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->loadMultiple($ids); + $entity_type_repository = \Drupal::service('entity_type.repository'); + $entity_type_manager = \Drupal::entityTypeManager(); + $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(get_called_class())); + return $storage->loadMultiple($ids); } /** * {@inheritdoc} */ public static function create(array $values = []) { - $entity_manager = \Drupal::entityManager(); - return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->create($values); + $entity_type_repository = \Drupal::service('entity_type.repository'); + $entity_type_manager = \Drupal::entityTypeManager(); + $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(get_called_class())); + return $storage->create($values); } /**