private function PotxExtractTranslationForm::generateComponentList in Translation template extractor 8
Generate a hierarchical structured list of components.
Return value
array Array in the directory structure identified.
- 'normal' keyed elements being subfolders
- '#name' elements being component objects for the 'name' component
- '#-count' being the file count of all components in the directory
1 call to PotxExtractTranslationForm::generateComponentList()
- PotxExtractTranslationForm::buildForm in src/
Form/ PotxExtractTranslationForm.php - Form constructor.
File
- src/
Form/ PotxExtractTranslationForm.php, line 210
Class
- PotxExtractTranslationForm
- Class PotxExtractTranslationForm.
Namespace
Drupal\potx\FormCode
private function generateComponentList() {
$components = [];
// Get a list of all enabled modules and themes.
$modules = $this->moduleHandler
->getModuleList();
$themes = $this->themeHandler
->listInfo();
/** @var \Drupal\Core\Extension\Extension[] $result */
$result = array_merge($modules, $themes);
foreach ($result as $component) {
// Build directory tree structure.
$path_parts = explode('/', $component
->getPath());
$dir =& $components;
foreach ($path_parts as $dirname) {
if (!isset($dir[$dirname])) {
$dir[$dirname] = [];
}
$dir =& $dir[$dirname];
}
// Information about components in this directory.
$dir['#' . $component
->getExtensionFilename()] = $component;
$dir['#-count'] = isset($dir['#-count']) ? $dir['#-count'] + 1 : 1;
}
return $components;
}