Renamed the codebase to RippingCluster
Since the new design is engine agnostic, removed HandBrake from the class names.
This commit is contained in:
50
lib/RippingCluster/PluginFactory.class.php
Normal file
50
lib/RippingCluster/PluginFactory.class.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
abstract class RippingCluster_PluginFactory {
|
||||
|
||||
static protected $validPlugins;
|
||||
|
||||
abstract public static function init();
|
||||
|
||||
public static function getValidPlugins() {
|
||||
return array_keys(self::$validPlugins);
|
||||
}
|
||||
|
||||
protected static function findPlugins($directory) {
|
||||
$plugins = array();
|
||||
|
||||
$iterator = new RippingCluster_Utility_ClassFilesIterator(new RippingCluster_Utility_VisibleFilesIterator(new DirectoryIterator(RippingCluster_Lib . $directory)));
|
||||
|
||||
foreach ($iterator as /** @var SplFileInfo */ $file) {
|
||||
$plugin = preg_replace('/.class.php$/', '', $file->getFilename());
|
||||
$plugins[] = $plugin;
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
protected static function loadPlugins($plugins, $prefix) {
|
||||
self::$validPlugins = array();
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$fullClassname = $prefix . $plugin;
|
||||
if ( ! class_exists($fullClassname, true)) {
|
||||
echo "Cannot load $fullClassname\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! in_array('RippingCluster_Worker_IPlugin', class_implements($fullClassname))) {
|
||||
echo "$plugin does not implement the necessary interfaces\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Initialise the plugin
|
||||
call_user_func(array($fullClassname, 'init'));
|
||||
|
||||
self::$validPlugins[$plugin] = $fullClassname;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user