ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 getBuildArtifactObjective ()
 @inheritdocs More...
 
 getStatusObjective (Metrics\Storage $storage)
 @inheritdocs More...
 
 getNamedObjective (string $name, 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...
 
 getBuildArtifactObjective ()
 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...
 
 getNamedObjective (string $name, Config $config=null)
 Get a named objective from 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 
)

Member Function Documentation

◆ checkConfig()

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

Definition at line 237 of file AgentCollection.php.

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

References $config.

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

+ 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 }
A agent is some component that performs part of the setup process.
Definition: Agent.php:14

◆ getArrayToConfigTransformation()

ILIAS\Setup\AgentCollection::getArrayToConfigTransformation ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 73 of file AgentCollection.php.

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

References $in, and $out.

◆ getBuildArtifactObjective()

ILIAS\Setup\AgentCollection::getBuildArtifactObjective ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 149 of file AgentCollection.php.

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 }
getBuildArtifactObjective()
Get the goal the agent wants to achieve to build artifacts.

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

+ Here is the call graph for this function:

◆ getInstallObjective()

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

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 98 of file AgentCollection.php.

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 }

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

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

@inheritDoc

Implements ILIAS\Setup\Agent.

Definition at line 205 of file AgentCollection.php.

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($format !==null) $name
Definition: metadata.php:230

References $config, Vendor\Package\$e, $name, 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 166 of file AgentCollection.php.

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 }
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 124 of file AgentCollection.php.

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 }

References $config, 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 60 of file AgentCollection.php.

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

References $c.

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