1 <?php declare(strict_types=1);
52 $this->agent_finder = $agent_finder;
53 $this->config_reader = $config_reader;
60 $this->setDescription(
"Achieve a named objective from an agent.");
61 $this->addArgument(
"objective", InputArgument::REQUIRED,
"Objective to be execute from an agent. Format: \$AGENT::\$OBJECTIVE");
62 $this->addArgument(
"config", InputArgument::OPTIONAL,
"Configuration file for the installation");
63 $this->addOption(
"config", null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
"Define fields in the configuration file that should be overwritten, e.g. \"a.b.c=foo\"", []);
64 $this->addOption(
"yes",
"y", InputOption::VALUE_NONE,
"Confirm every message of the update.");
67 public function execute(InputInterface $input, OutputInterface $output)
69 $objective_name = $input->getArgument(
'objective');
72 $io->printLicenseMessage();
73 $io->title(
"Achieve objective: $objective_name");
77 if ($input->getArgument(
"config")) {
83 $objective = $agent->getNamedObjective($objective_name,
$config);
85 if (count($this->preconditions) > 0) {
88 ...$this->preconditions
100 $this->achieveObjective($objective, $environment, $io);
101 $io->success(
"Achieved objective '$objective_name'. Thanks and have fun!");
103 $io->error(
"Aborted the attempt to achieve '$objective_name', a necessary confirmation is missing:\n\n" . $e->
getRequestedConfirmation());
110 if (!preg_match(
'/^\s*(\w+)::(\w+)\s*$/', $agent_method,
$result)) {
Read a json-formatted config from a file and overwrite some fields.
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
__construct(AgentFinder $agent_finder, ConfigReader $config_reader, array $preconditions, Refinery $refinery)
readAgentConfig(Agent $agent, InputInterface $input)
A wrapper around an objective that adds some preconditions.
addAgentConfigsToEnvironment(Agent $agent, Config $config, Environment $environment)
execute(InputInterface $input, OutputInterface $output)
getRelevantAgent(InputInterface $input)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseAgentMethod(string $agent_method)
__construct(Container $dic, ilPlugin $plugin)
$preconditions
var Objective[]
const RESOURCE_ADMIN_INTERACTION
trait HasAgent
Add this to an Command that has an agent.
getRequestedConfirmation()
Signals that a necessary confirmation from the admin is missing.
trait HasConfigReader
Add this to an Command that has an config reader.