return \Drupal::entityTypeManager();
}
+ /**
+ * 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.
*
$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'];
}
*/
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);
}
* {@inheritdoc}
*/
public function save() {
- return $this->entityManager()->getStorage($this->entityTypeId)->save($this);
+ $storage = $this->entityTypeManager()->getStorage($this->entityTypeId);
+ return $storage->save($this);
}
/**
*/
public function delete() {
if (!$this->isNew()) {
- $this->entityManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]);
+ $this->entityTypeManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]);
}
}
* {@inheritdoc}
*/
public function getEntityType() {
- return $this->entityManager()->getDefinition($this->getEntityTypeId());
+ return $this->entityTypeManager()->getDefinition($this->getEntityTypeId());
}
/**
* {@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);
}
/**