ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Setup\CLI\BaseCommand Class Reference

Command base class. More...

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

Public Member Functions

 __construct (callable $lazy_agent, ConfigReader $config_reader, array $preconditions)
 
 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 

Protected Member Functions

 getAgent ()
 
 shouldSayYes (InputInterface $input)
 
 printLicenseMessage (IOWrapper $io, InputInterface $input)
 
 printIntroMessage (IOWrapper $io)
 
 printOutroMessage (IOWrapper $io)
 
 readAgentConfig (Agent $agent, InputInterface $input)
 
 buildEnvironment (Agent $agent, ?Config $config, IOWrapper $io)
 
 getObjective (Agent $agent, ?Config $config)
 

Protected Attributes

 $lazy_agent
 
 $agent
 
 $config_reader
 
 $preconditions
 var Objective[] More...
 

Static Protected Attributes

static $defaultName = "install"
 

Detailed Description

Command base class.

Definition at line 23 of file BaseCommand.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\CLI\BaseCommand::__construct ( callable  $lazy_agent,
ConfigReader  $config_reader,
array  $preconditions 
)

Definition at line 51 of file BaseCommand.php.

References ILIAS\Setup\CLI\BaseCommand\$config_reader, ILIAS\Setup\CLI\BaseCommand\$lazy_agent, ILIAS\Setup\CLI\BaseCommand\$preconditions, and ILIAS\GlobalScreen\Provider\__construct().

52  {
54  $this->lazy_agent = $lazy_agent;
55  $this->agent = null;
56  $this->config_reader = $config_reader;
57  $this->preconditions = $preconditions;
58  }
$preconditions
var Objective[]
Definition: BaseCommand.php:45
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildEnvironment()

ILIAS\Setup\CLI\BaseCommand::buildEnvironment ( Agent  $agent,
?Config  $config,
IOWrapper  $io 
)
abstractprotected

Referenced by ILIAS\Setup\CLI\BaseCommand\execute(), and ILIAS\Setup\CLI\BaseCommand\readAgentConfig().

+ Here is the caller graph for this function:

◆ configure()

ILIAS\Setup\CLI\BaseCommand::configure ( )

Definition at line 69 of file BaseCommand.php.

70  {
71  $this
72  ->addArgument("config", InputArgument::REQUIRED, "Configuration file for the Setup")
73  ->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\"", [])
74  ->addOption("yes", "y", InputOption::VALUE_NONE, "Confirm every message of the setup.");
75  }

◆ execute()

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

Definition at line 77 of file BaseCommand.php.

References $config, Vendor\Package\$e, ILIAS\Setup\CLI\BaseCommand\buildEnvironment(), ILIAS\Setup\CLI\BaseCommand\getAgent(), ILIAS\Setup\CLI\BaseCommand\getObjective(), ILIAS\Setup\NoConfirmationException\getRequestedConfirmation(), ILIAS\Setup\CLI\BaseCommand\printIntroMessage(), ILIAS\Setup\CLI\BaseCommand\printLicenseMessage(), ILIAS\Setup\CLI\BaseCommand\printOutroMessage(), ILIAS\Setup\CLI\BaseCommand\readAgentConfig(), and ILIAS\Setup\CLI\BaseCommand\shouldSayYes().

78  {
79  $io = new IOWrapper($input, $output, $this->shouldSayYes($input));
80 
81  $this->printLicenseMessage($io, $input);
82 
83  $this->printIntroMessage($io);
84 
85  $config = $this->readAgentConfig($this->getAgent(), $input);
86  $environment = $this->buildEnvironment($this->getAgent(), $config, $io);
87  $goal = $this->getObjective($this->getAgent(), $config);
88  if (count($this->preconditions) > 0) {
89  $goal = new ObjectiveWithPreconditions(
90  $goal,
91  ...$this->preconditions
92  );
93  }
94  $goals = new ObjectiveIterator($environment, $goal);
95 
96  try {
97  while ($goals->valid()) {
98  $current = $goals->current();
99  $io->startObjective($current->getLabel(), $current->isNotable());
100  try {
101  $environment = $current->achieve($environment);
102  $io->finishedLastObjective($current->getLabel(), $current->isNotable());
103  $goals->setEnvironment($environment);
104  } catch (UnachievableException $e) {
105  $goals->markAsFailed($current);
106  $io->error($e->getMessage());
107  $io->failedLastObjective($current->getLabel());
108  }
109  $goals->next();
110  }
111  $this->printOutroMessage($io);
112  } catch (NoConfirmationException $e) {
113  $io->error("Aborting Setup, a necessary confirmation is missing:\n\n" . $e->getRequestedConfirmation());
114  }
115  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
printLicenseMessage(IOWrapper $io, InputInterface $input)
printOutroMessage(IOWrapper $io)
getObjective(Agent $agent, ?Config $config)
buildEnvironment(Agent $agent, ?Config $config, IOWrapper $io)
shouldSayYes(InputInterface $input)
printIntroMessage(IOWrapper $io)
readAgentConfig(Agent $agent, InputInterface $input)
+ Here is the call graph for this function:

◆ getAgent()

ILIAS\Setup\CLI\BaseCommand::getAgent ( )
protected

Definition at line 60 of file BaseCommand.php.

References ILIAS\Setup\CLI\BaseCommand\$agent, and ILIAS\Setup\CLI\BaseCommand\$lazy_agent.

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

60  : Agent
61  {
62  if ($this->agent !== null) {
63  return $this->agent;
64  }
65  $this->agent = ($this->lazy_agent)();
66  return $this->agent;
67  }
+ Here is the caller graph for this function:

◆ getObjective()

ILIAS\Setup\CLI\BaseCommand::getObjective ( Agent  $agent,
?Config  $config 
)
abstractprotected

Referenced by ILIAS\Setup\CLI\BaseCommand\execute(), and ILIAS\Setup\CLI\BaseCommand\readAgentConfig().

+ Here is the caller graph for this function:

◆ printIntroMessage()

ILIAS\Setup\CLI\BaseCommand::printIntroMessage ( IOWrapper  $io)
abstractprotected

Referenced by ILIAS\Setup\CLI\BaseCommand\execute(), and ILIAS\Setup\CLI\BaseCommand\printLicenseMessage().

+ Here is the caller graph for this function:

◆ printLicenseMessage()

ILIAS\Setup\CLI\BaseCommand::printLicenseMessage ( IOWrapper  $io,
InputInterface  $input 
)
protected

Definition at line 122 of file BaseCommand.php.

References ILIAS\Setup\CLI\BaseCommand\printIntroMessage(), ILIAS\Setup\CLI\BaseCommand\printOutroMessage(), ILIAS\Setup\CLI\BaseCommand\shouldSayYes(), and ILIAS\Setup\CLI\IOWrapper\text().

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

122  : void
123  {
124  if ($this->shouldSayYes($input) || ($input->hasOption("no-interaction") && $input->getOption("no-interaction"))) {
125  return;
126  }
127  $io->text(
128  " ILIAS Copyright (C) 1998-2019 ILIAS Open Source e.V. - GPLv3\n\n" .
129  "This program comes with ABSOLUTELY NO WARRANTY. This is free software,\n" .
130  "and you are welcome to redistribute it under certain conditions. Look\n" .
131  "into the LICENSE file for details."
132  );
133  }
shouldSayYes(InputInterface $input)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printOutroMessage()

ILIAS\Setup\CLI\BaseCommand::printOutroMessage ( IOWrapper  $io)
abstractprotected

Referenced by ILIAS\Setup\CLI\BaseCommand\execute(), and ILIAS\Setup\CLI\BaseCommand\printLicenseMessage().

+ Here is the caller graph for this function:

◆ readAgentConfig()

ILIAS\Setup\CLI\BaseCommand::readAgentConfig ( Agent  $agent,
InputInterface  $input 
)
protected

Definition at line 139 of file BaseCommand.php.

References ILIAS\Setup\CLI\BaseCommand\$agent, $config, ILIAS\Setup\CLI\BaseCommand\buildEnvironment(), ILIAS\Setup\CLI\BaseCommand\getObjective(), and ILIAS\Setup\Agent\hasConfig().

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

139  : ?Config
140  {
141  if (!$agent->hasConfig()) {
142  return null;
143  }
144 
145  $config_file = $input->getArgument("config");
146  $config_overwrites_raw = $input->getOption("config");
147  $config_overwrites = [];
148  foreach ($config_overwrites_raw as $o) {
149  list($k, $v) = explode("=", $o);
150  $config_overwrites[$k] = $v;
151  }
152  $config_content = $this->config_reader->readConfigFile($config_file, $config_overwrites);
153  $trafo = $this->agent->getArrayToConfigTransformation();
154  return $trafo->transform($config_content);
155  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shouldSayYes()

ILIAS\Setup\CLI\BaseCommand::shouldSayYes ( InputInterface  $input)
protected

Definition at line 117 of file BaseCommand.php.

Referenced by ILIAS\Setup\CLI\BaseCommand\execute(), and ILIAS\Setup\CLI\BaseCommand\printLicenseMessage().

117  : bool
118  {
119  return $input->getOption("yes") ?? false;
120  }
+ Here is the caller graph for this function:

Field Documentation

◆ $agent

ILIAS\Setup\CLI\BaseCommand::$agent
protected

◆ $config_reader

ILIAS\Setup\CLI\BaseCommand::$config_reader
protected

Definition at line 40 of file BaseCommand.php.

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

◆ $defaultName

ILIAS\Setup\CLI\BaseCommand::$defaultName = "install"
staticprotected

Definition at line 25 of file BaseCommand.php.

◆ $lazy_agent

ILIAS\Setup\CLI\BaseCommand::$lazy_agent
protected

◆ $preconditions

ILIAS\Setup\CLI\BaseCommand::$preconditions
protected

var Objective[]

Definition at line 45 of file BaseCommand.php.

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


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