Files
download-dispatcher/source/lib/DownloadDispatcher/Processor.class.php
Ben Roberts 44c72b132a Update processor to run only configured source plugins
Grab a list of enabled plugins and iterate through, rather than grabbing
a list of all plugins and attempting to match against the enabled ones.
2011-12-13 08:19:37 +00:00

48 lines
1.6 KiB
PHP

<?php
class DownloadDispatcher_Processor {
/**
* Entry point for the Download Dispatcher
*
* Iterates over all enabled plugins and moves supported files to the proper destinations
*/
public static function run() {
$main = DownloadDispatcher_Main::instance();
$config = $main->config();
$log = $main->log();
// Find the list of available Sync plugins
$sync_plugins = $config->get('sync');
foreach ($sync_plugins as $plugin_name) {
// Get a list of all the instances of this plugin to be used
$instances = $config->get("sync.{$plugin_name}");
foreach ($instances as $instance) {
try {
$plugin = DownloadDispatcher_Sync_PluginFactory::create($plugin_name, $config, $log, $instance);
$plugin->run();
} catch(SihnonFramework_Exception_PluginException $e) {
SihnonFramework_LogEntry::warning($log, $e->getMessage());
}
}
}
// Find the list of available source plugins
DownloadDispatcher_Source_PluginFactory::scan();
$source_plugins = $config->get('sources');
foreach ($source_plugins as $plugin_name) {
try {
$plugin = DownloadDispatcher_Source_PluginFactory::create($plugin_name, $config, $log);
$plugin->run();
} catch(DownloadDispatcher_Exception_PluginException $e) {
SihnonFramework_LogEntry::warning($log, $e->getMessage());
}
}
}
}
?>