Skip to content

Commit 1abd958

Browse files
committed
change the way we load plugins
1 parent f63e4e9 commit 1abd958

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

index.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,24 @@
8080
$plugin_class = $plugin . 'Plugin';
8181

8282
if (file_exists('./plugins/' . $plugin_class . '.php')) {
83-
84-
// use user plugin from /plugins/
8583
require_once('./plugins/' . $plugin_class . '.php');
86-
87-
} elseif (class_exists('\\Proxy\\Plugin\\' . $plugin_class)) {
88-
89-
// does the native plugin from php-proxy package with such name exist?
90-
$plugin_class = '\\Proxy\\Plugin\\' . $plugin_class;
84+
} else if (file_exists('./plugins/' . $plugin . '.php')) {
85+
require_once('./plugins/' . $plugin . '.php');
9186
}
9287

93-
// otherwise plugin_class better be loaded already through composer.json and match namespace exactly \\Vendor\\Plugin\\SuperPlugin
94-
// $proxy->getEventDispatcher()->addSubscriber(new $plugin_class());
88+
// where to search for this class?
89+
$searchForClasses = [
90+
$plugin,
91+
$plugin_class,
92+
'\\Proxy\\Plugin\\' . $plugin_class
93+
];
9594

96-
$proxy->addSubscriber(new $plugin_class());
95+
foreach ($searchForClasses as $class) {
96+
97+
if (class_exists($class)) {
98+
$proxy->addSubscriber(new $class());
99+
}
100+
}
97101
}
98102

99103
try {

0 commit comments

Comments
 (0)