diff --git a/cli/hello_world.php b/cli/hello_world.php new file mode 100644 index 000000000000..82febb9218fe --- /dev/null +++ b/cli/hello_world.php @@ -0,0 +1,24 @@ + new Component\EntryPoint\HelloWorld($this); } } diff --git a/components/ILIAS/Component/README.md b/components/ILIAS/Component/README.md index c92ca74c5774..50638a21d062 100644 --- a/components/ILIAS/Component/README.md +++ b/components/ILIAS/Component/README.md @@ -5,6 +5,12 @@ how the system is initialized and how components integrate with each other. The schema implemented here is described in [this paper](docs/development/components-and-directories.md). +## Core Concepts + +### Component + +### Entrypoint + ## Why don't you use Immutable Objects in Dependencies The dependencies of the components define a graph. That graph is read by analyzing diff --git a/components/ILIAS/Component/src/Dependencies/OfComponent.php b/components/ILIAS/Component/src/Dependencies/OfComponent.php index be41915c5a70..50a76cf2d749 100644 --- a/components/ILIAS/Component/src/Dependencies/OfComponent.php +++ b/components/ILIAS/Component/src/Dependencies/OfComponent.php @@ -74,6 +74,17 @@ public function getInDependenciesOf(InType $type): \Iterator } } + public function getOutDependenciesOf(OutType $type): \Iterator + { + foreach ($this->dependencies as $d) { + foreach ($d as $o) { + if ($o instanceof Out && $o->getType() === $type) { + yield $o; + } + } + } + } + // ArrayAccess public function offsetExists($dependency_description): bool diff --git a/components/ILIAS/Component/src/Dependencies/Out.php b/components/ILIAS/Component/src/Dependencies/Out.php index c70c2c4c1c6a..0a478e27edcd 100644 --- a/components/ILIAS/Component/src/Dependencies/Out.php +++ b/components/ILIAS/Component/src/Dependencies/Out.php @@ -51,6 +51,11 @@ public function __toString(): string return $this->type->value . ": " . $this->name; } + public function getType(): OutType + { + return $this->type; + } + public function getName(): string { return (string) $this->name; diff --git a/components/ILIAS/Component/src/Dependencies/Reader.php b/components/ILIAS/Component/src/Dependencies/Reader.php index bd1e54d973ac..320c66bfe6f5 100644 --- a/components/ILIAS/Component/src/Dependencies/Reader.php +++ b/components/ILIAS/Component/src/Dependencies/Reader.php @@ -151,6 +151,9 @@ protected function addContribute(int $i, string $name, $value) $aux = [ "position" => $i ]; + if ($impl instanceof \ILIAS\Component\EntryPoint) { + $aux["entry_point_name"] = $impl->getName(); + } $d = new Out(OutType::CONTRIBUTE, $name, $aux, $dependencies); $this->contributes[$i] = $d; } diff --git a/components/ILIAS/Component/src/Dependencies/Renderer.php b/components/ILIAS/Component/src/Dependencies/Renderer.php index d2613714de99..fe028a5adf46 100644 --- a/components/ILIAS/Component/src/Dependencies/Renderer.php +++ b/components/ILIAS/Component/src/Dependencies/Renderer.php @@ -40,7 +40,8 @@ public function render(OfComponent ...$components): string join("\n", array_map( fn($c) => $this->renderComponent($component_lookup, $c), $components - )); + )) . + $this->renderEntryPointsSection($component_lookup, ...$components); } protected function renderHeader(): string @@ -64,7 +65,11 @@ protected function renderHeader(): string * *********************************************************************/ -\$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); + +function entry_point(string \$component, string \$name) +{ + \$null_dic = new ILIAS\Component\Dependencies\NullDIC(); PHP; @@ -78,17 +83,17 @@ protected function renderComponent(array $component_lookup, OfComponent $compone $pull = $this->renderPull($component_lookup, $component); return <<getComponentName()}(); + \$component_$me = new {$component->getComponentName()}(); -\$implement_$me = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -\$use = new Pimple\Container();{$use} -\$contribute_$me = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -\$seek = new Pimple\Container();{$seek} -\$provide_$me = new Pimple\Container(); -\$pull = new Pimple\Container();{$pull} -\$internal = new Pimple\Container(); + \$implement_$me = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + \$use = new Pimple\Container();{$use} + \$contribute_$me = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + \$seek = new Pimple\Container();{$seek} + \$provide_$me = new Pimple\Container(); + \$pull = new Pimple\Container();{$pull} + \$internal = new Pimple\Container(); -\$component_{$me}->init(\$null_dic, \$implement_$me, \$use, \$contribute_$me, \$seek, \$provide_$me, \$pull, \$internal); + \$component_{$me}->init(\$null_dic, \$implement_$me, \$use, \$contribute_$me, \$seek, \$provide_$me, \$pull, \$internal); PHP; } @@ -101,7 +106,7 @@ protected function renderUse(array $component_lookup, OfComponent $component): s $p = $r->aux["position"]; $o = $component_lookup[$r->getComponent()->getComponentName()]; $use .= "\n" . <<getName()}::class] = fn() => \$implement_{$o}[{$r->getName()}::class . "_{$p}"]; + \$use[{$in->getName()}::class] = fn() => \$implement_{$o}[{$r->getName()}::class . "_{$p}"]; PHP; } return $use; @@ -119,15 +124,15 @@ protected function renderSeek(array $component_lookup, OfComponent $component): $o = $component_lookup[$r->getComponent()->getComponentName()]; $u[] = "\$contribute_{$o}"; $a .= "\n" . <<getName()}::class . "_{$p}"], + \$contribute_{$o}[{$r->getName()}::class . "_{$p}"], PHP; } $u = join(", ", array_unique($u)); $seek .= "\n" . <<getName()}::class] = function () use ({$u}) { - return [{$a} - ]; -}; + \$seek[{$in->getName()}::class] = function () use ({$u}) { + return [{$a} + ]; + }; PHP; } return $seek; @@ -140,9 +145,55 @@ protected function renderPull(array $component_lookup, OfComponent $component): $r = $in->getResolvedBy()[0]; $o = $component_lookup[$r->getComponent()->getComponentName()]; $pull .= "\n" . <<getName()}::class] = fn() => \$provide_{$o}[{$r->getName()}::class]; + \$pull[{$in->getName()}::class] = fn() => \$provide_{$o}[{$r->getName()}::class]; PHP; } return $pull; } + + protected function renderEntryPointsSection(array $component_lookup, OfComponent ...$components): string + { + $entry_points = ""; + foreach ($components as $component) { + $p = $component_lookup[$component->getComponentName()]; + $entry_points .= $this->renderEntryPoints($p, $component); + } + return <<enter(); +} + +PHP; + } + + protected function renderEntryPoints(int $me, OfComponent $component): string + { + $entry_points = ""; + foreach ($component->getOutDependenciesOf(OutType::CONTRIBUTE) as $out) { + if ($out->getName() !== \ILIAS\Component\EntryPoint::class) { + continue; + } + $p = $out->aux["position"]; + $n = str_replace("\"", "\\\"", $out->aux["entry_point_name"]); + $entry_points .= "\n" . << fn() => \$contribute_{$me}[ILIAS\Component\EntryPoint::class . "_{$p}"], +PHP; + } + + if (strlen($entry_points) > 0) { + $entry_points .= "\n "; + } + + return "\n" . <<getComponentName()}::class => [{$entry_points}], +PHP; + } } diff --git a/components/ILIAS/Component/src/EntryPoint.php b/components/ILIAS/Component/src/EntryPoint.php new file mode 100644 index 000000000000..897318ae5daf --- /dev/null +++ b/components/ILIAS/Component/src/EntryPoint.php @@ -0,0 +1,36 @@ +component; + } + + public function getName(): string + { + return $this->name; + } +} diff --git a/components/ILIAS/Component/src/EntryPoint/HelloWorld.php b/components/ILIAS/Component/src/EntryPoint/HelloWorld.php new file mode 100644 index 000000000000..bb30ee5af047 --- /dev/null +++ b/components/ILIAS/Component/src/EntryPoint/HelloWorld.php @@ -0,0 +1,44 @@ +getComponent()) . ", entry point " . $this->getName() . ": \"Hello World!\"\n"; + } +} diff --git a/components/ILIAS/Component/tests/Dependencies/RendererTest.php b/components/ILIAS/Component/tests/Dependencies/RendererTest.php index 755786bfd466..e9d95652ac19 100644 --- a/components/ILIAS/Component/tests/Dependencies/RendererTest.php +++ b/components/ILIAS/Component/tests/Dependencies/RendererTest.php @@ -81,6 +81,11 @@ public function scenarios() \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentB::class, \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentC::class ] + ], + "render entry points" => ["scenario5.php", "result5.php", + [ + \ILIAS\Component\Tests\Dependencies\Scenario5\ComponentA::class + ] ] ]; } diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result1.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result1.php index 1c9e89d0fd4c..7b918e9ee6ad 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result1.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result1.php @@ -16,17 +16,33 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(string $component, string $name) +{ + $null_dic = new ILIAS\Component\Dependencies\NullDIC(); -$component_0 = new ILIAS\Component\Tests\Dependencies\Scenario1\ComponentA(); -$implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_0 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); + $component_0 = new ILIAS\Component\Tests\Dependencies\Scenario1\ComponentA(); -$component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + $implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_0 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + + $component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + + + $entry_points = [ + ILIAS\Component\Tests\Dependencies\Scenario1\ComponentA::class => [], + ]; + + if (!isset($entry_points[$component]) || !isset($entry_points[$component][$name])) { + throw new \LogicException("Unknown entry point: $component/$name."); + } + + $entry_points[$component][$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php index 21eb301a7e7e..d834fd5ec9c2 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php @@ -16,31 +16,48 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(string $component, string $name) +{ + $null_dic = new ILIAS\Component\Dependencies\NullDIC(); -$component_0 = new ILIAS\Component\Tests\Dependencies\Scenario2\ComponentA(); -$implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_0 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); + $component_0 = new ILIAS\Component\Tests\Dependencies\Scenario2\ComponentA(); -$component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + $implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_0 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + $component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); -$component_1 = new ILIAS\Component\Tests\Dependencies\Scenario2\ComponentB(); -$implement_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_1 = new Pimple\Container(); -$pull = new Pimple\Container(); -$pull[ILIAS\Component\Tests\Dependencies\Scenario2\Provides::class] = fn() => $provide_0[ILIAS\Component\Tests\Dependencies\Scenario2\Provides::class]; -$internal = new Pimple\Container(); + $component_1 = new ILIAS\Component\Tests\Dependencies\Scenario2\ComponentB(); -$component_1->init($null_dic, $implement_1, $use, $contribute_1, $seek, $provide_1, $pull, $internal); + $implement_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_1 = new Pimple\Container(); + $pull = new Pimple\Container(); + $pull[ILIAS\Component\Tests\Dependencies\Scenario2\Provides::class] = fn() => $provide_0[ILIAS\Component\Tests\Dependencies\Scenario2\Provides::class]; + $internal = new Pimple\Container(); + + $component_1->init($null_dic, $implement_1, $use, $contribute_1, $seek, $provide_1, $pull, $internal); + + + $entry_points = [ + ILIAS\Component\Tests\Dependencies\Scenario2\ComponentA::class => [], + ILIAS\Component\Tests\Dependencies\Scenario2\ComponentB::class => [], + ]; + + if (!isset($entry_points[$component]) || !isset($entry_points[$component][$name])) { + throw new \LogicException("Unknown entry point: $component/$name."); + } + + $entry_points[$component][$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php index 71ece950dc6a..f4c7a74601e0 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php @@ -16,31 +16,48 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(string $component, string $name) +{ + $null_dic = new ILIAS\Component\Dependencies\NullDIC(); -$component_0 = new ILIAS\Component\Tests\Dependencies\Scenario3\ComponentA(); -$implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_0 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); + $component_0 = new ILIAS\Component\Tests\Dependencies\Scenario3\ComponentA(); -$component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + $implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_0 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + $component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); -$component_1 = new ILIAS\Component\Tests\Dependencies\Scenario3\ComponentB(); -$implement_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$use[ILIAS\Component\Tests\Dependencies\Scenario3\Service::class] = fn() => $implement_0[ILIAS\Component\Tests\Dependencies\Scenario3\Service::class . "_0"]; -$contribute_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_1 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); + $component_1 = new ILIAS\Component\Tests\Dependencies\Scenario3\ComponentB(); -$component_1->init($null_dic, $implement_1, $use, $contribute_1, $seek, $provide_1, $pull, $internal); + $implement_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $use[ILIAS\Component\Tests\Dependencies\Scenario3\Service::class] = fn() => $implement_0[ILIAS\Component\Tests\Dependencies\Scenario3\Service::class . "_0"]; + $contribute_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_1 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + + $component_1->init($null_dic, $implement_1, $use, $contribute_1, $seek, $provide_1, $pull, $internal); + + + $entry_points = [ + ILIAS\Component\Tests\Dependencies\Scenario3\ComponentA::class => [], + ILIAS\Component\Tests\Dependencies\Scenario3\ComponentB::class => [], + ]; + + if (!isset($entry_points[$component]) || !isset($entry_points[$component][$name])) { + throw new \LogicException("Unknown entry point: $component/$name."); + } + + $entry_points[$component][$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php index a0cd888dd37d..d64c23e1fb53 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php @@ -16,50 +16,68 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(string $component, string $name) +{ + $null_dic = new ILIAS\Component\Dependencies\NullDIC(); -$component_0 = new ILIAS\Component\Tests\Dependencies\Scenario4\ComponentA(); -$implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_0 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); + $component_0 = new ILIAS\Component\Tests\Dependencies\Scenario4\ComponentA(); -$component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + $implement_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_0 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_0 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + $component_0->init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); -$component_1 = new ILIAS\Component\Tests\Dependencies\Scenario4\ComponentB(); -$implement_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$provide_1 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); + $component_1 = new ILIAS\Component\Tests\Dependencies\Scenario4\ComponentB(); -$component_1->init($null_dic, $implement_1, $use, $contribute_1, $seek, $provide_1, $pull, $internal); + $implement_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_1 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $provide_1 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + $component_1->init($null_dic, $implement_1, $use, $contribute_1, $seek, $provide_1, $pull, $internal); -$component_2 = new ILIAS\Component\Tests\Dependencies\Scenario4\ComponentC(); -$implement_2 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$use = new Pimple\Container(); -$contribute_2 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); -$seek = new Pimple\Container(); -$seek[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class] = function () use ($contribute_0, $contribute_1) { - return [ - $contribute_0[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class . "_0"], - $contribute_1[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class . "_0"], - $contribute_1[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class . "_1"], + $component_2 = new ILIAS\Component\Tests\Dependencies\Scenario4\ComponentC(); + + $implement_2 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $use = new Pimple\Container(); + $contribute_2 = new ILIAS\Component\Dependencies\RenamingDIC(new Pimple\Container()); + $seek = new Pimple\Container(); + $seek[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class] = function () use ($contribute_0, $contribute_1) { + return [ + $contribute_0[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class . "_0"], + $contribute_1[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class . "_0"], + $contribute_1[ILIAS\Component\Tests\Dependencies\Scenario4\Contribution::class . "_1"], + ]; + }; + $provide_2 = new Pimple\Container(); + $pull = new Pimple\Container(); + $internal = new Pimple\Container(); + + $component_2->init($null_dic, $implement_2, $use, $contribute_2, $seek, $provide_2, $pull, $internal); + + + $entry_points = [ + ILIAS\Component\Tests\Dependencies\Scenario4\ComponentA::class => [], + ILIAS\Component\Tests\Dependencies\Scenario4\ComponentB::class => [], + ILIAS\Component\Tests\Dependencies\Scenario4\ComponentC::class => [], ]; -}; -$provide_2 = new Pimple\Container(); -$pull = new Pimple\Container(); -$internal = new Pimple\Container(); -$component_2->init($null_dic, $implement_2, $use, $contribute_2, $seek, $provide_2, $pull, $internal); + if (!isset($entry_points[$component]) || !isset($entry_points[$component][$name])) { + throw new \LogicException("Unknown entry point: $component/$name."); + } + + $entry_points[$component][$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result5.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result5.php new file mode 100644 index 000000000000..822be1bfd1a2 --- /dev/null +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result5.php @@ -0,0 +1,50 @@ +init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + + + $entry_points = [ + ILIAS\Component\Tests\Dependencies\Scenario5\ComponentA::class => [ + "just a name" => fn() => $contribute_0[ILIAS\Component\EntryPoint::class . "_0"], + ], + ]; + + if (!isset($entry_points[$component]) || !isset($entry_points[$component][$name])) { + throw new \LogicException("Unknown entry point: $component/$name."); + } + + $entry_points[$component][$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/scenario5.php b/components/ILIAS/Component/tests/Dependencies/scenarios/scenario5.php new file mode 100644 index 000000000000..3c6ed81ea917 --- /dev/null +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/scenario5.php @@ -0,0 +1,52 @@ + new ComponentAEntryPoint(); + } +}