public function import($type, $plugin = null, $autocreate = true, $dispatcher = null)
	{
		static $loaded = array();

		// check for the default args, if so we can optimise cheaply
		$defaults = false;
		if (is_null($plugin) && $autocreate == true && is_null($dispatcher))
		{
			$defaults = true;
		}

		if (!isset($loaded[$type]) || !$defaults)
		{
			$results = null;

			// Makes sure we have an event dispatcher
			if (!($dispatcher instanceof DispatcherInterface))
			{
				$dispatcher = App::get('dispatcher');
			}

			// Get the specified plugin(s).
			foreach ($this->all() as $plug)
			{
				if ($plug->type == $type && ($plugin === null || $plug->name == $plugin))
				{
					if ($p = $this->init($plug, $autocreate)) //, $dispatcher))
					{
						$dispatcher->addListener($p);
					}
					$results = true;
				}
			}

			// Bail out early if we're not using default args
			if (!$defaults)
			{
				return $results;
			}
			$loaded[$type] = $results;
		}

		return $loaded[$type];
	}
public function import($type, $plugin = null, $autocreate = true, $dispatcher = null)
	{
		static $loaded = array();

		// check for the default args, if so we can optimise cheaply
		$defaults = false;
		if (is_null($plugin) && $autocreate == true && is_null($dispatcher))
		{
			$defaults = true;
		}

		if (!isset($loaded[$type]) || !$defaults)
		{
			$results = null;

			// Makes sure we have an event dispatcher
			if (!($dispatcher instanceof DispatcherInterface))
			{
				$dispatcher = App::get('dispatcher');
			}

			// Get the specified plugin(s).
			foreach ($this->all() as $plug)
			{
				if ($plug->type == $type && ($plugin === null || $plug->name == $plugin))
				{
					if ($p = $this->init($plug, $autocreate)) //, $dispatcher))
					{
						$dispatcher->addListener($p);
					}
					$results = true;
				}
			}

			// Bail out early if we're not using default args
			if (!$defaults)
			{
				return $results;
			}
			$loaded[$type] = $results;
		}

		return $loaded[$type];
	}
public function import ( $ type , $ plugin = null , $ autocreate = true , $ dispatcher = null ) { static $ loaded = array ( ) ; // check for the default args, if so we can optimise cheaply $ defaults = false ; if ( is_null ( $ plugin ) && $ autocreate == true && is_null ( $ dispatcher ) ) { $ defaults = true ; } if ( ! isset ( $ loaded [ $ type ] ) || ! $ defaults ) { $ results = null ; // Makes sure we have an event dispatcher if ( ! ( $ dispatcher instanceof DispatcherInterface ) ) { $ dispatcher = App :: get ( 'dispatcher' ) ; } // Get the specified plugin(s). foreach ( $ this -> all ( ) as $ plug ) { if ( $ plug -> type == $ type && ( $ plugin === null || $ plug -> name == $ plugin ) ) { if ( $ p = $ this -> init ( $ plug , $ autocreate ) ) //, $dispatcher)) { $ dispatcher -> addListener ( $ p ) ; } $ results = true ; } } // Bail out early if we're not using default args if ( ! $ defaults ) { return $ results ; } $ loaded [ $ type ] = $ results ; } return $ loaded [ $ type ] ; }
Loads all the plugin files for a particular type if no specific plugin is specified
otherwise only the specific plugin is loaded.

@param   string   $type        The plugin type, relates to the sub-directory in the plugins directory.
@param   string   $plugin      The plugin name.
@param   boolean  $autocreate  Autocreate the plugin.
@param   object   $dispatcher  Optionally allows the plugin to use a different dispatcher.
@return  boolean  True on success.
Loads all the plugin files for a particular type if no specific plugin is specified otherwise only the specific plugin is loaded .