public function ComponentDiscovery::getMainComponents in Lightning Core 8.3
Same name and namespace in other branches
- 8.5 src/ComponentDiscovery.php \Drupal\lightning_core\ComponentDiscovery::getMainComponents()
- 8.4 src/ComponentDiscovery.php \Drupal\lightning_core\ComponentDiscovery::getMainComponents()
Returns extension objects for all main Lightning components.
Return value
Extension[] Array of extension objects for top-level Lightning components.
1 call to ComponentDiscovery::getMainComponents()
- ComponentDiscovery::getSubComponents in src/
ComponentDiscovery.php - Returns extension object for all Lightning sub-components.
File
- src/
ComponentDiscovery.php, line 95
Class
- ComponentDiscovery
- Helper object to locate Lightning components and sub-components.
Namespace
Drupal\lightning_coreCode
public function getMainComponents() {
$identifier = self::COMPONENT_PREFIX;
$filter = function (Extension $module) use ($identifier) {
// Assumes that:
// 1. Lightning sub-components are always in a sub-directory within the
// main component.
// 2. The main component's directory starts with "lightning_".
// E.g.: "/lightning_core/modules/lightning_search".
$path = explode(DIRECTORY_SEPARATOR, $module
->getPath());
$parent = $path[count($path) - 3];
return strpos($parent, $identifier) !== 0;
};
return array_filter($this
->getAll(), $filter);
}