Skip to content

Commit

Permalink
Fix root path of AbstractOfFinder and plugins path of ImplementationO…
Browse files Browse the repository at this point in the history
…fAgentFinder
  • Loading branch information
fwolf-ilias committed Dec 6, 2024
1 parent 544d6f4 commit 32f77ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 10 additions & 10 deletions components/ILIAS/Setup/src/AbstractOfFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
}
}
Expand All @@ -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");
}

Expand All @@ -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. " .
Expand All @@ -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;
}
}
Expand Down
5 changes: 1 addition & 4 deletions components/ILIAS/Setup/src/ImplementationOfAgentFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class ImplementationOfAgentFinder implements AgentFinder
{
protected array|AgentCollection $component_agents;

/**
* @var array<string, Agent> $predefined_agents
*/
public function __construct(
protected Refinery $refinery,
protected Data\Factory $data_factory,
Expand Down Expand Up @@ -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,
[],
Expand Down

0 comments on commit 32f77ed

Please sign in to comment.