ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Setup\AgentCollection Class Reference

An agent that is just a collection of some other agents. More...

+ Inheritance diagram for ILIAS\Setup\AgentCollection:
+ Collaboration diagram for ILIAS\Setup\AgentCollection:

Public Member Functions

 __construct (Refinery $refinery, array $agents)
 
 getAgent (string $key)
 
 withRemovedAgent (string $key)
 
 withAdditionalAgent (string $key, Agent $agent)
 
 hasConfig ()
 @inheritdocs More...
 
 getArrayToConfigTransformation ()
 @inheritdocs More...
 
 getInstallObjective (?Config $config=null)
 @inheritdocs More...
 
 getUpdateObjective (?Config $config=null)
 @inheritdocs More...
 
 getBuildObjective ()
 @inheritdocs More...
 
 getStatusObjective (Metrics\Storage $storage)
 @inheritdocs More...
 
 getAgents ()
 
 getNamedObjectives (?Config $config=null)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\Setup\Agent
 hasConfig ()
 Does this agent require a configuration? More...
 
 getArrayToConfigTransformation ()
 Agents must be able to tell how to create a configuration from a nested array. More...
 
 getInstallObjective (?Config $config=null)
 Get the goals the agent wants to achieve on setup. More...
 
 getUpdateObjective (?Config $config=null)
 Get the goal the agent wants to achieve on update. More...
 
 getBuildObjective ()
 Get the goal the agent wants to achieve to build artifacts. More...
 
 getStatusObjective (Metrics\Storage $storage)
 Get the objective to be achieved when status is requested. More...
 
 getMigrations ()
 Get a named map of migrations available for this Agent. More...
 
 getNamedObjectives (?Config $config=null)
 Gets all named objectives The keys of the returned array are the commands. More...
 

Protected Member Functions

 getKey (Migration $migration)
 
 checkConfig (Config $config)
 

Protected Attributes

Refinery $refinery
 
array $agents
 

Detailed Description

An agent that is just a collection of some other agents.

Definition at line 30 of file AgentCollection.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\AgentCollection::__construct ( Refinery  $refinery,
array  $agents 
)

Definition at line 39 of file AgentCollection.php.

References ILIAS\Setup\AgentCollection\$agents, ILIAS\Setup\AgentCollection\$refinery, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkConfig()

ILIAS\Setup\AgentCollection::checkConfig ( Config  $config)
protected

Definition at line 214 of file AgentCollection.php.

214 : void
215 {
216 if (!($config instanceof ConfigCollection)) {
217 throw new \InvalidArgumentException(
218 "Expected ConfigCollection for configuration."
219 );
220 }
221 }

Referenced by ILIAS\Setup\AgentCollection\getInstallObjective(), ILIAS\Setup\AgentCollection\getNamedObjectives(), and ILIAS\Setup\AgentCollection\getUpdateObjective().

+ Here is the caller graph for this function:

◆ getAgent()

ILIAS\Setup\AgentCollection::getAgent ( string  $key)

Definition at line 47 of file AgentCollection.php.

47 : ?Agent
48 {
49 return $this->agents[$key] ?? null;
50 }
A agent is some component that performs part of the setup process.
Definition: Agent.php:30

◆ getAgents()

ILIAS\Setup\AgentCollection::getAgents ( )
Returns
Agent[]

Definition at line 226 of file AgentCollection.php.

226 : array
227 {
228 return $this->agents;
229 }

References ILIAS\Setup\AgentCollection\$agents.

◆ getArrayToConfigTransformation()

ILIAS\Setup\AgentCollection::getArrayToConfigTransformation ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 85 of file AgentCollection.php.

85 : Transformation
86 {
87 return $this->refinery->in()->series([
88 $this->refinery->custom()->transformation(function ($in): array {
89 $out = [];
90 foreach ($this->agents as $key => $agent) {
91 if (!$agent->hasConfig()) {
92 continue;
93 }
94 $val = $in[$key] ?? null;
95 $transformation = $agent->getArrayToConfigTransformation();
96 $out[$key] = $transformation($val);
97 }
98 return $out;
99 }),
100 $this->refinery->custom()->transformation(fn($v): array => [$v]),
101 $this->refinery->to()->toNew(ConfigCollection::class)
102 ]);
103 }
$out
Definition: buildRTE.php:24

References $out, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getBuildObjective()

ILIAS\Setup\AgentCollection::getBuildObjective ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 159 of file AgentCollection.php.

159 : Objective
160 {
161 return new ObjectiveCollection(
162 "Collected Build Artifact Objectives",
163 false,
164 ...array_values(array_map(
165 fn(Agent $v): \ILIAS\Setup\Objective => $v->getBuildObjective(),
166 $this->agents
167 ))
168 );
169 }
getBuildObjective()
Get the goal the agent wants to achieve to build artifacts.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Setup\Agent\getBuildObjective().

+ Here is the call graph for this function:

◆ getInstallObjective()

ILIAS\Setup\AgentCollection::getInstallObjective ( ?Config  $config = null)

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 108 of file AgentCollection.php.

108 : Objective
109 {
110 if (!is_null($config)) {
111 $this->checkConfig($config);
112 }
113
114 return new ObjectiveCollection(
115 "Collected Install Objectives",
116 false,
117 ...array_values(array_map(
118 function (string $k, Agent $v) use ($config) {
119 if ($v->hasConfig()) {
120 return $v->getInstallObjective($config->getConfig($k));
121 } else {
122 return $v->getInstallObjective();
123 }
124 },
125 array_keys($this->agents),
126 array_values($this->agents)
127 ))
128 );
129 }

References ILIAS\Setup\AgentCollection\checkConfig(), and ILIAS\Setup\Agent\hasConfig().

+ Here is the call graph for this function:

◆ getKey()

ILIAS\Setup\AgentCollection::getKey ( Migration  $migration)
protected

Definition at line 208 of file AgentCollection.php.

208 : string
209 {
210 $names = explode("\\", get_class($migration));
211 return array_pop($names);
212 }

◆ getNamedObjectives()

ILIAS\Setup\AgentCollection::getNamedObjectives ( ?Config  $config = null)

@inheritDoc

Implements ILIAS\Setup\Agent.

Definition at line 232 of file AgentCollection.php.

232 : array
233 {
234 if (!is_null($config)) {
235 $this->checkConfig($config);
236 }
237
239 $namedObjectives = [];
240
241 foreach ($agents as $k => $agent) {
242 if ($config) {
243 $objectives = $agent->getNamedObjectives($config->maybeGetConfig($k));
244 } else {
245 $objectives = $agent->getNamedObjectives();
246 }
247 foreach ($objectives as $name => $constructor) {
248 $namedObjectives["$k.$name"] = $constructor;
249 }
250 }
251
252 ksort($namedObjectives);
253 return $namedObjectives;
254 }
$objectives

References ILIAS\Setup\AgentCollection\$agents, $objectives, and ILIAS\Setup\AgentCollection\checkConfig().

+ Here is the call graph for this function:

◆ getStatusObjective()

ILIAS\Setup\AgentCollection::getStatusObjective ( Metrics\Storage  $storage)

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 174 of file AgentCollection.php.

174 : Objective
175 {
176 return new ObjectiveCollection(
177 "Collected Status Objectives",
178 false,
179 ...array_values(array_map(
180 fn(string $k, Agent $v): \ILIAS\Setup\Objective => $v->getStatusObjective(
181 new Metrics\StorageOnPathWrapper($k, $storage)
182 ),
183 array_keys($this->agents),
184 array_values($this->agents)
185 ))
186 );
187 }
getStatusObjective(Metrics\Storage $storage)
Get the objective to be achieved when status is requested.

References ILIAS\Setup\Agent\getStatusObjective().

+ Here is the call graph for this function:

◆ getUpdateObjective()

ILIAS\Setup\AgentCollection::getUpdateObjective ( ?Config  $config = null)

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 134 of file AgentCollection.php.

134 : Objective
135 {
136 if ($config !== null) {
137 $this->checkConfig($config);
138 }
139
140 return new ObjectiveCollection(
141 "Collected Update Objectives",
142 false,
143 ...array_values(array_map(
144 function (string $k, Agent $v) use ($config): \ILIAS\Setup\Objective {
145 if ($config !== null) {
146 return $v->getUpdateObjective($config->maybeGetConfig($k));
147 }
148 return $v->getUpdateObjective();
149 },
150 array_keys($this->agents),
151 array_values($this->agents)
152 ))
153 );
154 }

References ILIAS\Setup\AgentCollection\checkConfig(), and ILIAS\Setup\Agent\getUpdateObjective().

+ Here is the call graph for this function:

◆ hasConfig()

ILIAS\Setup\AgentCollection::hasConfig ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 72 of file AgentCollection.php.

72 : bool
73 {
74 foreach ($this->agents as $c) {
75 if ($c->hasConfig()) {
76 return true;
77 }
78 }
79 return false;
80 }
$c
Definition: deliver.php:25

References $c.

◆ withAdditionalAgent()

ILIAS\Setup\AgentCollection::withAdditionalAgent ( string  $key,
Agent  $agent 
)

Definition at line 59 of file AgentCollection.php.

59 : AgentCollection
60 {
61 if (isset($this->agents[$key])) {
62 throw new \LogicException("An agent with the name '$key' already exists.");
63 }
64 $clone = clone $this;
65 $clone->agents[$key] = $agent;
66 return $clone;
67 }

◆ withRemovedAgent()

ILIAS\Setup\AgentCollection::withRemovedAgent ( string  $key)

Definition at line 52 of file AgentCollection.php.

52 : AgentCollection
53 {
54 $clone = clone $this;
55 unset($clone->agents[$key]);
56 return $clone;
57 }

Field Documentation

◆ $agents

array ILIAS\Setup\AgentCollection::$agents
protected

◆ $refinery

Refinery ILIAS\Setup\AgentCollection::$refinery
protected

Definition at line 32 of file AgentCollection.php.

Referenced by ILIAS\Setup\AgentCollection\__construct().


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