Use autoload for \Mibew\Plugin class

This commit is contained in:
Dmitriy Simushev 2013-12-26 14:54:36 +00:00
parent 98c96a7c81
commit a033d72f20
4 changed files with 8 additions and 9 deletions

View File

@ -65,13 +65,13 @@ Class EventDispatcher {
* All event listeners must receive one argument of array type by reference. * All event listeners must receive one argument of array type by reference.
* *
* @param string $event_name Event's name * @param string $event_name Event's name
* @param Plugin $plugin Plugin object, that handles the event * @param \Mibew\Plugin $plugin Plugin object, that handles the event
* @param string $listener Plugins method, that handles the event * @param string $listener Plugins method, that handles the event
* @param int $priority Priority of listener. If $priority = null, the plugin weight will * @param int $priority Priority of listener. If $priority = null, the plugin weight will
* use instead. * use instead.
* @return boolean true on success or false on failure. * @return boolean true on success or false on failure.
* *
* @see Plugin::getWeight() * @see \Mibew\Plugin::getWeight()
*/ */
public function attachListener($event_name, Plugin $plugin, $listener, $priority = null){ public function attachListener($event_name, Plugin $plugin, $listener, $priority = null){
// Check method is callable // Check method is callable
@ -100,7 +100,7 @@ Class EventDispatcher {
* Detach listener function from event * Detach listener function from event
* *
* @param string $event_name Event's name * @param string $event_name Event's name
* @param Plugin $plugin Plugin object, that handles the event * @param \Mibew\Plugin $plugin Plugin object, that handles the event
* @param string $listener Plugins method, that handles the event * @param string $listener Plugins method, that handles the event
* @return boolean true on success or false on failure. * @return boolean true on success or false on failure.
*/ */

View File

@ -15,6 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
namespace Mibew;
/** /**
* Base plugin class * Base plugin class
*/ */

View File

@ -96,7 +96,7 @@ Class PluginManager {
// Build name of the plugin class // Build name of the plugin class
$plugin_name_parts = explode('_', $plugin_name); $plugin_name_parts = explode('_', $plugin_name);
$plugin_name_parts = array_map('ucfirst', $plugin_name_parts); $plugin_name_parts = array_map('ucfirst', $plugin_name_parts);
$plugin_classname = implode('', $plugin_name_parts) . "Plugin"; $plugin_classname = '\\Mibew\\Plugin\\' . implode('', $plugin_name_parts);
// Try to load plugin file // Try to load plugin file
if (! (include_once $plugin_name."/".$plugin_name."_plugin.php")) { if (! (include_once $plugin_name."/".$plugin_name."_plugin.php")) {
@ -111,10 +111,10 @@ Class PluginManager {
continue; continue;
} }
// Check if plugin extends abstract 'Plugin' class // Check if plugin extends abstract 'Plugin' class
if ('Plugin' != get_parent_class($plugin_classname)) { if ('Mibew\\Plugin' != get_parent_class($plugin_classname)) {
trigger_error( trigger_error(
"Plugin class '{$plugin_classname}' does not extend " . "Plugin class '{$plugin_classname}' does not extend " .
"abstract 'Plugin' class!", "abstract '\\Mibew\\Plugin' class!",
E_USER_WARNING E_USER_WARNING
); );
continue; continue;

View File

@ -36,9 +36,6 @@ require_once(MIBEW_FS_ROOT.'/libs/common/constants.php');
require_once(MIBEW_FS_ROOT.'/libs/common/autoload.php'); require_once(MIBEW_FS_ROOT.'/libs/common/autoload.php');
spl_autoload_register('class_autoload'); spl_autoload_register('class_autoload');
// Include system classes
require_once(MIBEW_FS_ROOT.'/libs/classes/plugin.php');
// Include common libs // Include common libs
require_once(MIBEW_FS_ROOT.'/libs/common/configurations.php'); require_once(MIBEW_FS_ROOT.'/libs/common/configurations.php');
require_once(MIBEW_FS_ROOT.'/libs/common/csrf.php'); require_once(MIBEW_FS_ROOT.'/libs/common/csrf.php');