ILIAS  release_7 Revision v7.30-3-g800a261c036
HasAgent.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
4namespace ILIAS\Setup\CLI;
5
8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Input\InputOption;
10
15{
19 protected $agent_finder = null;
20
21 protected function configureCommandForPlugins()
22 {
23 $this->addOption("plugin", null, InputOption::VALUE_REQUIRED, "Name of the plugin to run the command for.");
24 $this->addOption("no-plugins", null, InputOption::VALUE_NONE, "Ignore all plugins when running the command.");
25 $this->addOption("skip", null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, "Skip plugin with the supplied <plugin-name> when running the command.");
26 }
27
28 protected function getRelevantAgent(InputInterface $input) : Agent
29 {
30 if (!$this->agent_finder) {
31 throw new \LogicException(
32 "\$this->agent_finder needs to intialized with an AgentFinder."
33 );
34 }
35
36 if ($input->hasOption("no-plugins") && $input->getOption("no-plugins")) {
37 // The agents of the core are in all folders but the customizing folder.
38 return $this->agent_finder->getCoreAgents();
39 }
40
41 if ($input->hasOption("plugin")) {
42 $plugin_name = $input->getOption("plugin");
43 if ($plugin_name) {
44 return $this->agent_finder->getPluginAgent($plugin_name);
45 }
46 }
47
48 $agents = $this->agent_finder->getAgents();
49 if ($input->hasOption("skip")) {
50 foreach (($input->getOption("skip") ?? []) as $plugin_name) {
51 $agents = $agents->withRemovedAgent(strtolower($plugin_name));
52 }
53 }
54
55 return $agents;
56 }
57}
An exception for terminatinating execution or to throw for unit testing.
A agent is some component that performs part of the setup process.
Definition: Agent.php:14
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