You are here

public function EntityManagerWrapper::getStorage in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Entity/EntityManagerWrapper.php \Drupal\webprofiler\Entity\EntityManagerWrapper::getStorage()
  2. 8 webprofiler/src/Entity/EntityManagerWrapper.php \Drupal\webprofiler\Entity\EntityManagerWrapper::getStorage()
  3. 8.2 webprofiler/src/Entity/EntityManagerWrapper.php \Drupal\webprofiler\Entity\EntityManagerWrapper::getStorage()

Creates a new storage instance.

Parameters

string $entity_type_id: The entity type ID for this storage.

Return value

\Drupal\Core\Entity\EntityStorageInterface A storage instance.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if the entity type doesn't exist.

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Thrown if the storage handler couldn't be loaded.

Overrides EntityTypeManagerInterface::getStorage

File

webprofiler/src/Entity/EntityManagerWrapper.php, line 49

Class

EntityManagerWrapper
Class EntityManagerWrapper.

Namespace

Drupal\webprofiler\Entity

Code

public function getStorage($entity_type) {

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $handler */
  $handler = $this
    ->getHandler($entity_type, 'storage');
  $type = $handler instanceof ConfigEntityStorageInterface ? 'config' : 'content';
  if (!isset($this->loaded[$type][$entity_type])) {
    $handler = $this
      ->getStorageDecorator($entity_type, $handler);
    $this->loaded[$type][$entity_type] = $handler;
  }
  else {
    $handler = $this->loaded[$type][$entity_type];
  }
  return $handler;
}