public function CacheDecorator::getDefinition

Implements Drupal\Component\Plugin\Discovery\DicoveryInterface::getDefinition().

Overrides DiscoveryInterface::getDefinition

File

drupal/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php, line 89
Definition of Drupal\Core\Plugin\Discovery\CacheDecorator.

Class

CacheDecorator
Enables static and persistent caching of discovered plugin definitions.

Namespace

Drupal\Core\Plugin\Discovery

Code

public function getDefinition($plugin_id) {

  // Optimize for fast access to definitions if they are already in memory.
  if (isset($this->definitions)) {

    // Avoid using a ternary that would create a copy of the array.
    if (isset($this->definitions[$plugin_id])) {
      return $this->definitions[$plugin_id];
    }
    else {
      return;
    }
  }
  $definitions = $this
    ->getDefinitions();

  // Avoid using a ternary that would create a copy of the array.
  if (isset($definitions[$plugin_id])) {
    return $definitions[$plugin_id];
  }
}