public function UpgradeStatusCommands::doAnalyze in Upgrade Status 8.3
Analyze projects and return all processed extensions.
@option all Analyze all projects. @option skip-existing Return results from a previous scan of a project if available, otherwise start a new one. @option ignore-uninstalled Ignore uninstalled projects. @option ignore-contrib Ignore contributed projects. @option ignore-custom Ignore custom projects.
Parameters
array $projects: List of projects to analyze.
array $options: Additional options for the command.
Throws
\InvalidArgumentException Thrown when one of the passed arguments is invalid or no arguments were provided.
2 calls to UpgradeStatusCommands::doAnalyze()
- UpgradeStatusCommands::analyze in src/
Commands/ UpgradeStatusCommands.php - Analyze projects output as ASCII.
- UpgradeStatusCommands::checkstyle in src/
Commands/ UpgradeStatusCommands.php - Analyze projects output as XML.
File
- src/
Commands/ UpgradeStatusCommands.php, line 184
Class
- UpgradeStatusCommands
- Upgrade Status Drush command
Namespace
Drupal\upgrade_status\CommandsCode
public function doAnalyze(array $projects, array $options = [
'all' => FALSE,
'skip-existing' => FALSE,
'ignore-uninstalled' => FALSE,
'ignore-contrib' => FALSE,
'ignore-custom' => FALSE,
]) {
// Group by type here so we can tell loader what is type of each one of
// these.
$extensions = [];
$invalid_names = [];
if (empty($projects) && !$options['all']) {
$message = dt('You need to provide at least one installed project\'s machine_name.');
throw new \InvalidArgumentException($message);
}
// Gather project list grouped by custom and contrib projects.
$available_projects = $this->projectCollector
->collectProjects();
if ($options['all']) {
foreach ($available_projects as $name => $project) {
if ($options['ignore-uninstalled'] && $project->status === 0) {
continue;
}
if ($options['ignore-contrib'] && $project->info['upgrade_status_type'] == ProjectCollector::TYPE_CONTRIB) {
continue;
}
if ($options['ignore-custom'] && $project->info['upgrade_status_type'] == ProjectCollector::TYPE_CUSTOM) {
continue;
}
$extensions[$project
->getType()][$name] = $project;
}
}
else {
foreach ($projects as $name) {
if (!isset($available_projects[$name])) {
$invalid_names[] = $name;
continue;
}
if ($options['ignore-uninstalled'] && $available_projects[$name]->status === 0) {
$invalid_names[] = $name;
continue;
}
if ($options['ignore-contrib'] && $available_projects[$name]->info['upgrade_status_type'] == ProjectCollector::TYPE_CONTRIB) {
$invalid_names[] = $name;
continue;
}
if ($options['ignore-custom'] && $available_projects[$name]->info['upgrade_status_type'] == ProjectCollector::TYPE_CUSTOM) {
$invalid_names[] = $name;
continue;
}
$extensions[$available_projects[$name]
->getType()][$name] = $available_projects[$name];
}
}
if (!empty($invalid_names)) {
if (count($invalid_names) == 1) {
$message = dt('The project machine name @invalid_name is invalid. Is this a project on this site? (For community projects, use the machine name of the drupal.org project itself).', [
'@invalid_name' => $invalid_names[0],
]);
}
else {
$message = dt('The project machine names @invalid_names are invalid. Are these projects on this site? (For community projects, use the machine name of the drupal.org project itself).', [
'@invalid_names' => implode(', ', $invalid_names),
]);
}
throw new \InvalidArgumentException($message);
}
else {
$this
->logger()
->info(dt('Starting the analysis. This may take a while.'));
}
foreach ($extensions as $type => $list) {
foreach ($list as $name => $extension) {
if ($options['skip-existing']) {
$scan_result = \Drupal::service('keyvalue')
->get('upgrade_status_scan_results')
->get($name);
if (!empty($scan_result)) {
$this
->logger()
->info(dt('Using previous results for @name.', [
'@name' => $name,
]));
continue;
}
}
$this
->logger()
->info(dt('Processing @name.', [
'@name' => $name,
]));
$this->deprecationAnalyzer
->analyze($extension);
}
}
return $extensions;
}