You are here

public function Projects::execute in DRD Agent 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Agent/Action/Projects.php \Drupal\drd_agent\Agent\Action\Projects::execute()

Execute an action.

Return value

mixed The response of the action as an array which will be encrypted before returned to DRD.

Overrides Base::execute

File

src/Agent/Action/Projects.php, line 16

Class

Projects
Provides a 'Projects' code.

Namespace

Drupal\drd_agent\Agent\Action

Code

public function execute() {
  $projects = [];

  // Core.
  $projects[] = [
    'name' => 'drupal',
    'type' => 'core',
    'status' => 1,
    'info' => [
      'core' => '8.x',
      'version' => Drupal::VERSION,
      'project' => 'drupal',
      'hidden' => FALSE,
    ],
  ];

  // Modules.

  /** @noinspection NullPointerExceptionInspection */
  foreach ($this->container
    ->get('extension.list.module')
    ->reset()
    ->getList() as $name => $extension) {
    $this
      ->buildProjectInfo($projects, 'module', $name, $extension);
  }

  // Themes.

  /** @noinspection NullPointerExceptionInspection */
  foreach ($this->container
    ->get('theme_handler')
    ->rebuildThemeData() as $name => $extension) {
    $this
      ->buildProjectInfo($projects, 'theme', $name, $extension);
  }

  // Integration with the Hacked module.
  if ($this->moduleHandler
    ->moduleExists('hacked')) {
    $this
      ->checkHacked($projects);
  }
  return $projects;
}