[pLog-svn] r761 - plog/trunk/class/plugin

oscar at devel.plogworld.net oscar at devel.plogworld.net
Wed Jan 19 18:18:37 GMT 2005


Author: oscar
Date: 2005-01-19 18:18:36 +0000 (Wed, 19 Jan 2005)
New Revision: 761

Modified:
   plog/trunk/class/plugin/pluginbase.class.php
Log:
added some more information to the PluginBase::register() method and added PluginBase::notifyEvent so that events can be easily thrown from plugins

Modified: plog/trunk/class/plugin/pluginbase.class.php
===================================================================
--- plog/trunk/class/plugin/pluginbase.class.php	2005-01-18 21:30:57 UTC (rev 760)
+++ plog/trunk/class/plugin/pluginbase.class.php	2005-01-19 18:18:36 UTC (rev 761)
@@ -161,7 +161,11 @@
         }
 
         /**
-         * This function is called only once when the plugin is registered.
+         * This function is called only once when the plugin is registered. Please use this method
+		 * in case your plugin needs to perform some initializations before it is used, specially
+		 * if the initialization process requires access to the plugin/blog settings (because the
+		 * BlogInfo and UserInfo objects are not available in the constructor *yet* so this method
+		 * will be called once they are available)
          *
          * @return Nothing.
          */
@@ -307,6 +311,24 @@
 		}
 		
 		/**
+		 * allows the plugin to throw any event, be it one of the core/standard ones
+		 * or a new custom one
+		 *
+		 * @see PluginManager::notifyEvent
+		 * @param eventType the event code
+		 * @param params an associative array with the even parameters, if any
+		 * @return true
+		 */
+		function notifyEvent( $eventType, $params = Array())
+		{
+			$this->log->debug( "plugin ".$this->id." - throwing event ".$eventType );		
+		
+			// get a handle to the plugin manager and throw the event with its parameters
+			$pm =& PluginManager::getPluginManager();
+			return( $pm->notifyEvent( $eventType, $params ));
+		}
+		
+		/**
 		 * this method should be implemented by plugins, and will tell the plugin manager 
 		 * which configuration settings are stored in the database by this plugin. This will be
 		 * used later on, in case users want to completely remove any trace of this plugin




More information about the pLog-svn mailing list