You are here

class AnnotatedClassDiscovery in Typed Data API enhancements 8

Extends the annotation class discovery for usage with Typed Data context.

We modify the annotations classes for ContextDefinition and for Condition. This class makes sure that our plugin managers apply these.

Hierarchy

Expanded class hierarchy of AnnotatedClassDiscovery

File

src/Context/AnnotatedClassDiscovery.php, line 14

Namespace

Drupal\typed_data\Context
View source
class AnnotatedClassDiscovery extends CoreAnnotatedClassDiscovery {

  /**
   * {@inheritdoc}
   */
  protected function getAnnotationReader() {
    if (!isset($this->annotationReader)) {

      // Do not call out the parent, but re-configure the simple annotation
      // reader on our own, so we can control the order of namespaces.
      $this->annotationReader = new SimpleAnnotationReader();

      // Make sure to add our namespace first, so our ContextDefinition and
      // Condition annotations gets picked.
      $this->annotationReader
        ->addNamespace('Drupal\\typed_data\\Context\\Annotation');

      // Add the namespaces from the main plugin annotation, like @EntityType.
      $namespace = mb_substr($this->pluginDefinitionAnnotationName, 0, mb_strrpos($this->pluginDefinitionAnnotationName, '\\'));
      $this->annotationReader
        ->addNamespace($namespace);

      // Add general core annotations like @Translation.
      $this->annotationReader
        ->addNamespace('Drupal\\Core\\Annotation');
    }
    return $this->annotationReader;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AnnotatedClassDiscovery::$annotationNamespaces protected property Additional namespaces to be scanned for annotation classes.
AnnotatedClassDiscovery::$annotationReader protected property The doctrine annotation reader.
AnnotatedClassDiscovery::$directorySuffix protected property A suffix to append to each PSR-4 directory associated with a base namespace, to form the directories where plugins are found.
AnnotatedClassDiscovery::$fileCache protected property The file cache object.
AnnotatedClassDiscovery::$namespaceSuffix protected property A suffix to append to each base namespace, to obtain the namespaces where plugins are found.
AnnotatedClassDiscovery::$pluginDefinitionAnnotationName protected property The name of the annotation that contains the plugin definition.
AnnotatedClassDiscovery::$pluginNamespaces protected property The namespaces within which to find plugin classes.
AnnotatedClassDiscovery::$rootNamespacesIterator protected property A list of base namespaces with their PSR-4 directories.
AnnotatedClassDiscovery::getAnnotationReader protected function Gets the used doctrine annotation reader. Overrides AnnotatedClassDiscovery::getAnnotationReader
AnnotatedClassDiscovery::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryTrait::getDefinitions 1
AnnotatedClassDiscovery::getPluginNamespaces protected function Gets an array of PSR-4 namespaces to search for plugin classes. Overrides AnnotatedClassDiscovery::getPluginNamespaces
AnnotatedClassDiscovery::getProviderFromNamespace protected function Extracts the provider name from a Drupal namespace.
AnnotatedClassDiscovery::prepareAnnotationDefinition protected function Prepares the annotation definition. Overrides AnnotatedClassDiscovery::prepareAnnotationDefinition 2
AnnotatedClassDiscovery::__construct public function Constructs an AnnotatedClassDiscovery object. Overrides AnnotatedClassDiscovery::__construct 2
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::getDefinition public function 3
DiscoveryTrait::hasDefinition public function