ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
StatusCommand.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3 
4 namespace ILIAS\Setup\CLI;
5 
14 
18 class StatusCommand extends Command
19 {
20  use HasAgent;
21  use ObjectiveHelper;
22 
23  protected static $defaultName = "status";
24 
25  public function __construct(AgentFinder $agent_finder)
26  {
28  $this->agent_finder = $agent_finder;
29  }
30 
31  public function configure()
32  {
33  $this->setDescription("Collect and show status information about the installation.");
35  }
36 
37 
38  public function execute(InputInterface $input, OutputInterface $output)
39  {
40  $agent = $this->getRelevantAgent($input);
41 
42  $output->write($this->getMetrics($agent)->toYAML() . "\n");
43  }
44 
45  public function getMetrics(Agent $agent) : Metrics\Metric
46  {
47  // ATTENTION: Don't do this (in general), please have a look at the comment
48  // in ilIniFilesLoadedObjective.
50 
51  $environment = new ArrayEnvironment([]);
52  $storage = new Metrics\ArrayStorage();
53  $objective = new Tentatively(
54  $agent->getStatusObjective($storage)
55  );
56 
57  $this->achieveObjective($objective, $environment);
58 
59  $metric = $storage->asMetric();
60  list($config, $other) = $metric->extractByStability(Metrics\Metric::STABILITY_CONFIG);
61  if ($other) {
62  $values = $other->getValue();
63  } else {
64  $values = [];
65  }
66  if ($config) {
67  $values["config"] = $config;
68  }
69 
70  return new Metrics\Metric(
73  $values
74  );
75  }
76 }
execute(InputInterface $input, OutputInterface $output)
getStatusObjective(Metrics\Storage $storage)
Get the objective to be achieved when status is requested.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
Command to output status information about the installation.
A agent is some component that performs part of the setup process.
Definition: Agent.php:13
A metric is something we can measure about the system.
Definition: Metric.php:17
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:28
__construct(AgentFinder $agent_finder)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A wrapper around an objective that attempts to achieve the wrapped objective but won&#39;t stop the proce...
Definition: Tentatively.php:13
configureCommandForPlugins()
Definition: HasAgent.php:21
__construct(Container $dic, ilPlugin $plugin)
trait HasAgent
Add this to an Command that has an agent.
Definition: HasAgent.php:15
const STABILITY_CONFIG
The stability of a metric tells how often we expect changes in the metric.
Definition: Metric.php:24