mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03:00
refactor: add php autoloader (#2655)
This commit is contained in:
parent
b090b17bbf
commit
0ef298f9cc
9 changed files with 16 additions and 12 deletions
|
@ -27,8 +27,6 @@ class ActionFactory extends FactoryAbstract {
|
|||
throw new \Exception('Action ' . $name . ' does not exist!');
|
||||
}
|
||||
|
||||
require_once $filePath;
|
||||
|
||||
$class = $this->buildClassName($name);
|
||||
|
||||
if((new \ReflectionClass($class))->isInstantiable()) {
|
||||
|
|
|
@ -68,8 +68,6 @@ class BridgeFactory extends FactoryAbstract {
|
|||
throw new \Exception('Bridge file ' . $filePath . ' does not exist!');
|
||||
}
|
||||
|
||||
require_once $filePath;
|
||||
|
||||
if((new \ReflectionClass($name))->isInstantiable()) {
|
||||
return new $name();
|
||||
}
|
||||
|
|
|
@ -54,8 +54,6 @@ class CacheFactory extends FactoryAbstract {
|
|||
throw new \Exception('Cache file ' . $filePath . ' does not exist!');
|
||||
}
|
||||
|
||||
require_once $filePath;
|
||||
|
||||
if((new \ReflectionClass($name))->isInstantiable()) {
|
||||
return new $name();
|
||||
}
|
||||
|
|
|
@ -59,8 +59,6 @@ class FormatFactory extends FactoryAbstract {
|
|||
throw new \Exception('Format file ' . $filePath . ' does not exist!');
|
||||
}
|
||||
|
||||
require_once $pathFormat;
|
||||
|
||||
if((new \ReflectionClass($name))->isInstantiable()) {
|
||||
return new $name();
|
||||
}
|
||||
|
|
|
@ -88,6 +88,22 @@ require_once PATH_LIB_VENDOR . 'parsedown/Parsedown.php';
|
|||
require_once PATH_LIB_VENDOR . 'php-urljoin/src/urljoin.php';
|
||||
require_once PATH_LIB_VENDOR . 'simplehtmldom/simple_html_dom.php';
|
||||
|
||||
spl_autoload_register(function ($className) {
|
||||
$folders = [
|
||||
__DIR__ . '/../actions/',
|
||||
__DIR__ . '/../bridges/',
|
||||
__DIR__ . '/../caches/',
|
||||
__DIR__ . '/../formats/',
|
||||
__DIR__ . '/../lib/',
|
||||
];
|
||||
foreach ($folders as $folder) {
|
||||
$file = $folder . $className . '.php';
|
||||
if (is_file($file)) {
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Configuration::verifyInstallation();
|
||||
Configuration::loadConfiguration();
|
||||
Authentication::showPromptIfNeeded();
|
||||
|
|
|
@ -48,7 +48,6 @@ class ActionImplementationTest extends TestCase {
|
|||
}
|
||||
|
||||
private function setAction($path) {
|
||||
require_once $path;
|
||||
$this->class = basename($path, '.php');
|
||||
$this->assertTrue(class_exists($this->class), 'class ' . $this->class . ' doesn\'t exist');
|
||||
$this->obj = new $this->class();
|
||||
|
|
|
@ -212,7 +212,6 @@ class BridgeImplementationTest extends TestCase {
|
|||
}
|
||||
|
||||
private function setBridge($path) {
|
||||
require_once $path;
|
||||
$this->class = basename($path, '.php');
|
||||
$this->assertTrue(class_exists($this->class), 'class ' . $this->class . ' doesn\'t exist');
|
||||
$this->obj = new $this->class();
|
||||
|
|
|
@ -34,7 +34,6 @@ class CacheImplementationTest extends TestCase {
|
|||
}
|
||||
|
||||
private function setCache($path) {
|
||||
require_once $path;
|
||||
$this->class = basename($path, '.php');
|
||||
$this->assertTrue(class_exists($this->class), 'class ' . $this->class . ' doesn\'t exist');
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class FormatImplementationTest extends TestCase {
|
|||
}
|
||||
|
||||
private function setFormat($path) {
|
||||
require_once $path;
|
||||
$this->class = basename($path, '.php');
|
||||
$this->assertTrue(class_exists($this->class), 'class ' . $this->class . ' doesn\'t exist');
|
||||
$this->obj = new $this->class();
|
||||
|
|
Loading…
Add table
Reference in a new issue