ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4namespace ILIAS\Setup\CLI;
5
10use Symfony\Component\Console\Command\Command;
11use Symfony\Component\Console\Input\InputInterface;
12use Symfony\Component\Console\Output\OutputInterface;
14
18class 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}
An exception for terminatinating execution or to throw for unit testing.
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:18
const STABILITY_CONFIG
The stability of a metric tells how often we expect changes in the metric.
Definition: Metric.php:24
A wrapper around an objective that attempts to achieve the wrapped objective but won't stop the proce...
Definition: Tentatively.php:14
A agent is some component that performs part of the setup process.
Definition: Agent.php:14
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
__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:15
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:28
configureCommandForPlugins()
Definition: HasAgent.php:21