ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 getArrayToConfigTransformation ()
 
 getInstallObjective (?Config $config=null)
 
 getUpdateObjective (?Config $config=null)
 
 getBuildObjective ()
 
 getStatusObjective (Metrics\Storage $storage)
 
 getAgents ()
 
 getNamedObjectives (?Config $config=null)
 

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().

42  {
43  $this->refinery = $refinery;
44  $this->agents = $agents;
45  }
+ 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.

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

214  : void
215  {
216  if (!($config instanceof ConfigCollection)) {
217  throw new \InvalidArgumentException(
218  "Expected ConfigCollection for configuration."
219  );
220  }
221  }
+ Here is the caller graph for this function:

◆ getAgent()

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

Definition at line 47 of file AgentCollection.php.

References null.

47  : ?Agent
48  {
49  return $this->agents[$key] ?? null;
50  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getAgents()

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

Definition at line 226 of file AgentCollection.php.

References ILIAS\Setup\AgentCollection\$agents.

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

◆ getArrayToConfigTransformation()

ILIAS\Setup\AgentCollection::getArrayToConfigTransformation ( )

Definition at line 85 of file AgentCollection.php.

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$out
Definition: buildRTE.php:24
+ Here is the call graph for this function:

◆ getBuildObjective()

ILIAS\Setup\AgentCollection::getBuildObjective ( )

Definition at line 159 of file AgentCollection.php.

References ILIAS\Setup\AgentCollection\$agents, and ILIAS\Setup\Agent\getBuildObjective().

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(),
167  ))
168  );
169  }
Interface Observer Contains several chained tasks and infos about them.
+ Here is the call graph for this function:

◆ getInstallObjective()

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

Definition at line 108 of file AgentCollection.php.

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

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  }
+ 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)

Definition at line 232 of file AgentCollection.php.

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

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
+ Here is the call graph for this function:

◆ getStatusObjective()

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

Definition at line 174 of file AgentCollection.php.

References ILIAS\Setup\Agent\getMigrations(), and ILIAS\Setup\Agent\getStatusObjective().

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  }
Interface Observer Contains several chained tasks and infos about them.
+ Here is the call graph for this function:

◆ getUpdateObjective()

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

Definition at line 134 of file AgentCollection.php.

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

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  }
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ hasConfig()

ILIAS\Setup\AgentCollection::hasConfig ( )

Definition at line 72 of file AgentCollection.php.

References $c.

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

◆ 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

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