protected function ComponentsInfo::findComponentsInfo in Components! 8.2
Finds component info from the given extension list.
Parameters
\Drupal\Core\Extension\ExtensionList $extension_list: The extension list to search.
Return value
array The components info for all extensions in the extension list.
1 call to ComponentsInfo::findComponentsInfo()
- ComponentsInfo::init in src/
Template/ ComponentsInfo.php - Initializes the registry and loads the theme namespaces.
File
- src/
Template/ ComponentsInfo.php, line 138
Class
- ComponentsInfo
- Loads info about components defined in themes or modules.
Namespace
Drupal\components\TemplateCode
protected function findComponentsInfo(ExtensionList $extension_list) {
$data = [];
foreach ($extension_list
->getAllInstalledInfo() as $name => $extension_info) {
// Find the components info.
$info = isset($extension_info['components']) && is_array($extension_info['components']) ? $extension_info['components'] : [];
// Look for namespaces using 1.x API (backwards compatibility).
if (!isset($info['namespaces']) && isset($extension_info['component-libraries'])) {
$this
->logWarning(sprintf('Components 8.x-1.x API is deprecated in components:8.x-2.0 and is removed from components:3.0.0. Update the %s.info.yml file to replace the component-libraries.[namespace].paths data with components.namespaces.[namespace]. See https://www.drupal.org/node/3082817', $name));
if (is_array($extension_info['component-libraries'])) {
foreach ($extension_info['component-libraries'] as $namespace => $namespace_data) {
if (!empty($namespace_data['paths'])) {
$info['namespaces'][$namespace] = $namespace_data['paths'];
}
}
}
}
// Normalize namespace data.
$extension_path = $extension_list
->getPath($name);
if (isset($info['namespaces'])) {
foreach ($info['namespaces'] as $namespace => $paths) {
// Allow paths to be an array or a string.
if (!is_array($paths)) {
$info['namespaces'][$namespace] = [];
$paths = [
$paths,
];
}
// Add the full path to the namespace paths.
foreach ($paths as $key => $path) {
// Determine if the given path is relative to the Drupal root or to
// the extension.
$parent_path = $path[0] === '/' ? \Drupal::root() : $extension_path . '/';
$info['namespaces'][$namespace][$key] = $parent_path . $path;
}
}
}
// Save the components info for the extension.
if (!empty($info)) {
$info['extensionPath'] = $extension_path;
$data[$name] = $info;
}
// The following namespaces are protected because they did not opt-in.
if ((!isset($info['namespaces']) || empty($info['namespaces'][$name])) && !isset($info['allow_default_namespace_reuse'])) {
$this
->setProtectedNamespace($name, $extension_info);
}
}
return $data;
}