9use Symfony\Component\Mime\Exception\LogicException;
10use Symfony\Component\Console\Input\InputInterface;
37 return $this->agents[$key] ??
null;
43 unset($clone->agents[$key]);
49 if (isset($this->agents[$key])) {
50 throw new \LogicException(
"An agent with the name '$key' already exists.");
53 $clone->agents[$key] = $agent;
62 foreach ($this->agents as
$c) {
63 if (
$c->hasConfig()) {
75 return $this->refinery->in()->series([
76 $this->refinery->custom()->transformation(function (
$in) {
78 foreach ($this->agents as $key => $agent) {
79 if (!$agent->hasConfig()) {
82 $val =
$in[$key] ??
null;
83 $transformation = $agent->getArrayToConfigTransformation();
84 $out[$key] = $transformation($val);
88 $this->refinery->custom()->transformation(function ($v) {
91 $this->refinery->to()->toNew(ConfigCollection::class)
105 "Collected Install Objectives",
107 ...array_values(array_map(
110 return $v->getInstallObjective($config->getConfig($k));
112 return $v->getInstallObjective();
115 array_keys($this->agents),
116 array_values($this->agents)
131 "Collected Update Objectives",
133 ...array_values(array_map(
140 array_keys($this->agents),
141 array_values($this->agents)
152 "Collected Build Artifact Objectives",
154 ...array_values(array_map(
155 function (
Agent $v) {
169 "Collected Status Objectives",
171 ...array_values(array_map(
172 function (
string $k,
Agent $v) use ($storage) {
174 new Metrics\StorageOnPathWrapper($k, $storage)
177 array_keys($this->agents),
178 array_values($this->agents)
189 foreach ($this->agents as $agent_key => $agent) {
190 foreach ($agent->getMigrations() as $migration) {
194 $key = (new \ReflectionClass($migration))->getShortName();
195 $migrations[$agent_key .
"." . $key] = $migration;
207 $names = explode(
".",
$name);
208 $front = array_shift($names);
209 if (!isset($this->agents[$front])) {
210 throw new \InvalidArgumentException(
211 "Can't find named objective '$name'."
221 return $this->agents[$front]->getNamedObjective(implode(
".", $names),
$config);
222 }
catch (\InvalidArgumentException
$e) {
223 throw new \InvalidArgumentException(
224 "Can't find named objective '$name'.",
233 $names = explode(
"\\", get_class($migration));
234 return array_pop($names);
240 throw new \InvalidArgumentException(
241 "Expected ConfigCollection for configuration."
if(php_sapi_name() !='cli') $in
An exception for terminatinating execution or to throw for unit testing.
An agent that is just a collection of some other agents.
__construct(Refinery $refinery, array $agents)
getKey(Setup\Migration $migration)
getInstallObjective(Config $config=null)
@inheritdocs
withAdditionalAgent(string $key, Agent $agent)
checkConfig(Config $config)
getBuildArtifactObjective()
@inheritdocs
getArrayToConfigTransformation()
@inheritdocs
getUpdateObjective(Config $config=null)
@inheritdocs
getNamedObjective(string $name, Config $config=null)
@inheritDoc
getStatusObjective(Metrics\Storage $storage)
@inheritdocs
withRemovedAgent(string $key)
A collection of some configurations.
A objective collection is a objective that is achieved once all subobjectives are achieved.
A agent is some component that performs part of the setup process.
getMigrations()
Get a named map of migrations available for this Agent.
hasConfig()
Does this agent require a configuration?
getBuildArtifactObjective()
Get the goal the agent wants to achieve to build artifacts.
getStatusObjective(Metrics\Storage $storage)
Get the objective to be achieved when status is requested.
getUpdateObjective(Config $config=null)
Get the goal the agent wants to achieve on update.
A configuration for the setup.
A migration is a potentially long lasting operation that can be broken into discrete steps.
An objective is a desired state of the system that is supposed to be created by the setup.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...