ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Setup\CLI\AchieveCommand Class Reference

Achieves an objective. More...

+ Inheritance diagram for ILIAS\Setup\CLI\AchieveCommand:
+ Collaboration diagram for ILIAS\Setup\CLI\AchieveCommand:

Public Member Functions

 __construct (AgentFinder $agent_finder, ConfigReader $config_reader, array $preconditions, Refinery $refinery)
 

Protected Member Functions

 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 

Protected Attributes

array $preconditions = []
 
Refinery $refinery
 

Static Protected Attributes

static $defaultName = "achieve"
 

Private Member Functions

 shouldListNamedObjectives (InputInterface $input)
 
 executeListNamedObjectives (IOWrapper $io, OutputInterface $output)
 
 executeAchieveObjective (IOWrapper $io, InputInterface $input)
 

Detailed Description

Achieves an objective.

Definition at line 41 of file AchieveCommand.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\CLI\AchieveCommand::__construct ( AgentFinder  $agent_finder,
ConfigReader  $config_reader,
array  $preconditions,
Refinery  $refinery 
)

Definition at line 56 of file AchieveCommand.php.

61 {
63 $this->agent_finder = $agent_finder;
64 $this->config_reader = $config_reader;
65 $this->preconditions = $preconditions;
66 $this->refinery = $refinery;
67 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\Setup\CLI\AchieveCommand\$preconditions, ILIAS\Setup\CLI\AchieveCommand\$refinery, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ configure()

ILIAS\Setup\CLI\AchieveCommand::configure ( )
protected

Definition at line 69 of file AchieveCommand.php.

69 : void
70 {
71 $this->setDescription("Achieve a named objective from an agent.");
72 $this->addArgument(
73 "objective",
74 InputArgument::OPTIONAL,
75 "Objective to be execute from an agent. Format: \$AGENT::\$OBJECTIVE"
76 );
77 $this->addArgument("config", InputArgument::OPTIONAL, "Configuration file for the installation");
78 $this->addOption(
79 "config",
80 null,
81 InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
82 "Define fields in the configuration file that should be overwritten, e.g. \"a.b.c=foo\"",
83 []
84 );
85 $this->addOption("yes", "y", InputOption::VALUE_NONE, "Confirm every message of the objective.");
86 $this->addOption("list", null, InputOption::VALUE_NONE, "Lists all achievable objectives");
87 }

◆ execute()

ILIAS\Setup\CLI\AchieveCommand::execute ( InputInterface  $input,
OutputInterface  $output 
)
protected

Definition at line 89 of file AchieveCommand.php.

89 : int
90 {
91 $io = new IOWrapper($input, $output);
92 $io->printLicenseMessage();
93
94 if ($this->shouldListNamedObjectives($input)) {
95 $this->executeListNamedObjectives($io, $output);
96 return 0;
97 }
98
99 $this->executeAchieveObjective($io, $input);
100
101 return 0;
102 }
executeAchieveObjective(IOWrapper $io, InputInterface $input)
shouldListNamedObjectives(InputInterface $input)
executeListNamedObjectives(IOWrapper $io, OutputInterface $output)

References ILIAS\Setup\CLI\AchieveCommand\executeAchieveObjective(), ILIAS\Setup\CLI\AchieveCommand\executeListNamedObjectives(), and ILIAS\Setup\CLI\AchieveCommand\shouldListNamedObjectives().

+ Here is the call graph for this function:

◆ executeAchieveObjective()

ILIAS\Setup\CLI\AchieveCommand::executeAchieveObjective ( IOWrapper  $io,
InputInterface  $input 
)
private

Definition at line 131 of file AchieveCommand.php.

131 : void
132 {
133 $agent = $this->getRelevantAgent($input);
134 $objective_name = $input->getArgument('objective');
135
136 $io->title("Achieve objective: $objective_name");
137
138 $config = null;
139 if ($input->getArgument("config")) {
140 $config = $this->readAgentConfig($agent, $input);
141 }
142
143 $namedObjectives = $agent->getNamedObjectives($config);
144
145 if (isset($namedObjectives[$objective_name])) {
146 $objective = $namedObjectives[$objective_name];
147 } else {
148 throw new InvalidArgumentException(
149 "There is no named objective '$objective_name'"
150 );
151 }
152
153 if ($this->preconditions !== []) {
154 $objective = new ObjectiveWithPreconditions(
155 $objective->create(),
156 ...$this->preconditions
157 );
158 } else {
159 $objective = $objective->create();
160 }
161
162 $environment = new ArrayEnvironment([
164 ]);
165 if ($config !== null) {
166 $environment = $this->addAgentConfigsToEnvironment($agent, $config, $environment);
167 }
168
169 try {
170 $this->achieveObjective($objective, $environment, $io);
171 $io->success("Achieved objective '$objective_name'. Thanks and have fun!");
172 } catch (NoConfirmationException $e) {
173 $io->error("Aborted the attempt to achieve '$objective_name', a necessary confirmation is missing:\n\n" . $e->getRequestedConfirmation());
174 }
175 }
addAgentConfigsToEnvironment(Agent $agent, Config $config, Environment $environment)
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
readAgentConfig(Agent $agent, InputInterface $input, ?string $use_config_field=null)

References Vendor\Package\$e, ILIAS\Setup\CLI\addAgentConfigsToEnvironment(), ILIAS\Setup\CLI\IOWrapper\error(), ILIAS\Setup\CLI\getRelevantAgent(), ILIAS\Setup\CLI\readAgentConfig(), ILIAS\Setup\Environment\RESOURCE_ADMIN_INTERACTION, ILIAS\Setup\CLI\IOWrapper\success(), and ILIAS\Setup\CLI\IOWrapper\title().

Referenced by ILIAS\Setup\CLI\AchieveCommand\execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeListNamedObjectives()

ILIAS\Setup\CLI\AchieveCommand::executeListNamedObjectives ( IOWrapper  $io,
OutputInterface  $output 
)
private

Definition at line 119 of file AchieveCommand.php.

119 : void
120 {
121 $io->title("Listing available objectives");
122
123 $agentCollection = $this->agent_finder->getAgents();
124 foreach ($agentCollection->getNamedObjectives(null) as $cmd => $objectiveCollection) {
125 $output->write(str_pad($cmd, IOWrapper::LABEL_WIDTH));
126 $output->writeln($objectiveCollection->getDescription());
127 }
128 $output->writeln("");
129 }

References ILIAS\Setup\CLI\IOWrapper\LABEL_WIDTH, and ILIAS\Setup\CLI\IOWrapper\title().

Referenced by ILIAS\Setup\CLI\AchieveCommand\execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shouldListNamedObjectives()

ILIAS\Setup\CLI\AchieveCommand::shouldListNamedObjectives ( InputInterface  $input)
private

Definition at line 104 of file AchieveCommand.php.

104 : bool
105 {
106 return
107 (
108 $input->getOption("list") !== null
109 && is_bool($input->getOption("list"))
110 && $input->getOption("list")
111 )
112 ||
113 (
114 $input->getArgument("objective") === ""
115 || $input->getArgument("objective") === null
116 );
117 }

Referenced by ILIAS\Setup\CLI\AchieveCommand\execute().

+ Here is the caller graph for this function:

Field Documentation

◆ $defaultName

ILIAS\Setup\CLI\AchieveCommand::$defaultName = "achieve"
staticprotected

Definition at line 47 of file AchieveCommand.php.

◆ $preconditions

array ILIAS\Setup\CLI\AchieveCommand::$preconditions = []
protected

Definition at line 49 of file AchieveCommand.php.

Referenced by ILIAS\Setup\CLI\AchieveCommand\__construct().

◆ $refinery

Refinery ILIAS\Setup\CLI\AchieveCommand::$refinery
protected

Definition at line 51 of file AchieveCommand.php.

Referenced by ILIAS\Setup\CLI\AchieveCommand\__construct().


The documentation for this class was generated from the following file: