Projects.php in DRD Agent 8.3
File
src/Agent/Action/Projects.php
View source
<?php
namespace Drupal\drd_agent\Agent\Action;
use Drupal;
use Drupal\hacked\hackedProject;
class Projects extends Base {
public function execute() {
$projects = [];
$projects[] = [
'name' => 'drupal',
'type' => 'core',
'status' => 1,
'info' => [
'core' => '8.x',
'version' => Drupal::VERSION,
'project' => 'drupal',
'hidden' => FALSE,
],
];
foreach ($this->container
->get('extension.list.module')
->reset()
->getList() as $name => $extension) {
$this
->buildProjectInfo($projects, 'module', $name, $extension);
}
foreach ($this->container
->get('theme_handler')
->rebuildThemeData() as $name => $extension) {
$this
->buildProjectInfo($projects, 'theme', $name, $extension);
}
if ($this->moduleHandler
->moduleExists('hacked')) {
$this
->checkHacked($projects);
}
return $projects;
}
private function buildProjectInfo(array &$projects, $type, $name, $extension) {
$projects[] = [
'name' => $name,
'type' => $type,
'status' => $extension->status,
'info' => $extension->info,
];
}
private function checkHacked(array &$projects) {
foreach ($projects as &$project) {
$hacked = new hackedProject($project['name']);
$project['hacked'] = [
'report' => $hacked
->compute_report(),
];
$project['hacked']['status'] = $project['hacked']['report']['status'] === HACKED_STATUS_HACKED;
}
}
}
if (!defined('HACKED_STATUS_HACKED')) {
define('HACKED_STATUS_HACKED', 3);
}