ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.

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)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildEnvironment()

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

◆ configure()

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

Reimplemented in ILIAS\Setup\CLI\BuildArtifactsCommand, ILIAS\Setup\CLI\InstallCommand, ILIAS\Setup\CLI\ReloadControlStructureCommand, and ILIAS\Setup\CLI\UpdateCommand.

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 
)

Reimplemented in ILIAS\Setup\CLI\InstallCommand, and ILIAS\Setup\CLI\UpdateCommand.

Definition at line 77 of file BaseCommand.php.

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 }
printLicenseMessage(IOWrapper $io, InputInterface $input)
readAgentConfig(Agent $agent, InputInterface $input)
buildEnvironment(Agent $agent, ?Config $config, IOWrapper $io)
printIntroMessage(IOWrapper $io)
shouldSayYes(InputInterface $input)
printOutroMessage(IOWrapper $io)
getObjective(Agent $agent, ?Config $config)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68

References $config, Vendor\Package\$e, ILIAS\Setup\CLI\BaseCommand\buildEnvironment(), ILIAS\Setup\CLI\BaseCommand\getAgent(), ILIAS\Setup\CLI\BaseCommand\getObjective(), 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().

+ Here is the call graph for this function:

◆ getAgent()

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

Definition at line 60 of file BaseCommand.php.

60 : Agent
61 {
62 if ($this->agent !== null) {
63 return $this->agent;
64 }
65 $this->agent = ($this->lazy_agent)();
66 return $this->agent;
67 }

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

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

+ Here is the caller graph for this function:

◆ getObjective()

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

◆ printIntroMessage()

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

◆ printLicenseMessage()

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

Definition at line 122 of file BaseCommand.php.

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 }

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

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

+ 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

◆ readAgentConfig()

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

Reimplemented in ILIAS\Setup\CLI\BuildArtifactsCommand.

Definition at line 139 of file BaseCommand.php.

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 }

References ILIAS\Setup\CLI\BaseCommand\$agent.

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

+ 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.

117 : bool
118 {
119 return $input->getOption("yes") ?? false;
120 }

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

+ Here is the caller graph for this function:

Field Documentation

◆ $agent

◆ $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: