function AttributeClassDiscovery::getClassDependencies
Same name in this branch
- 11.x core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery::getClassDependencies()
Gets the list of class, interface, and trait dependencies for the class.
Parameters
\ReflectionClass $reflection_class: Plugin class reflection object.
Return value
array{"class"?: list<class-string>, "interface"?: list<class-string>, "trait"?: list<class-string>, "provider"?: list<string>}|null The list of dependencies, keyed by type. If the type is 'class', 'trait', or 'interface', the values for the type are class names. If the type is 'provider', the values for the type are provider names. NULL if there are no dependencies.
Overrides AttributeClassDiscovery::getClassDependencies
File
-
core/
lib/ Drupal/ Core/ Plugin/ Discovery/ AttributeClassDiscovery.php, line 127
Class
- AttributeClassDiscovery
- Defines a discovery mechanism to find plugins using attributes.
Namespace
Drupal\Core\Plugin\DiscoveryCode
protected function getClassDependencies(\ReflectionClass $reflection_class) : ?array {
if (!$dependencies = parent::getClassDependencies($reflection_class)) {
return NULL;
}
// Get the providers from all the class namespaces. Exclude 'component',
// 'core', and the provider for the plugin class itself, since none of those
// providers will ever be missing.
$class_provider = $this->getProviderFromNamespace($reflection_class->getName());
$providers = [];
foreach ($dependencies as $type_dependencies) {
foreach ($type_dependencies as $dependency) {
if (($provider = $this->getProviderFromNamespace($dependency)) && $provider !== $class_provider && !in_array($provider, [
'component',
'core',
]) && !in_array($provider, $providers)) {
$providers[] = $provider;
}
}
}
if ($providers) {
// Only need to return providers here.
return [
'provider' => $providers,
];
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.