function AnnotatedClassDiscoveryAutomatedProviders::prepareAnnotationDefinition

Same name in other branches
  1. 8.9.x core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php \Drupal\migrate\Plugin\Discovery\AnnotatedClassDiscoveryAutomatedProviders::prepareAnnotationDefinition()
  2. 10 core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php \Drupal\migrate\Plugin\Discovery\AnnotatedClassDiscoveryAutomatedProviders::prepareAnnotationDefinition()
  3. 11.x core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php \Drupal\migrate\Plugin\Discovery\AnnotatedClassDiscoveryAutomatedProviders::prepareAnnotationDefinition()

Overrides AnnotatedClassDiscovery::prepareAnnotationDefinition

1 call to AnnotatedClassDiscoveryAutomatedProviders::prepareAnnotationDefinition()
AnnotatedClassDiscoveryAutomatedProviders::getDefinitions in core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
Gets the definition of all plugins for this type.

File

core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php, line 54

Class

AnnotatedClassDiscoveryAutomatedProviders
Determines providers based on a class's and its parent's namespaces.

Namespace

Drupal\migrate\Plugin\Discovery

Code

protected function prepareAnnotationDefinition(AnnotationInterface $annotation, $class, BaseStaticReflectionParser $parser = NULL) {
    if (!$annotation instanceof MultipleProviderAnnotationInterface) {
        throw new \LogicException('AnnotatedClassDiscoveryAutomatedProviders annotations must implement \\Drupal\\migrate\\Annotation\\MultipleProviderAnnotationInterface');
    }
    $annotation->setClass($class);
    $providers = $annotation->getProviders();
    // Loop through all the parent classes and add their providers (which we
    // infer by parsing their namespaces) to the $providers array.
    do {
        $providers[] = $this->getProviderFromNamespace($parser->getNamespaceName());
    } while ($parser = StaticReflectionParser::getParentParser($parser, $this->finder));
    $providers = array_unique(array_filter($providers, function ($provider) {
        return $provider && $provider !== 'component';
    }));
    $annotation->setProviders($providers);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.