From 32f77ed24dec719ca5af3e8f81b9691b1cc31102 Mon Sep 17 00:00:00 2001 From: Fabian Wolf Date: Fri, 6 Dec 2024 18:04:40 +0100 Subject: [PATCH] Fix root path of AbstractOfFinder and plugins path of ImplementationOfAgentFinder --- .../ILIAS/Setup/src/AbstractOfFinder.php | 20 +++++++++---------- .../Setup/src/ImplementationOfAgentFinder.php | 5 +---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/components/ILIAS/Setup/src/AbstractOfFinder.php b/components/ILIAS/Setup/src/AbstractOfFinder.php index a1c3175b8460..e35c904eab7b 100755 --- a/components/ILIAS/Setup/src/AbstractOfFinder.php +++ b/components/ILIAS/Setup/src/AbstractOfFinder.php @@ -66,7 +66,7 @@ abstract class AbstractOfFinder public function __construct() { - $this->root = substr(__FILE__, 0, strpos(__FILE__, DIRECTORY_SEPARATOR . "src")); + $this->root = substr(__FILE__, 0, strpos(__FILE__, DIRECTORY_SEPARATOR . "components")); $external_classmap = include(__DIR__ . "/../../../../vendor/composer/vendor/composer/autoload_classmap.php"); $this->classmap = $external_classmap ?: null; } @@ -89,13 +89,13 @@ protected function genericGetMatchingClassNames( array $additional_ignore = [], string $matching_path = null ): \Iterator { - foreach($this->getAllClassNames($additional_ignore, $matching_path) as $class_name) { + foreach ($this->getAllClassNames($additional_ignore, $matching_path) as $class_name) { try { $reflection_class = new \ReflectionClass($class_name); - if($is_matching($reflection_class)) { + if ($is_matching($reflection_class)) { yield $class_name; } - } catch(\Throwable $e) { + } catch (\Throwable $e) { // ignore } } @@ -108,7 +108,7 @@ protected function getAllClassNames(array $additional_ignore, string $matching_p { $ignore = array_merge($this->ignore, $additional_ignore); - if(!is_array($this->classmap)) { + if (!is_array($this->classmap)) { throw new \LogicException("Composer ClassMap not loaded"); } @@ -120,14 +120,14 @@ protected function getAllClassNames(array $additional_ignore, string $matching_p $ignore ) ); - if($matching_path) { + if ($matching_path) { $matching_path = str_replace('/', '(/|\\\\)', $matching_path); } - foreach($this->classmap as $class_name => $file_path) { + foreach ($this->classmap as $class_name => $file_path) { $real_path = realpath($file_path); - if($real_path === false) { + if ($real_path === false) { throw new \RuntimeException( "Could not find file for class $class_name (path: $file_path). " . "Please check the composer classmap, maybe it is outdated. " . @@ -137,10 +137,10 @@ protected function getAllClassNames(array $additional_ignore, string $matching_p } $path = str_replace($this->root, "", $real_path); - if($matching_path && !preg_match("#^" . $matching_path . "$#", $path)) { + if ($matching_path && !preg_match("#^" . $matching_path . "$#", $path)) { continue; } - if(!preg_match("#^" . $regexp . "$#", $path)) { + if (!preg_match("#^" . $regexp . "$#", $path)) { yield $class_name; } } diff --git a/components/ILIAS/Setup/src/ImplementationOfAgentFinder.php b/components/ILIAS/Setup/src/ImplementationOfAgentFinder.php index b323f5fcd20b..d52e8557f582 100755 --- a/components/ILIAS/Setup/src/ImplementationOfAgentFinder.php +++ b/components/ILIAS/Setup/src/ImplementationOfAgentFinder.php @@ -27,9 +27,6 @@ class ImplementationOfAgentFinder implements AgentFinder { protected array|AgentCollection $component_agents; - /** - * @var array $predefined_agents - */ public function __construct( protected Refinery $refinery, protected Data\Factory $data_factory, @@ -98,7 +95,7 @@ public function getPluginAgent(string $name): Agent // TODO: This seems to be something that rather belongs to Services/Component/ // but we put it here anyway for the moment. This seems to be something that // could go away when we unify Services/Modules/Plugins to one common concept. - $path = "[/]public/Customizing/global/plugins/.*/.*/" . $name . "/.*"; + $path = "[/]public/Customizing/plugins/.*/.*/" . $name . "/.*"; $agent_classes = iterator_to_array($this->interface_finder->getMatchingClassNames( Agent::class, [],