PHP Class Phergie_Plugin_Handler, phergie

Author: Phergie Development Team ([email protected])
Inheritance: implements IteratorAggregate, implements Countable
Afficher le fichier Open project: phergie/phergie Class Usage Examples

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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 méthode

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
Résultat void

__construct() public méthode

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
Résultat void

__get() public méthode

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
Résultat Phergie_Plugin_Abstract Requested plugin instance

__isset() public méthode

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

__unset() public méthode

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

addPath() public méthode

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
Résultat Phergie_Plugin_Handler Provides a fluent interface

addPlugin() public méthode

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
Résultat Phergie_Plugin_Abstract New plugin instance

addPlugins() public méthode

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))
Résultat Phergie_Plugin_Handler Provides a fluent interface

count() public méthode

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

getAutoload() public méthode

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
Résultat boolean TRUE if autoloading is enabled, FALSE otherwise

getIterator() public méthode

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

getPlugin() public méthode

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
Résultat Phergie_Plugin_Abstract Plugin instance

getPluginInfo() public méthode

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

getPlugins() public méthode

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
Résultat array Associative array mapping lowercased plugin class short names to corresponding plugin instances

hasPlugin() public méthode

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
Résultat boolean TRUE if an instance exists, FALSE otherwise

removePlugin() public méthode

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
Résultat Phergie_Plugin_Handler Provides a fluent interface

setAutoload() public méthode

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
Résultat Phergie_Plugin_Handler Provides a fluent interface.

setIteratorClass() public méthode

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
Résultat 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
Résultat boolean

$config protected_oe property

Phergie_Config instance that should be passed in to any plugin instantiated within the handler
protected Phergie_Config $config
Résultat 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
Résultat Phergie_Event_Handler

$iteratorClass protected_oe property

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

$iteratorCollection protected_oe property

protected $iteratorCollection

$paths protected_oe property

Paths in which to search for plugin class files
protected array $paths
Résultat array

$plugins protected_oe property

Current list of plugin instances
protected array $plugins
Résultat array