ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Component\Dependencies\Renderer Class Reference

This takes a (hopefully resolved...) dependency tree and renders it in PHP to be used for initialisation. More...

+ Collaboration diagram for ILIAS\Component\Dependencies\Renderer:

Public Member Functions

 render (OfComponent ... $components)
 

Protected Member Functions

 renderHeader ()
 
 renderComponent (array $component_lookup, OfComponent $component)
 
 renderUse (array $component_lookup, OfComponent $component)
 
 renderSeek (array $component_lookup, OfComponent $component)
 
 renderPull (array $component_lookup, OfComponent $component)
 
 renderEntryPointsSection (array $component_lookup, OfComponent ... $components)
 
 renderEntryPoints (int $me, OfComponent $component)
 

Detailed Description

This takes a (hopefully resolved...) dependency tree and renders it in PHP to be used for initialisation.

Definition at line 27 of file Renderer.php.

Member Function Documentation

◆ render()

ILIAS\Component\Dependencies\Renderer::render ( OfComponent ...  $components)

Definition at line 29 of file Renderer.php.

29 : string
30 {
31 $component_lookup = array_flip(
32 array_map(
33 fn($c) => $c->getComponentName(),
35 )
36 );
37
38 return
39 $this->renderHeader() .
40 join("\n", array_map(
41 fn($c) => $this->renderComponent($component_lookup, $c),
43 )) .
44 $this->renderEntryPointsSection($component_lookup, ...$components);
45 }
$components
renderComponent(array $component_lookup, OfComponent $component)
Definition: Renderer.php:67
renderEntryPointsSection(array $component_lookup, OfComponent ... $components)
Definition: Renderer.php:141
$c
Definition: deliver.php:25

References $c, $components, ILIAS\Component\Dependencies\Renderer\renderComponent(), ILIAS\Component\Dependencies\Renderer\renderEntryPointsSection(), and ILIAS\Component\Dependencies\Renderer\renderHeader().

+ Here is the call graph for this function:

◆ renderComponent()

ILIAS\Component\Dependencies\Renderer::renderComponent ( array  $component_lookup,
OfComponent  $component 
)
protected

Definition at line 67 of file Renderer.php.

70 : int
71{
72 \$null_dic = new ILIAS\Component\Dependencies\NullDIC();
73 \$implement = new Pimple\Container();
74 \$contribute = new Pimple\Container();
75 \$provide = new Pimple\Container();
76
77
78PHP;
79 }
80
81 protected function renderComponent(array $component_lookup, OfComponent $component): string
82 {
83 $me = $component_lookup[$component->getComponentName()];
84 $use = $this->renderUse($component_lookup, $component);
85 $seek = $this->renderSeek($component_lookup, $component);
86 $pull = $this->renderPull($component_lookup, $component);
87 return <<<PHP
88
An object that looks like a Dependency Injection Container but actually does nothing.
Definition: NullDIC.php:28
renderPull(array $component_lookup, OfComponent $component)
Definition: Renderer.php:128
renderSeek(array $component_lookup, OfComponent $component)
Definition: Renderer.php:104
renderUse(array $component_lookup, OfComponent $component)
Definition: Renderer.php:90

Referenced by ILIAS\Component\Dependencies\Renderer\render(), and ILIAS\Component\Dependencies\Renderer\renderHeader().

+ Here is the caller graph for this function:

◆ renderEntryPoints()

ILIAS\Component\Dependencies\Renderer::renderEntryPoints ( int  $me,
OfComponent  $component 
)
protected

Definition at line 164 of file Renderer.php.

165 {$entry_points}
166 ];
167
168 if (!isset(\$entry_points[\$name])) {
169 throw new \\LogicException("Unknown entry point: \$name.");
170 }
171
172 return \$entry_points[\$name]()->enter();
173}
174
175PHP;
176 }
177
178 protected function renderEntryPoints(int $me, OfComponent $component): string
179 {
180 $entry_points = "";
renderEntryPoints(int $me, OfComponent $component)
Definition: Renderer.php:164

◆ renderEntryPointsSection()

ILIAS\Component\Dependencies\Renderer::renderEntryPointsSection ( array  $component_lookup,
OfComponent ...  $components 
)
protected

Definition at line 141 of file Renderer.php.

142 : string
143 {
144 $pull = "";
145 foreach ($component->getInDependenciesOf(InType::PULL) as $in) {
146 $r = $in->getResolvedBy()[0];
147 $o = $component_lookup[$r->getComponent()->getComponentName()];
148 $pull .= "\n" . <<<PHP
149 \$pull[{$in->getName()}::class] = fn() => \$provide[{$o}][{$r->getName()}::class];
150PHP;
151 }
152 return $pull;
153 }
154
155 protected function renderEntryPointsSection(array $component_lookup, OfComponent ...$components): string
156 {
157 $entry_points = "";
158 foreach ($components as $component) {
159 $p = $component_lookup[$component->getComponentName()];
160 $entry_points .= $this->renderEntryPoints($p, $component);
161 }
162 return <<<PHP

References ILIAS\Component\Dependencies\OfComponent\getInDependenciesOf().

Referenced by ILIAS\Component\Dependencies\Renderer\render().

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

◆ renderHeader()

ILIAS\Component\Dependencies\Renderer::renderHeader ( )
protected

◆ renderPull()

ILIAS\Component\Dependencies\Renderer::renderPull ( array  $component_lookup,
OfComponent  $component 
)
protected

Definition at line 128 of file Renderer.php.

128 {$o}";
129 $a .= "\n" . <<<PHP
130 \$contribute[$o][{$r->getName()}::class . "_{$p}"],
131PHP;
132 }
133 $u = join(", ", array_unique($u));
134 $seek .= "\n" . <<<PHP
135 \$seek[{$in->getName()}::class] = fn() => [{$a}
136 ];
137PHP;
138 }
139 return $seek;

Referenced by ILIAS\Component\Dependencies\Renderer\renderHeader().

+ Here is the caller graph for this function:

◆ renderSeek()

ILIAS\Component\Dependencies\Renderer::renderSeek ( array  $component_lookup,
OfComponent  $component 
)
protected

Definition at line 104 of file Renderer.php.

104 : string
105 {
106 $use = "";
107 foreach ($component->getInDependenciesOf(InType::USE) as $in) {
108 $r = $in->getResolvedBy()[0];
109 $p = $r->aux["position"];
110 $o = $component_lookup[$r->getComponent()->getComponentName()];
111 $use .= "\n" . <<<PHP
112 \$use[{$in->getName()}::class] = fn() => \$implement[{$o}][{$r->getName()}::class . "_{$p}"];
113PHP;
114 }
115 return $use;
116 }
117
118 protected function renderSeek(array $component_lookup, OfComponent $component): string
119 {
120 $seek = "";
121 foreach ($component->getInDependenciesOf(InType::SEEK) as $in) {
122 $rs = $in->getResolvedBy();
123 $u = [];
124 $a = "";
125 foreach ($rs as $r) {
126 $p = $r->aux["position"];
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References ILIAS\Component\Dependencies\OfComponent\getInDependenciesOf().

Referenced by ILIAS\Component\Dependencies\Renderer\renderHeader().

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

◆ renderUse()

ILIAS\Component\Dependencies\Renderer::renderUse ( array  $component_lookup,
OfComponent  $component 
)
protected

Definition at line 90 of file Renderer.php.

92 {$use}
93 \$contribute[$me] = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container());
94 \$seek = new Pimple\Container();{$seek}
95 \$provide[$me] = new Pimple\Container();
96 \$pull = new Pimple\Container();{$pull}
97 \$internal = new Pimple\Container();
98
99 \$component_{$me}->init(\$null_dic, \$implement[$me], \$use, \$contribute[$me], \$seek, \$provide[$me], \$pull, \$internal);
100
101PHP;
102 }
A wrapper around another DIC that superficially adds a _# and passes them to an underlying DIC.
Definition: RenamingDIC.php:29

Referenced by ILIAS\Component\Dependencies\Renderer\renderHeader().

+ Here is the caller graph for this function:

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