ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
HasAgent.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\Setup\CLI;
20 
25 
29 trait HasAgent
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 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
configureCommandForPlugins()
Definition: HasAgent.php:33