ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
HasAgent.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Setup\CLI;
20
23use Symfony\Component\Console\Input\InputInterface;
24use Symfony\Component\Console\Input\InputOption;
25
30{
31 protected ?AgentFinder $agent_finder = null;
32
33 protected function configureCommandForPlugins(): void
34 {
35 $this->addOption("legacy-plugin", null, InputOption::VALUE_REQUIRED, "Name of the plugin to run the command for.");
36 $this->addOption("no-legacy-plugins", null, InputOption::VALUE_NONE, "Ignore all plugins when running the command.");
37 $this->addOption("skip-legacy-plugin", null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, "Skip plugin with the supplied <plugin-name> when running the command.");
38 }
39
40 protected function getRelevantAgent(InputInterface $input): Agent
41 {
42 if (!$this->agent_finder) {
43 throw new \LogicException(
44 "\$this->agent_finder needs to intialized with an AgentFinder."
45 );
46 }
47
48 if ($input->hasOption("no-legacy-plugins") && $input->getOption("no-legacy-plugins")) {
49 // The agents of the core are in all folders but the customizing folder.
50 return $this->agent_finder->getComponentAgents();
51 }
52
53 if ($input->hasOption("legacy-plugin")) {
54 $plugin_name = $input->getOption("legacy-plugin");
55 if ($plugin_name) {
56 return $this->agent_finder->getPluginAgent($plugin_name);
57 }
58 }
59
60 $agents = $this->agent_finder->getAgents();
61 if ($input->hasOption("skip-legacy-plugin")) {
62 foreach (($input->getOption("skip-legacy-plugin") ?? []) as $plugin_name) {
63 $agents = $agents->withRemovedAgent($plugin_name);
64 }
65 }
66
67 return $agents;
68 }
69}
A agent is some component that performs part of the setup process.
Definition: Agent.php:30
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