ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables 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)
 
 getBuildArtifactObjective ()
 
 getStatusObjective (Metrics\Storage $storage)
 
 getNamedObjective (string $name, Config $config=null)
 
- Public Member Functions inherited from ILIAS\Setup\Agent
 getMigrations ()
 Get a named map of migrations available for this Agent. More...
 

Protected Member Functions

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

Protected Attributes

 $refinery
 
 $agents
 

Detailed Description

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

Definition at line 15 of file AgentCollection.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 27 of file AgentCollection.php.

References ILIAS\Setup\AgentCollection\$agents, and ILIAS\Setup\AgentCollection\$refinery.

30  {
31  $this->refinery = $refinery;
32  $this->agents = $agents;
33  }

Member Function Documentation

◆ checkConfig()

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

Definition at line 237 of file AgentCollection.php.

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

238  {
239  if (!($config instanceof ConfigCollection)) {
240  throw new \InvalidArgumentException(
241  "Expected ConfigCollection for configuration."
242  );
243  }
244  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
+ Here is the caller graph for this function:

◆ getAgent()

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

Definition at line 35 of file AgentCollection.php.

35  : ?Agent
36  {
37  return $this->agents[$key] ?? null;
38  }

◆ getArrayToConfigTransformation()

ILIAS\Setup\AgentCollection::getArrayToConfigTransformation ( )

Implements ILIAS\Setup\Agent.

Definition at line 73 of file AgentCollection.php.

References $in, and $out.

73  : Transformation
74  {
75  return $this->refinery->in()->series([
76  $this->refinery->custom()->transformation(function ($in) {
77  $out = [];
78  foreach ($this->agents as $key => $agent) {
79  if (!$agent->hasConfig()) {
80  continue;
81  }
82  $val = $in[$key] ?? null;
83  $transformation = $agent->getArrayToConfigTransformation();
84  $out[$key] = $transformation($val);
85  }
86  return $out;
87  }),
88  $this->refinery->custom()->transformation(function ($v) {
89  return [$v];
90  }),
91  $this->refinery->to()->toNew(ConfigCollection::class)
92  ]);
93  }
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ getBuildArtifactObjective()

ILIAS\Setup\AgentCollection::getBuildArtifactObjective ( )

Implements ILIAS\Setup\Agent.

Definition at line 149 of file AgentCollection.php.

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

149  : Objective
150  {
151  return new ObjectiveCollection(
152  "Collected Build Artifact Objectives",
153  false,
154  ...array_values(array_map(
155  function (Agent $v) {
156  return $v->getBuildArtifactObjective();
157  },
159  ))
160  );
161  }
+ Here is the call graph for this function:

◆ getInstallObjective()

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

Implements ILIAS\Setup\Agent.

Definition at line 98 of file AgentCollection.php.

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

98  : Objective
99  {
100  if (!is_null($config)) {
101  $this->checkConfig($config);
102  }
103 
104  return new ObjectiveCollection(
105  "Collected Install Objectives",
106  false,
107  ...array_values(array_map(
108  function (string $k, Agent $v) use ($config) {
109  if ($v->hasConfig()) {
110  return $v->getInstallObjective($config->getConfig($k));
111  } else {
112  return $v->getInstallObjective();
113  }
114  },
115  array_keys($this->agents),
116  array_values($this->agents)
117  ))
118  );
119  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
+ Here is the call graph for this function:

◆ getKey()

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

Definition at line 231 of file AgentCollection.php.

231  : string
232  {
233  $names = explode("\\", get_class($migration));
234  return array_pop($names);
235  }

◆ getNamedObjective()

ILIAS\Setup\AgentCollection::getNamedObjective ( string  $name,
Config  $config = null 
)

Implements ILIAS\Setup\Agent.

Definition at line 205 of file AgentCollection.php.

References $config, Vendor\Package\$e, and ILIAS\Setup\AgentCollection\checkConfig().

205  : Objective
206  {
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'."
212  );
213  }
214 
215  if ($config) {
216  $this->checkConfig($config);
217  $config = $config->maybeGetConfig($front);
218  }
219 
220  try {
221  return $this->agents[$front]->getNamedObjective(implode(".", $names), $config);
222  } catch (\InvalidArgumentException $e) {
223  throw new \InvalidArgumentException(
224  "Can't find named objective '$name'.",
225  0,
226  $e
227  );
228  }
229  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ getStatusObjective()

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

Implements ILIAS\Setup\Agent.

Definition at line 166 of file AgentCollection.php.

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

166  : Objective
167  {
168  return new ObjectiveCollection(
169  "Collected Status Objectives",
170  false,
171  ...array_values(array_map(
172  function (string $k, Agent $v) use ($storage) {
173  return $v->getStatusObjective(
174  new Metrics\StorageOnPathWrapper($k, $storage)
175  );
176  },
177  array_keys($this->agents),
178  array_values($this->agents)
179  ))
180  );
181  }
+ Here is the call graph for this function:

◆ getUpdateObjective()

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

Implements ILIAS\Setup\Agent.

Definition at line 124 of file AgentCollection.php.

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

124  : Objective
125  {
126  if ($config) {
127  $this->checkConfig($config);
128  }
129 
130  return new ObjectiveCollection(
131  "Collected Update Objectives",
132  false,
133  ...array_values(array_map(
134  function (string $k, Agent $v) use ($config) {
135  if ($config) {
136  return $v->getUpdateObjective($config->maybeGetConfig($k));
137  }
138  return $v->getUpdateObjective();
139  },
140  array_keys($this->agents),
141  array_values($this->agents)
142  ))
143  );
144  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
+ Here is the call graph for this function:

◆ hasConfig()

ILIAS\Setup\AgentCollection::hasConfig ( )

Implements ILIAS\Setup\Agent.

Definition at line 60 of file AgentCollection.php.

References $c.

60  : bool
61  {
62  foreach ($this->agents as $c) {
63  if ($c->hasConfig()) {
64  return true;
65  }
66  }
67  return false;
68  }
$c
Definition: cli.php:37

◆ withAdditionalAgent()

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

Definition at line 47 of file AgentCollection.php.

47  : AgentCollection
48  {
49  if (isset($this->agents[$key])) {
50  throw new \LogicException("An agent with the name '$key' already exists.");
51  }
52  $clone = clone $this;
53  $clone->agents[$key] = $agent;
54  return $clone;
55  }

◆ withRemovedAgent()

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

Definition at line 40 of file AgentCollection.php.

40  : AgentCollection
41  {
42  $clone = clone $this;
43  unset($clone->agents[$key]);
44  return $clone;
45  }

Field Documentation

◆ $agents

ILIAS\Setup\AgentCollection::$agents
protected

◆ $refinery

ILIAS\Setup\AgentCollection::$refinery
protected

Definition at line 20 of file AgentCollection.php.

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


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