You are here

class EntityManagerWrapper in Devel 8.2

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Entity/EntityManagerWrapper.php \Drupal\webprofiler\Entity\EntityManagerWrapper
  2. 8 webprofiler/src/Entity/EntityManagerWrapper.php \Drupal\webprofiler\Entity\EntityManagerWrapper
  3. 4.x webprofiler/src/Entity/EntityManagerWrapper.php \Drupal\webprofiler\Entity\EntityManagerWrapper

Class EntityManagerWrapper

Hierarchy

Expanded class hierarchy of EntityManagerWrapper

1 string reference to 'EntityManagerWrapper'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses EntityManagerWrapper
webprofiler.debug.entity_type.manager in webprofiler/webprofiler.services.yml
Drupal\webprofiler\Entity\EntityManagerWrapper

File

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

Namespace

Drupal\webprofiler\Entity
View source
class EntityManagerWrapper extends DefaultPluginManager implements EntityTypeManagerInterface, ContainerAwareInterface {

  /**
   * @var array
   */
  private $loaded;

  /**
   * @var array
   */
  private $rendered;

  /**
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  private $entityManager;

  /**
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityManager
   */
  public function __construct(EntityTypeManagerInterface $entityManager) {
    $this->entityManager = $entityManager;
  }

  /**
   * {@inheritdoc}
   */
  public function getStorage($entity_type) {

    /** @var 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;
  }

  /**
   * {@inheritdoc}
   */
  public function getViewBuilder($entity_type) {

    /** @var EntityViewBuilderInterface $handler */
    $handler = $this
      ->getHandler($entity_type, 'view_builder');
    if ($handler instanceof EntityViewBuilderInterface) {
      if (!isset($this->rendered[$entity_type])) {
        $handler = new EntityViewBuilderDecorator($handler);
        $this->rendered[$entity_type] = $handler;
      }
      else {
        $handler = $this->rendered[$entity_type];
      }
    }
    return $handler;
  }

  /**
   * @param $entity_type
   * @param $handler
   *
   * @return \Drupal\webprofiler\Entity\EntityDecorator
   */
  private function getStorageDecorator($entity_type, $handler) {
    if ($handler instanceof ConfigEntityStorageInterface) {
      switch ($entity_type) {
        case 'taxonomy_vocabulary':
          return new VocabularyStorageDecorator($handler);
          break;
        case 'user_role':
          return new RoleStorageDecorator($handler);
          break;
        case 'shortcut_set':
          return new ShortcutSetStorageDecorator($handler);
          break;
        case 'image_style':
          return new ImageStyleStorageDecorator($handler);
          break;
        case 'domain':
          return new DomainStorageDecorator($handler);
          break;
        default:
          return new ConfigEntityStorageDecorator($handler);
          break;
      }
    }
    return $handler;
  }

  /**
   * @param $type
   * @param $entity_type
   *
   * @return array
   */
  public function getLoaded($type, $entity_type) {
    return isset($this->loaded[$type][$entity_type]) ? $this->loaded[$type][$entity_type] : NULL;
  }

  /**
   * @param $entity_type
   *
   * @return array
   */
  public function getRendered($entity_type) {
    return isset($this->rendered[$entity_type]) ? $this->rendered[$entity_type] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function useCaches($use_caches = FALSE) {
    $this->entityManager
      ->useCaches($use_caches);
  }

  /**
   * {@inheritdoc}
   */
  public function hasDefinition($plugin_id) {
    return $this->entityManager
      ->hasDefinition($plugin_id);
  }

  /**
   * {@inheritdoc}
   */
  public function getAccessControlHandler($entity_type) {
    return $this->entityManager
      ->getAccessControlHandler($entity_type);
  }

  /**
   * {@inheritdoc}
   */
  public function clearCachedDefinitions() {
    $this->entityManager
      ->clearCachedDefinitions();
    $this->loaded = NULL;
    $this->rendered = NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getListBuilder($entity_type) {
    return $this->entityManager
      ->getListBuilder($entity_type);
  }

  /**
   * {@inheritdoc}
   */
  public function getFormObject($entity_type, $operation) {
    return $this->entityManager
      ->getFormObject($entity_type, $operation);
  }

  /**
   * {@inheritdoc}
   */
  public function getRouteProviders($entity_type) {
    return $this->entityManager
      ->getRouteProviders($entity_type);
  }

  /**
   * {@inheritdoc}
   */
  public function hasHandler($entity_type, $handler_type) {
    return $this->entityManager
      ->hasHandler($entity_type, $handler_type);
  }

  /**
   * {@inheritdoc}
   */
  public function getHandler($entity_type, $handler_type) {
    return $this->entityManager
      ->getHandler($entity_type, $handler_type);
  }

  /**
   * {@inheritdoc}
   */
  public function createHandlerInstance($class, EntityTypeInterface $definition = NULL) {
    return $this->entityManager
      ->createHandlerInstance($class, $definition);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefinition($entity_type_id, $exception_on_invalid = TRUE) {
    return $this->entityManager
      ->getDefinition($entity_type_id, $exception_on_invalid);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefinitions() {
    return $this->entityManager
      ->getDefinitions();
  }

  /**
   * {@inheritdoc}
   */
  public function createInstance($plugin_id, array $configuration = []) {
    return $this->entityManager
      ->createInstance($plugin_id, $configuration);
  }

  /**
   * {@inheritdoc}
   */
  public function getInstance(array $options) {
    return $this->entityManager
      ->getInstance($options);
  }

  /**
   * {@inheritdoc}
   */
  public function setContainer(ContainerInterface $container = NULL) {
    $this->entityManager
      ->setContainer($container);
  }

  /**
   * {@inheritdoc}
   */
  public function getActiveDefinition($entity_type_id) {
    return $this->entityManager
      ->getActiveDefinition($entity_type_id);
  }

  /**
   * {@inheritdoc}
   */
  public function getActiveFieldStorageDefinitions($entity_type_id) {
    return $this->entityManager
      ->getActiveFieldStorageDefinitions($entity_type_id);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultPluginManager::$additionalAnnotationNamespaces protected property Additional namespaces the annotation discovery mechanism should scan for annotation definitions.
DefaultPluginManager::$alterHook protected property Name of the alter hook if one should be invoked.
DefaultPluginManager::$cacheKey protected property The cache key.
DefaultPluginManager::$cacheTags protected property An array of cache tags to use for the cached definitions.
DefaultPluginManager::$defaults protected property A set of defaults to be referenced by $this->processDefinition() if additional processing of plugins is necessary or helpful for development purposes. 9
DefaultPluginManager::$moduleHandler protected property The module handler to invoke the alter hook. 1
DefaultPluginManager::$namespaces protected property An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations.
DefaultPluginManager::$pluginDefinitionAnnotationName protected property The name of the annotation that contains the plugin definition.
DefaultPluginManager::$pluginInterface protected property The interface each plugin should implement. 1
DefaultPluginManager::$subdir protected property The subdirectory within a namespace to look for plugins, or FALSE if the plugins are in the top level of the namespace.
DefaultPluginManager::alterDefinitions protected function Invokes the hook to alter the definitions if the alter hook is set. 1
DefaultPluginManager::alterInfo protected function Sets the alter hook name.
DefaultPluginManager::extractProviderFromDefinition protected function Extracts the provider from a plugin definition.
DefaultPluginManager::findDefinitions protected function Finds plugin definitions. 7
DefaultPluginManager::fixContextAwareDefinitions private function Fix the definitions of context-aware plugins.
DefaultPluginManager::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
DefaultPluginManager::getCachedDefinitions protected function Returns the cached plugin definitions of the decorated discovery class.
DefaultPluginManager::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge
DefaultPluginManager::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyInterface::getCacheTags
DefaultPluginManager::getDiscovery protected function Gets the plugin discovery. Overrides PluginManagerBase::getDiscovery 12
DefaultPluginManager::getFactory protected function Gets the plugin factory. Overrides PluginManagerBase::getFactory
DefaultPluginManager::processDefinition public function Performs extra processing on plugin definitions. 13
DefaultPluginManager::providerExists protected function Determines if the provider of a definition exists. 3
DefaultPluginManager::setCacheBackend public function Initialize the cache backend.
DefaultPluginManager::setCachedDefinitions protected function Sets a cache of plugin definitions for the decorated discovery class.
DiscoveryCachedTrait::$definitions protected property Cached definitions array. 1
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
EntityManagerWrapper::$entityManager private property
EntityManagerWrapper::$loaded private property
EntityManagerWrapper::$rendered private property
EntityManagerWrapper::clearCachedDefinitions public function Clears static and persistent plugin definition caches. Overrides DefaultPluginManager::clearCachedDefinitions
EntityManagerWrapper::createHandlerInstance public function Creates new handler instance. Overrides EntityTypeManagerInterface::createHandlerInstance
EntityManagerWrapper::createInstance public function Creates a pre-configured instance of a plugin. Overrides PluginManagerBase::createInstance
EntityManagerWrapper::getAccessControlHandler public function Creates a new access control handler instance. Overrides EntityTypeManagerInterface::getAccessControlHandler
EntityManagerWrapper::getActiveDefinition public function
EntityManagerWrapper::getActiveFieldStorageDefinitions public function
EntityManagerWrapper::getDefinition public function Gets a specific plugin definition. Overrides DiscoveryCachedTrait::getDefinition
EntityManagerWrapper::getDefinitions public function Gets the definition of all plugins for this type. Overrides DefaultPluginManager::getDefinitions
EntityManagerWrapper::getFormObject public function Creates a new form instance. Overrides EntityTypeManagerInterface::getFormObject
EntityManagerWrapper::getHandler public function Returns a handler instance for the given entity type and handler. Overrides EntityTypeManagerInterface::getHandler
EntityManagerWrapper::getInstance public function Gets a preconfigured instance of a plugin. Overrides PluginManagerBase::getInstance
EntityManagerWrapper::getListBuilder public function Creates a new entity list builder. Overrides EntityTypeManagerInterface::getListBuilder
EntityManagerWrapper::getLoaded public function
EntityManagerWrapper::getRendered public function
EntityManagerWrapper::getRouteProviders public function Gets all route provider instances. Overrides EntityTypeManagerInterface::getRouteProviders
EntityManagerWrapper::getStorage public function Creates a new storage instance. Overrides EntityTypeManagerInterface::getStorage
EntityManagerWrapper::getStorageDecorator private function
EntityManagerWrapper::getViewBuilder public function Creates a new view builder instance. Overrides EntityTypeManagerInterface::getViewBuilder
EntityManagerWrapper::hasDefinition public function Indicates if a specific plugin definition exists. Overrides DiscoveryTrait::hasDefinition
EntityManagerWrapper::hasHandler public function Checks whether a certain entity type has a certain handler. Overrides EntityTypeManagerInterface::hasHandler
EntityManagerWrapper::setContainer public function Sets the Container.
EntityManagerWrapper::useCaches public function Disable the use of caches. Overrides DefaultPluginManager::useCaches
EntityManagerWrapper::__construct public function Overrides DefaultPluginManager::__construct
PluginManagerBase::$discovery protected property The object that discovers plugins managed by this manager.
PluginManagerBase::$factory protected property The object that instantiates plugins managed by this manager.
PluginManagerBase::$mapper protected property The object that returns the preconfigured plugin instance appropriate for a particular runtime condition.
PluginManagerBase::handlePluginNotFound protected function Allows plugin managers to specify custom behavior if a plugin is not found. 1
UseCacheBackendTrait::$cacheBackend protected property Cache backend instance.
UseCacheBackendTrait::$useCaches protected property Flag whether caches should be used or skipped.
UseCacheBackendTrait::cacheGet protected function Fetches from the cache backend, respecting the use caches flag. 1
UseCacheBackendTrait::cacheSet protected function Stores data in the persistent cache, respecting the use caches flag.