-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins_loader.php
More file actions
executable file
·51 lines (45 loc) · 1.43 KB
/
plugins_loader.php
File metadata and controls
executable file
·51 lines (45 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// ==============================================================
// Copyright (C) 2014 Mark Vejvoda
// Under GNU GPL v3.0
// ==============================================================
namespace riprunner;
if ( defined('INCLUSION_PERMITTED') === false ||
(defined('INCLUSION_PERMITTED') === true && INCLUSION_PERMITTED === false)) {
die( 'This file must not be invoked directly.' );
}
if(defined('__RIPRUNNER_ROOT__') === false) {
define('__RIPRUNNER_ROOT__', dirname(__FILE__));
}
// The list of plugin paths
$plugin_paths = array(
__RIPRUNNER_ROOT__ . '/plugins/cache/'
);
foreach ($plugin_paths as $path) {
// First include the interfaces for the plugin path
include_once $path . "plugin_interfaces.php";
// Next Include the plugins
foreach(glob($path . "*.class.php") as $plugin) {
include_once $plugin;
}
}
class PluginsLoader {
static public function getImplementingClasses($interfaceName) {
return array_filter(
get_declared_classes(),
function ($className) use ($interfaceName) {
//echo "Looking for intferface [$interfaceName] for class [$className]" .PHP_EOL;
return in_array($interfaceName, class_implements($className) );
}
);
}
static public function findPlugin($interfaceName, $pluginType) {
foreach (self::getImplementingClasses($interfaceName) as $className) {
$class = new $className;
if($class->getPluginType() === $pluginType) {
return $class;
}
}
return null;
}
}