ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StatusCommand.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Setup\CLI;
22
28use Symfony\Component\Console\Input\InputInterface;
29use Symfony\Component\Console\Output\OutputInterface;
31
36{
37 use HasAgent;
38 use ObjectiveHelper;
39
40 protected static $defaultName = "status";
41
42 public function __construct(AgentFinder $agent_finder)
43 {
45 $this->agent_finder = $agent_finder;
46 }
47
48 protected function configure(): void
49 {
50 $this->setDescription("Collect and show status information about the installation.");
52 }
53
54
55 protected function execute(InputInterface $input, OutputInterface $output): int
56 {
57 $agent = $this->getRelevantAgent($input);
58
59 $output->write($this->getMetrics($agent)->toYAML() . "\n");
60
61 return 0;
62 }
63
64 public function getMetrics(Agent $agent): Metrics\Metric
65 {
66 // ATTENTION: Don't do this (in general), please have a look at the comment
67 // in ilIniFilesLoadedObjective.
69
70 $environment = new ArrayEnvironment([]);
71 $storage = new Metrics\ArrayStorage();
72 $objective = new Tentatively(
73 $agent->getStatusObjective($storage)
74 );
75
76 $this->achieveObjective($objective, $environment);
77
78 $metric = $storage->asMetric();
79 list($config, $other) = $metric->extractByStability(Metrics\Metric::STABILITY_CONFIG);
80 if ($other) {
81 $values = $other->getValue();
82 } else {
83 $values = [];
84 }
85 if ($config) {
86 $values["config"] = $config;
87 }
88
89 return new Metrics\Metric(
92 $values
93 );
94 }
95}
Command to output status information about the installation.
execute(InputInterface $input, OutputInterface $output)
__construct(AgentFinder $agent_finder)
A metric is something we can measure about the system.
Definition: Metric.php:34
const STABILITY_CONFIG
The stability of a metric tells how often we expect changes in the metric.
Definition: Metric.php:40
A wrapper around an objective that attempts to achieve the wrapped objective but won't stop the proce...
Definition: Tentatively.php:30
A agent is some component that performs part of the setup process.
Definition: Agent.php:30
getStatusObjective(Metrics\Storage $storage)
Get the objective to be achieved when status is requested.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait HasAgent
Add this to an Command that has an agent.
Definition: HasAgent.php:30
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
configureCommandForPlugins()
Definition: HasAgent.php:33