public function HackedCommands::listProjects in Hacked! 8.2
List all projects that can be analysed by Hacked!
@option force-rebuild Rebuild the Hacked! report instead of getting a cached version.
@command hacked:list-projects @aliases hlp,hacked-list-projects
@field-labels title: Title name: Name version: Version status: Status changed: Changed deleted: Deleted @default-fields title,name,version,status,changed,deleted
@validate-module-enabled hacked
Parameters
array $options: An associative array of options whose values come from cli, aliases, config, etc.
Return value
\Consolidation\OutputFormatters\StructuredData\RowsOfFields The list of projects arranged for table display
File
- src/
Commands/ HackedCommands.php, line 92
Class
- HackedCommands
- A Drush commandfile for Hacked! module.
Namespace
Drupal\hacked\CommandsCode
public function listProjects(array $options = [
'force-rebuild' => FALSE,
]) {
// Go get the data.
$this->moduleHandler
->loadInclude('update', 'inc', 'update.report');
$rows = [];
if ($available = update_get_available(TRUE)) {
$this->moduleHandler
->loadInclude('update', 'inc', 'update.compare');
$data = update_calculate_project_data($available);
$force_rebuild = $options['force-rebuild'];
$projects = $this
->calculateProjectData($data, $force_rebuild);
// Now print the data using drush.
$rows = [];
foreach ($projects as $project) {
$row = [
'title' => $project['title'],
'name' => $project['name'],
'version' => $project['existing_version'],
];
// Now add the status:
switch ($project['status']) {
case HACKED_STATUS_UNHACKED:
$row['status'] = $this
->t('Unchanged');
break;
case HACKED_STATUS_HACKED:
$row['status'] = $this
->t('Changed');
break;
case HACKED_STATUS_UNCHECKED:
default:
$row['status'] = $this
->t('Unchecked');
break;
}
$row['changed'] = $project['counts']['different'];
$row['deleted'] = $project['counts']['missing'];
$rows[] = $row;
}
}
return new RowsOfFields($rows);
}