class AttributeDiscoveryWithAnnotationsAutomatedProviders
Enables both attribute and annotation discovery for plugin definitions.
@internal This provides backwards compatibility for migration source plugins using annotations and having more than one provider. This functionality will be deprecated with plugin discovery by annotations in https://www.drupal.org/project/drupal/issues/3522409.
Hierarchy
- class \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery implements \Drupal\Component\Plugin\Discovery\DiscoveryInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryTrait
- class \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery extends \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery
- class \Drupal\Core\Plugin\Discovery\AttributeDiscoveryWithAnnotations extends \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery
- class \Drupal\migrate\Plugin\Discovery\AttributeDiscoveryWithAnnotationsAutomatedProviders uses \Drupal\migrate\Plugin\Discovery\AnnotatedDiscoveryAutomatedProvidersTrait extends \Drupal\Core\Plugin\Discovery\AttributeDiscoveryWithAnnotations
- class \Drupal\Core\Plugin\Discovery\AttributeDiscoveryWithAnnotations extends \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery
- class \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery extends \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery
Expanded class hierarchy of AttributeDiscoveryWithAnnotationsAutomatedProviders
1 file declares its use of AttributeDiscoveryWithAnnotationsAutomatedProviders
- MigrateSourcePluginManager.php in core/
modules/ migrate/ src/ Plugin/ MigrateSourcePluginManager.php
File
-
core/
modules/ migrate/ src/ Plugin/ Discovery/ AttributeDiscoveryWithAnnotationsAutomatedProviders.php, line 22
Namespace
Drupal\migrate\Plugin\DiscoveryView source
class AttributeDiscoveryWithAnnotationsAutomatedProviders extends AttributeDiscoveryWithAnnotations {
use AnnotatedDiscoveryAutomatedProvidersTrait;
public function __construct(string $subdir, \Traversable $rootNamespaces, string $pluginDefinitionAttributeName = 'Drupal\\Component\\Plugin\\Attribute\\Plugin', string $pluginDefinitionAnnotationName = 'Drupal\\Component\\Annotation\\Plugin', array $additionalNamespaces = []) {
parent::__construct($subdir, $rootNamespaces, $pluginDefinitionAttributeName, $pluginDefinitionAnnotationName, $additionalNamespaces);
$this->finder = new ClassFinder();
}
/**
* {@inheritdoc}
*/
protected function parseClass(string $class, \SplFileInfo $fileinfo) : array {
// Parse using attributes first.
$definition = AttributeClassDiscovery::parseClass($class, $fileinfo);
if (isset($definition['id'])) {
return $definition;
}
// The filename is already known, so there is no need to find the
// file. However, StaticReflectionParser needs a finder, so use a
// mock version.
$finder = MockFileFinder::create($fileinfo->getPathName());
// The parser is instantiated here with FALSE as the last parameter. This is
// needed so that the parser includes the 'extends' declaration and extracts
// providers from ancestor classes.
$parser = new BaseStaticReflectionParser($class, $finder, FALSE);
$reflection_class = $parser->getReflectionClass();
// @todo Handle deprecating definitions discovery via annotations in
// https://www.drupal.org/project/drupal/issues/3522409.
/** @var \Drupal\Component\Annotation\AnnotationInterface $annotation */
if ($annotation = $this->getAnnotationReader()
->getClassAnnotation($reflection_class, $this->pluginDefinitionAnnotationName)) {
$this->prepareAnnotationDefinition($annotation, $class, $parser);
return [
'id' => $annotation->getId(),
'content' => $annotation->get(),
];
}
return [
'id' => NULL,
'content' => NULL,
];
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|
| AnnotatedDiscoveryAutomatedProvidersTrait::$finder | protected | property | A utility object that can use active autoloaders to find files for classes. | ||
| AnnotatedDiscoveryAutomatedProvidersTrait::prepareAnnotationDefinition | protected | function | Prepares the annotation definition. | ||
| AttributeClassDiscovery::$directorySuffix | protected | property | Suffix to append to each PSR-4 directory associated with a base namespace. | ||
| AttributeClassDiscovery::$fileCache | protected | property | The file cache object. | ||
| AttributeClassDiscovery::$namespaceSuffix | protected | property | A suffix to append to each base namespace. | ||
| AttributeClassDiscovery::$rootTwoLevelNamespaces | protected | property | List of root namespaces abbreviated to two levels. | ||
| AttributeClassDiscovery::$skipClasses | protected static | property | An array of classes to skip. | ||
| AttributeClassDiscovery::getClassDependencies | protected | function | Gets the list of class, interface, and trait dependencies for the class. | Overrides AttributeClassDiscovery::getClassDependencies | |
| AttributeClassDiscovery::getPluginNamespaces | protected | function | Gets an array of PSR-4 namespaces to search for plugin classes. | Overrides AttributeClassDiscovery::getPluginNamespaces | |
| AttributeClassDiscovery::getProviderFromNamespace | protected | function | Extracts the provider name from a Drupal namespace. | ||
| AttributeClassDiscovery::getTwoLevelNamespace | protected | function | Gets a string containing the first two levels of a class name or namespace. | ||
| AttributeClassDiscovery::hasMissingDependencies | protected | function | Whether the plugin definition has missing dependencies. | Overrides AttributeClassDiscovery::hasMissingDependencies | |
| AttributeClassDiscovery::prepareAttributeDefinition | protected | function | Prepares the attribute definition. | Overrides AttributeClassDiscovery::prepareAttributeDefinition | |
| AttributeDiscoveryWithAnnotations::$annotationReader | protected | property | The doctrine annotation reader. | ||
| AttributeDiscoveryWithAnnotations::getAnnotationReader | protected | function | Gets the used doctrine annotation reader. | ||
| AttributeDiscoveryWithAnnotations::getDefinitions | public | function | Gets the definition of all plugins for this type. | Overrides AttributeClassDiscovery::getDefinitions | |
| AttributeDiscoveryWithAnnotations::getFileCacheSuffix | protected | function | Gets the file cache suffix. | Overrides AttributeClassDiscovery::getFileCacheSuffix | |
| AttributeDiscoveryWithAnnotationsAutomatedProviders::parseClass | protected | function | Parses attributes from a class. | Overrides AttributeDiscoveryWithAnnotations::parseClass | |
| AttributeDiscoveryWithAnnotationsAutomatedProviders::__construct | public | function | Constructs an AttributeDiscoveryWithAnnotations object. | Overrides AttributeDiscoveryWithAnnotations::__construct | |
| DiscoveryTrait::doGetDefinition | protected | function | Gets a specific plugin definition. | ||
| DiscoveryTrait::getDefinition | public | function | 3 | ||
| DiscoveryTrait::hasDefinition | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.