PHP Class Phergie_Plugin_Handler, phergie

Author: Phergie Development Team ([email protected])
Inheritance: implements IteratorAggregate, implements Countable
显示文件 Open project: phergie/phergie Class Usage Examples

Protected Properties

Property Type Description
$autoload boolean Flag indicating whether plugin classes should be instantiated on demand if they are requested but no instance currently exists
$config Phergie_Config Phergie_Config instance that should be passed in to any plugin instantiated within the handler
$events Phergie_Event_Handler Phergie_Event_Handler instance that should be passed in to any plugin instantiated within the handler
$iteratorClass string Name of the class to use for iterating over all currently loaded plugins
$iteratorCollection
$paths array Paths in which to search for plugin class files
$plugins array Current list of plugin instances

Public Methods

Method Description
__call ( string $name, array $args ) : void Proxies method calls to all plugins containing the called method.
__construct ( Phergie_Config $config, Phergie_Event_Handler $events ) : void Constructor to initialize class properties and add the path for core plugins.
__get ( string $name ) : Phergie_Plugin_Abstract Allows plugin instances to be accessed as properties of the handler.
__isset ( string $name ) : boolean Allows plugin instances to be detected as properties of the handler.
__unset ( string $name ) : void Allows plugin instances to be removed as properties of handler.
addPath ( string $path, string $prefix = '' ) : Phergie_Plugin_Handler Adds a path to search for plugin class files. Paths are searched in the reverse order in which they are added.
addPlugin ( string | Phergie_Plugin_Abstract $plugin, array $args = null ) : Phergie_Plugin_Abstract Adds a plugin instance to the handler.
addPlugins ( array $plugins ) : Phergie_Plugin_Handler Adds multiple plugin instances to the handler.
count ( ) : integer Returns the number of plugins contained within the handler.
getAutoload ( ) : boolean Returns the value of a flag used to determine whether plugins should be loaded automatically if they have not been explicitly loaded.
getIterator ( $new = true ) : ArrayIterator Returns an iterator for all currently loaded plugin instances.
getPlugin ( string $name ) : Phergie_Plugin_Abstract Returns the corresponding instance for a specified plugin, loading it if it is not already loaded and autoloading is enabled.
getPluginInfo ( string $plugin ) : array | boolean Returns metadata corresponding to a specified plugin.
getPlugins ( array $names = [] ) : array Returns the corresponding instances for multiple specified plugins, loading them if they are not already loaded and autoloading is enabled.
hasPlugin ( string $name ) : boolean Returns whether or not at least one instance of a specified plugin class is loaded.
removePlugin ( string | Phergie_Plugin_Abstract $plugin ) : Phergie_Plugin_Handler Removes a plugin instance from the handler.
setAutoload ( boolean $flag = true ) : Phergie_Plugin_Handler Sets a flag used to determine whether plugins should be loaded automatically if they have not been explicitly loaded.
setIteratorClass ( string $class ) : Phergie_Plugin_Handler Sets the iterator class used for all currently loaded plugin instances.

Method Details

__call() public method

Proxies method calls to all plugins containing the called method.
public __call ( string $name, array $args ) : void
$name string Name of the method called
$args array Arguments passed in the method call
return void

__construct() public method

Constructor to initialize class properties and add the path for core plugins.
public __construct ( Phergie_Config $config, Phergie_Event_Handler $events ) : void
$config Phergie_Config configuration to pass to any instantiated plugin
$events Phergie_Event_Handler event handler to pass to any instantiated plugin
return void

__get() public method

Allows plugin instances to be accessed as properties of the handler.
public __get ( string $name ) : Phergie_Plugin_Abstract
$name string Short name of the plugin
return Phergie_Plugin_Abstract Requested plugin instance

__isset() public method

Allows plugin instances to be detected as properties of the handler.
public __isset ( string $name ) : boolean
$name string Short name of the plugin
return boolean TRUE if the plugin is loaded, FALSE otherwise

__unset() public method

Allows plugin instances to be removed as properties of handler.
public __unset ( string $name ) : void
$name string Short name of the plugin
return void

addPath() public method

Adds a path to search for plugin class files. Paths are searched in the reverse order in which they are added.
public addPath ( string $path, string $prefix = '' ) : Phergie_Plugin_Handler
$path string Filesystem directory path
$prefix string Optional class name prefix corresponding to the path
return Phergie_Plugin_Handler Provides a fluent interface

addPlugin() public method

Adds a plugin instance to the handler.
public addPlugin ( string | Phergie_Plugin_Abstract $plugin, array $args = null ) : Phergie_Plugin_Abstract
$plugin string | Phergie_Plugin_Abstract Short name of the plugin class or a plugin object
$args array Optional array of arguments to pass to the plugin constructor if a short name is passed for $plugin
return Phergie_Plugin_Abstract New plugin instance

addPlugins() public method

Adds multiple plugin instances to the handler.
public addPlugins ( array $plugins ) : Phergie_Plugin_Handler
$plugins array List of elements where each is of the form 'ShortPluginName' or array('ShortPluginName', array($arg1, ..., $argN))
return Phergie_Plugin_Handler Provides a fluent interface

count() public method

Returns the number of plugins contained within the handler.
public count ( ) : integer
return integer Plugin count

getAutoload() public method

Returns the value of a flag used to determine whether plugins should be loaded automatically if they have not been explicitly loaded.
public getAutoload ( ) : boolean
return boolean TRUE if autoloading is enabled, FALSE otherwise

getIterator() public method

Returns an iterator for all currently loaded plugin instances.
public getIterator ( $new = true ) : ArrayIterator
return ArrayIterator

getPlugin() public method

Returns the corresponding instance for a specified plugin, loading it if it is not already loaded and autoloading is enabled.
public getPlugin ( string $name ) : Phergie_Plugin_Abstract
$name string Short name of the plugin class
return Phergie_Plugin_Abstract Plugin instance

getPluginInfo() public method

Returns metadata corresponding to a specified plugin.
public getPluginInfo ( string $plugin ) : array | boolean
$plugin string Short name of the plugin class
return array | boolean Associative array containing the path to the class file and its containing directory as well as the full class name

getPlugins() public method

Returns the corresponding instances for multiple specified plugins, loading them if they are not already loaded and autoloading is enabled.
public getPlugins ( array $names = [] ) : array
$names array Optional list of short names of the plugin classes to which the returned plugin list will be limited, defaults to all presently loaded plugins
return array Associative array mapping lowercased plugin class short names to corresponding plugin instances

hasPlugin() public method

Returns whether or not at least one instance of a specified plugin class is loaded.
public hasPlugin ( string $name ) : boolean
$name string Short name of the plugin class
return boolean TRUE if an instance exists, FALSE otherwise

removePlugin() public method

Removes a plugin instance from the handler.
public removePlugin ( string | Phergie_Plugin_Abstract $plugin ) : Phergie_Plugin_Handler
$plugin string | Phergie_Plugin_Abstract Short name of the plugin class or a plugin object
return Phergie_Plugin_Handler Provides a fluent interface

setAutoload() public method

Sets a flag used to determine whether plugins should be loaded automatically if they have not been explicitly loaded.
public setAutoload ( boolean $flag = true ) : Phergie_Plugin_Handler
$flag boolean TRUE to have plugins autoload (default), FALSE otherwise
return Phergie_Plugin_Handler Provides a fluent interface.

setIteratorClass() public method

Sets the iterator class used for all currently loaded plugin instances.
public setIteratorClass ( string $class ) : Phergie_Plugin_Handler
$class string Name of a class that extends FilterIterator
return Phergie_Plugin_Handler Provides a fluent API

Property Details

$autoload protected_oe property

Flag indicating whether plugin classes should be instantiated on demand if they are requested but no instance currently exists
protected bool $autoload
return boolean

$config protected_oe property

Phergie_Config instance that should be passed in to any plugin instantiated within the handler
protected Phergie_Config $config
return Phergie_Config

$events protected_oe property

Phergie_Event_Handler instance that should be passed in to any plugin instantiated within the handler
protected Phergie_Event_Handler $events
return Phergie_Event_Handler

$iteratorClass protected_oe property

Name of the class to use for iterating over all currently loaded plugins
protected string $iteratorClass
return string

$iteratorCollection protected_oe property

protected $iteratorCollection

$paths protected_oe property

Paths in which to search for plugin class files
protected array $paths
return array

$plugins protected_oe property

Current list of plugin instances
protected array $plugins
return array