ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 (FieldFactory $field_factory, Refinery $refinery, array $agents)
 
 hasConfig ()
 @inheritdocs More...
 
 getConfigInput (Config $config=null)
 @inheritdocs More...
 
 getArrayToConfigTransformation ()
 @inheritdocs More...
 
 getInstallObjective (Config $config=null)
 @inheritdocs More...
 
 getUpdateObjective (Config $config=null)
 @inheritdocs More...
 
 getBuildArtifactObjective ()
 @inheritdocs More...
 
 hasConfig ()
 Does this agent require a configuration? More...
 
 getConfigInput (Config $config=null)
 Agents must provide an input to set the configuration if they have 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...
 

Protected Member Functions

 getXObjective (string $which, Config $config=null)
 
 checkConfig (Config $config)
 
 getAgentsWithConfig ()
 

Protected Attributes

 $field_factory
 
 $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 ( FieldFactory  $field_factory,
Refinery  $refinery,
array  $agents 
)

Member Function Documentation

◆ checkConfig()

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

Definition at line 153 of file AgentCollection.php.

154 {
155 if (!($config instanceof ConfigCollection)) {
156 throw new \InvalidArgumentException(
157 "Expected ConfigCollection for configuration."
158 );
159 }
160 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68

References $config.

Referenced by ILIAS\Setup\AgentCollection\getConfigInput(), and ILIAS\Setup\AgentCollection\getXObjective().

+ Here is the caller graph for this function:

◆ getAgentsWithConfig()

ILIAS\Setup\AgentCollection::getAgentsWithConfig ( )
protected

Definition at line 162 of file AgentCollection.php.

162 : \Traversable
163 {
164 foreach ($this->agents as $k => $c) {
165 if ($c->hasConfig()) {
166 yield $k => $c;
167 }
168 }
169 }

References Vendor\Package\$c.

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

+ Here is the caller graph for this function:

◆ getArrayToConfigTransformation()

ILIAS\Setup\AgentCollection::getArrayToConfigTransformation ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 87 of file AgentCollection.php.

87 : Transformation
88 {
89 return $this->refinery->in()->series([
90 $this->refinery->custom()->transformation(function ($in) {
91 $out = [];
92 foreach ($this->agents as $key => $agent) {
93 if (!$agent->hasConfig()) {
94 continue;
95 }
96 $val = $in[$key] ?? null;
97 $transformation = $agent->getArrayToConfigTransformation();
98 $out[$key] = $transformation($val);
99 }
100 return $out;
101 }),
102 $this->refinery->custom()->transformation(function ($v) {
103 return [$v];
104 }),
105 $this->refinery->to()->toNew(ConfigCollection::class)
106 ]);
107 }
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 128 of file AgentCollection.php.

128 : Objective
129 {
130 $gs = [];
131 foreach ($this->agents as $k => $c) {
132 $gs[] = $c->getBuildArtifactObjective();
133 }
134 return new ObjectiveCollection("Collected Build Artifact Objectives", false, ...$gs);
135 }

References Vendor\Package\$c.

◆ getConfigInput()

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

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 58 of file AgentCollection.php.

58 : Input
59 {
60 if ($config !== null) {
61 $this->checkConfig($config);
62 }
63
64 $inputs = [];
65 foreach ($this->getAgentsWithConfig() as $k => $c) {
66 if ($config) {
67 $inputs[$k] = $c->getConfigInput($config->getConfig($k));
68 } else {
69 $inputs[$k] = $c->getConfigInput();
70 }
71 }
72
73 return $this->field_factory->group($inputs)
74 ->withAdditionalTransformation(
75 $this->refinery->in()->series([
76 $this->refinery->custom()->transformation(function ($v) {
77 return [$v];
78 }),
79 $this->refinery->to()->toNew(ConfigCollection::class)
80 ])
81 );
82 }

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

+ Here is the call graph for this function:

◆ getInstallObjective()

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

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 112 of file AgentCollection.php.

112 : Objective
113 {
114 return $this->getXObjective("getInstallObjective", $config);
115 }
getXObjective(string $which, Config $config=null)

References $config, and ILIAS\Setup\AgentCollection\getXObjective().

+ Here is the call graph for this function:

◆ getUpdateObjective()

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

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 120 of file AgentCollection.php.

120 : Objective
121 {
122 return $this->getXObjective("getUpdateObjective", $config);
123 }

References $config, and ILIAS\Setup\AgentCollection\getXObjective().

+ Here is the call graph for this function:

◆ getXObjective()

ILIAS\Setup\AgentCollection::getXObjective ( string  $which,
Config  $config = null 
)
protected

Definition at line 137 of file AgentCollection.php.

137 : Objective
138 {
139 $this->checkConfig($config);
140
141 $gs = [];
142 foreach ($this->agents as $k => $c) {
143 if ($c->hasConfig()) {
144 $gs[] = call_user_func([$c, $which], $config->getConfig($k));
145 } else {
146 $gs[] = call_user_func([$c, $which]);
147 }
148 }
149
150 return new ObjectiveCollection("Collected Objectives", false, ...$gs);
151 }

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasConfig()

ILIAS\Setup\AgentCollection::hasConfig ( )

@inheritdocs

Implements ILIAS\Setup\Agent.

Definition at line 45 of file AgentCollection.php.

45 : bool
46 {
47 foreach ($this->agents as $c) {
48 if ($c->hasConfig()) {
49 return true;
50 }
51 }
52 return false;
53 }

References Vendor\Package\$c.

Field Documentation

◆ $agents

ILIAS\Setup\AgentCollection::$agents
protected

Definition at line 30 of file AgentCollection.php.

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

◆ $field_factory

ILIAS\Setup\AgentCollection::$field_factory
protected

Definition at line 20 of file AgentCollection.php.

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

◆ $refinery

ILIAS\Setup\AgentCollection::$refinery
protected

Definition at line 25 of file AgentCollection.php.

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


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