ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 (FieldFactory $field_factory, Refinery $refinery, array $agents)
 
 hasConfig ()
 
 getConfigInput (Config $config=null)
 
 getArrayToConfigTransformation ()
 
 getInstallObjective (Config $config=null)
 
 getUpdateObjective (Config $config=null)
 
 getBuildArtifactObjective ()
 

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.

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

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

◆ getAgentsWithConfig()

ILIAS\Setup\AgentCollection::getAgentsWithConfig ( )
protected

Definition at line 162 of file AgentCollection.php.

References Vendor\Package\$c.

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

162  : \Traversable
163  {
164  foreach ($this->agents as $k => $c) {
165  if ($c->hasConfig()) {
166  yield $k => $c;
167  }
168  }
169  }
+ Here is the caller graph for this function:

◆ getArrayToConfigTransformation()

ILIAS\Setup\AgentCollection::getArrayToConfigTransformation ( )

Implements ILIAS\Setup\Agent.

Definition at line 87 of file AgentCollection.php.

References $in, and $out.

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

◆ getBuildArtifactObjective()

ILIAS\Setup\AgentCollection::getBuildArtifactObjective ( )

Implements ILIAS\Setup\Agent.

Definition at line 128 of file AgentCollection.php.

References Vendor\Package\$c.

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  }

◆ getConfigInput()

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

Implements ILIAS\Setup\Agent.

Definition at line 58 of file AgentCollection.php.

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

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  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
+ Here is the call graph for this function:

◆ getInstallObjective()

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

Implements ILIAS\Setup\Agent.

Definition at line 112 of file AgentCollection.php.

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

112  : Objective
113  {
114  return $this->getXObjective("getInstallObjective", $config);
115  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
getXObjective(string $which, Config $config=null)
+ Here is the call graph for this function:

◆ getUpdateObjective()

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

Implements ILIAS\Setup\Agent.

Definition at line 120 of file AgentCollection.php.

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

120  : Objective
121  {
122  return $this->getXObjective("getUpdateObjective", $config);
123  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
getXObjective(string $which, Config $config=null)
+ 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.

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

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

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  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasConfig()

ILIAS\Setup\AgentCollection::hasConfig ( )

Implements ILIAS\Setup\Agent.

Definition at line 45 of file AgentCollection.php.

References Vendor\Package\$c.

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

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: