From 95129735b7048819d4494f6de0ca4b5d21d7d99d Mon Sep 17 00:00:00 2001 From: Richard Klees Date: Mon, 27 Nov 2023 14:19:07 +0100 Subject: [PATCH] Component: define EntryPoints of ILIAS --- cli/hello_world.php | 24 ++++++ components/ILIAS/App/tests/RootFolderTest.php | 1 + components/ILIAS/Component/Component.php | 1 + components/ILIAS/Component/README.md | 6 ++ .../src/Dependencies/OfComponent.php | 11 +++ .../ILIAS/Component/src/Dependencies/Out.php | 5 ++ .../Component/src/Dependencies/Reader.php | 3 + .../Component/src/Dependencies/Renderer.php | 82 ++++++++++++++---- components/ILIAS/Component/src/EntryPoint.php | 37 +++++++++ .../ILIAS/Component/src/EntryPoint/Base.php | 37 +++++++++ .../Component/src/EntryPoint/HelloWorld.php | 37 +++++++++ .../tests/Dependencies/RendererTest.php | 5 ++ .../tests/Dependencies/scenarios/result1.php | 35 +++++--- .../tests/Dependencies/scenarios/result2.php | 55 +++++++----- .../tests/Dependencies/scenarios/result3.php | 55 +++++++----- .../tests/Dependencies/scenarios/result4.php | 83 +++++++++++-------- .../tests/Dependencies/scenarios/result5.php | 48 +++++++++++ .../Dependencies/scenarios/scenario5.php | 52 ++++++++++++ 18 files changed, 475 insertions(+), 102 deletions(-) create mode 100644 cli/hello_world.php create mode 100644 components/ILIAS/Component/src/EntryPoint.php create mode 100644 components/ILIAS/Component/src/EntryPoint/Base.php create mode 100644 components/ILIAS/Component/src/EntryPoint/HelloWorld.php create mode 100644 components/ILIAS/Component/tests/Dependencies/scenarios/result5.php create mode 100644 components/ILIAS/Component/tests/Dependencies/scenarios/scenario5.php diff --git a/cli/hello_world.php b/cli/hello_world.php new file mode 100644 index 000000000000..8323aba43365 --- /dev/null +++ b/cli/hello_world.php @@ -0,0 +1,24 @@ + new Component\EntryPoint\HelloWorld("Component/HelloWorld"); } } 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..c01a69acc78e 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 \$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,50 @@ 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; + } + + return $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..cf656eb7cc10 --- /dev/null +++ b/components/ILIAS/Component/src/EntryPoint.php @@ -0,0 +1,37 @@ +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..a6bbf0d778b6 --- /dev/null +++ b/components/ILIAS/Component/src/EntryPoint/HelloWorld.php @@ -0,0 +1,37 @@ +getName() . "\" says: \"Hello World!\"\n"; + return 0; + } +} 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..acf8fc105503 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result1.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result1.php @@ -16,17 +16,32 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(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 = [ + ]; + + if (!isset($entry_points[$name])) { + throw new \LogicException("Unknown entry point: $name."); + } + + $entry_points[$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php index 21eb301a7e7e..9810eb101199 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result2.php @@ -16,31 +16,46 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(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 = [ + ]; + + if (!isset($entry_points[$name])) { + throw new \LogicException("Unknown entry point: $name."); + } + + $entry_points[$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php index 71ece950dc6a..92ee484017aa 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result3.php @@ -16,31 +16,46 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(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 = [ + ]; + + if (!isset($entry_points[$name])) { + throw new \LogicException("Unknown entry point: $name."); + } + + $entry_points[$name]()->enter(); +} diff --git a/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php b/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php index a0cd888dd37d..5115a9f7c576 100644 --- a/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result4.php @@ -16,50 +16,65 @@ * *********************************************************************/ -$null_dic = new ILIAS\Component\Dependencies\NullDIC(); +require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); +function entry_point(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 = [ ]; -}; -$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[$name])) { + throw new \LogicException("Unknown entry point: $name."); + } + + $entry_points[$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..c7aff075c079 --- /dev/null +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/result5.php @@ -0,0 +1,48 @@ +init($null_dic, $implement_0, $use, $contribute_0, $seek, $provide_0, $pull, $internal); + + + $entry_points = [ + "just a name" => fn() => $contribute_0[ILIAS\Component\EntryPoint::class . "_0"], + ]; + + if (!isset($entry_points[$name])) { + throw new \LogicException("Unknown entry point: $name."); + } + + $entry_points[$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..f25cab47061d --- /dev/null +++ b/components/ILIAS/Component/tests/Dependencies/scenarios/scenario5.php @@ -0,0 +1,52 @@ + new ComponentAEntryPoint(); + } +}