class AnnotatedClassDiscovery

Extends the annotation class discovery for usage with Rules 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

2 files declare their use of AnnotatedClassDiscovery
ConditionManager.php in src/Core/ConditionManager.php
RulesActionManager.php in src/Core/RulesActionManager.php

File

src/Context/AnnotatedClassDiscovery.php, line 14

Namespace

Drupal\rules\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\\rules\\Context\\Annotation');
            $this->annotationReader
                ->addNamespace('Drupal\\rules\\Core\\Annotation');
            // Add the namespaces from the main plugin annotation, like @EntityType.
            $namespace = substr($this->pluginDefinitionAnnotationName, 0, strrpos($this->pluginDefinitionAnnotationName, '\\'));
            $this->annotationReader
                ->addNamespace($namespace);
            // Add general core annotations like @Translation.
            $this->annotationReader
                ->addNamespace('Drupal\\Core\\Annotation');
        }
        return $this->annotationReader;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title 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 The directory suffix.
AnnotatedClassDiscovery::$fileCache protected property The file cache object.
AnnotatedClassDiscovery::$namespaceSuffix protected property The namespace suffix.
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 1
AnnotatedClassDiscovery::__construct public function Constructs an AnnotatedClassDiscovery object. Overrides AnnotatedClassDiscovery::__construct 1
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::getDefinition public function 3
DiscoveryTrait::hasDefinition public function