function AttributeClassDiscovery::getClassDependencies
Same name in this branch
- main core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery::getClassDependencies()
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery::getClassDependencies()
- 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.
File
-
core/
lib/ Drupal/ Component/ Plugin/ Discovery/ AttributeClassDiscovery.php, line 297
Class
- AttributeClassDiscovery
- Defines a discovery mechanism to find plugins with attributes.
Namespace
Drupal\Component\Plugin\DiscoveryCode
protected function getClassDependencies(\ReflectionClass $reflection_class) : ?array {
$dependencies = [];
if ($interfaces = $reflection_class->getInterfaceNames()) {
$dependencies['interface'] = $interfaces;
}
if ($traits = $reflection_class->getTraitNames()) {
$dependencies['trait'] = $traits;
}
$child_class = $reflection_class;
while ($parent_class = $child_class->getParentClass()) {
$dependencies['class'][] = $parent_class->getName();
if ($traits = $parent_class->getTraitNames()) {
$dependencies['trait'] ??= [];
$dependencies['trait'] = array_unique(array_merge($dependencies['trait'], $traits));
}
$child_class = $parent_class;
}
return $dependencies ?: NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.