Skip to content
Snippets Groups Projects
Select Git revision
  • d9bf0723092ced12e07b664964d56be7715c9cfc
  • 3.9 default
  • develop
  • 6.0
  • 5.0
  • 4.0
  • scrutinizer-patch-4
  • scrutinizer-patch-3
  • scrutinizer-patch-2
  • scrutinizer-patch-1
  • 3.7
  • 3.8
  • 3.6
  • 3.9_backported
  • 3.8_backported
  • 3.7_backported
  • 3.5
  • 3.6_backported
  • 3.5_backported
  • 3.4
  • 3.3_backported
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 5.0.6
  • 6.0.0
  • 5.0.5
  • 6.0.0-rc
  • 5.0.4
  • 6.0.0-beta
  • 5.0.3
  • 4.0.6
  • 5.0.2
  • 5.0.1
  • 4.0.5
  • 5.0.0
  • 4.0.4
  • 5.0.0-rc2
  • 5.0.0-rc1
41 results

modFacture.class.php

Blame
  • Broker.php 2.36 KiB
    <?php
    /**
     * Nmc_Controller_Action_Plugin_Broker: class to deal with calling plugin methods
     *
     * LICENSE: Some license information
     *
     * @copyright  2006 New Media Center - University of Nebraska-Lincoln
     * @license    http://www.gnu.org/licenses/gpl.txt GPL
     * @version    0.0.1
     * @link       http://nmc.unl.edu/
     * @since      File available since Release 0.0.1
    */
    
    require_once 'Nmc/Controller/Action/Plugin/Interface.php';
    
    /**
     * * Nmc_Controller_Action_Plugin_Broker
     *
     * @copyright  2006 New Media Center - University of Nebraska Lincoln
     * @license    http://www.gnu.org/gpl.txt GPL
     * @version    Release: 0.0.1
     * @link       http://nmc.unl.edu/
     * @since      Class available since Release 0.0.1
     */
    
    class Nmc_Controller_Action_Plugin_Broker implements Nmc_Controller_Action_Plugin_Interface
    {
        protected $_plugins;
    
    	public function __construct()
    	{
    	    $this->_plugins = array();
    	}
    
    	public function registerPlugin(Nmc_Controller_Action_Plugin_Interface $plugin)
    	{
    	    if(!in_array($plugin, $this->_plugins, true)) {
    	       $this->_plugins[] = $plugin;
    	    }
    	}
    
    	public function unregisterPlugin(Nmc_Controller_Action_Plugin_Interface $plugin)
    	{
    	    $key = array_search($plugin, $this->_plugins, true);
    	    if($key !== false) {
    	       unset($this->_plugins[$key]);
    	    }
    	}
    
    	public function preAction(Nmc_Controller_Action $controller,
                                  Zend_Controller_Request_Abstract $request,
                                  Zend_Controller_Response_Abstract $response)
    	{
    	    foreach($this->_plugins as $plugin) {
    	        $plugin->preAction($controller, $request, $response);
    	    }
    	}
    
    	public function postAction(Nmc_Controller_Action $controller,
                                   Zend_Controller_Request_Abstract $request,
                                   Zend_Controller_Response_Abstract $response)
    	{
    	    foreach($this->_plugins as $plugin) {
    	        $plugin->postAction($controller, $request, $response);
    	    }
    	}
    
    	public function pluginMethodExists($method)
    	{
    	    foreach($this->_plugins as $plugin) {
    	        if(method_exists($plugin, $method)) {
    	            return true;
    	        }
    	    }
    	    return false;
    	}
    
    	public function callPluginMethod($method, $args)
    	{
    	    foreach($this->_plugins as $plugin) {
    	        if(method_exists($plugin, $method)) {
    	            return call_user_func_array(array($plugin, $method), $args);
    	        }
    	    }
    	}
    
    }
    
    ?>