Phergie
[ class tree: Phergie ] [ index: Phergie ] [ all elements ]

Class: Phergie_Plugin_Handler

Source Location: /Phergie/Plugin/Handler.php

Class Overview


Handles on-demand loading of, iteration over, and access to plugins.


Author(s):

Implements interfaces:

  • IteratorAggregate (internal interface)
  • Countable (internal interface)

Variables

Methods



Class Details

[line 31]
Handles on-demand loading of, iteration over, and access to plugins.



Tags:

author:  Phergie Development Team <team@phergie.org>
link:  http://pear.phergie.org/package/Phergie
license:  New BSD License


[ Top ]


Class Variables

$autoload =

[line 53]

Flag indicating whether plugin classes should be instantiated on demand if they are requested but no instance currently exists



Tags:

access:  protected

Type:   bool


[ Top ]

$config =

[line 61]

Phergie_Config instance that should be passed in to any plugin instantiated within the handler



Tags:

access:  protected

Type:   Phergie_Config


[ Top ]

$events =

[line 69]

Phergie_Event_Handler instance that should be passed in to any plugin instantiated within the handler



Tags:

access:  protected



[ Top ]

$iteratorClass =  'Phergie_Plugin_Iterator'

[line 77]

Name of the class to use for iterating over all currently loaded plugins



Tags:

access:  protected

Type:   string


[ Top ]

$paths =

[line 45]

Paths in which to search for plugin class files



Tags:

access:  protected

Type:   array


[ Top ]

$plugins =

[line 38]

Current list of plugin instances



Tags:

access:  protected

Type:   array


[ Top ]



Class Methods


constructor __construct [line 90]

void __construct( Phergie_Config $config, Phergie_Event_Handler $events)

Constructor to initialize class properties and add the path for core plugins.



Tags:

access:  public


Parameters:

Phergie_Config   $config   configuration to pass to any instantiated plugin
Phergie_Event_Handler   $events   event handler to pass to any instantiated plugin

[ Top ]

method addPath [line 122]

Phergie_Plugin_Handler addPath( string $path, [string $prefix = ''])

Adds a path to search for plugin class files. Paths are searched in the reverse order in which they are added.



Tags:

return:  Provides a fluent interface
throws:  Phergie_Plugin_Exception
access:  public


Parameters:

string   $path   Filesystem directory path
string   $prefix   Optional class name prefix corresponding to the path

[ Top ]

method addPlugin [line 182]

Phergie_Plugin_Abstract addPlugin( string|Phergie_Plugin_Abstract $plugin, [ $args = null])

Adds a plugin instance to the handler.



Tags:

return:  New plugin instance
access:  public


Parameters:

string|Phergie_Plugin_Abstract   $plugin   Short name of the plugin class or a plugin object
array   $args   Optional array of arguments to pass to the plugin constructor if a short name is passed for $plugin

[ Top ]

method addPlugins [line 259]

Phergie_Plugin_Handler addPlugins( $plugins)

Adds multiple plugin instances to the handler.



Tags:

return:  Provides a fluent interface
access:  public


Parameters:

array   $plugins   List of elements where each is of the form 'ShortPluginName' or array('ShortPluginName', array($arg1, ..., $argN))

[ Top ]

method count [line 497]

int count( )

Returns the number of plugins contained within the handler.



Tags:

return:  Plugin count
access:  public



Implementation of:
Countable::count
[ Top ]

method getAutoload [line 386]

bool getAutoload( )

Returns the value of a flag used to determine whether plugins should be loaded automatically if they have not been explicitly loaded.



Tags:

return:  TRUE if autoloading is enabled, FALSE otherwise
access:  public


[ Top ]

method getIterator [line 432]

ArrayIterator getIterator( )

Returns an iterator for all currently loaded plugin instances.



Tags:

access:  public



Implementation of:
IteratorAggregate::getIterator
[ Top ]

method getPlugin [line 300]

Phergie_Plugin_Abstract getPlugin( string $name)

Returns the corresponding instance for a specified plugin, loading it if it is not already loaded and autoloading is enabled.



Tags:

return:  Plugin instance
access:  public


Parameters:

string   $name   Short name of the plugin class

[ Top ]

method getPluginInfo [line 150]

array|boolean getPluginInfo( string $plugin)

Returns metadata corresponding to a specified plugin.



Tags:

return:  Associative array containing the path to the class file and its containing directory as well as the full class name
throws:  Phergie_Plugin_Exception Class file can't be found
access:  public


Parameters:

string   $plugin   Short name of the plugin class

[ Top ]

method getPlugins [line 338]

array getPlugins( [ $names = array()])

Returns the corresponding instances for multiple specified plugins, loading them if they are not already loaded and autoloading is enabled.



Tags:

return:  Associative array mapping lowercased plugin class short names to corresponding plugin instances
access:  public


Parameters:

array   $names   Optional list of short names of the plugin classes to which the returned plugin list will be limited, defaults to all presently loaded plugins

[ Top ]

method hasPlugin [line 359]

bool hasPlugin( string $name)

Returns whether or not at least one instance of a specified plugin class is loaded.



Tags:

return:  TRUE if an instance exists, FALSE otherwise
access:  public


Parameters:

string   $name   Short name of the plugin class

[ Top ]

method removePlugin [line 280]

Phergie_Plugin_Handler removePlugin( string|Phergie_Plugin_Abstract $plugin)

Removes a plugin instance from the handler.



Tags:

return:  Provides a fluent interface
access:  public


Parameters:

string|Phergie_Plugin_Abstract   $plugin   Short name of the plugin class or a plugin object

[ Top ]

method setAutoload [line 373]

Phergie_Plugin_Handler setAutoload( [bool $flag = true])

Sets a flag used to determine whether plugins should be loaded automatically if they have not been explicitly loaded.



Tags:

return:  Provides a fluent interface.
access:  public


Parameters:

bool   $flag   TRUE to have plugins autoload (default), FALSE otherwise

[ Top ]

method setIteratorClass [line 449]

Phergie_Plugin_Handler setIteratorClass( string $class)

Sets the iterator class used for all currently loaded plugin instances.



Tags:

return:  Provides a fluent API
throws:  Phergie_Plugin_Exception Class cannot be found or is not an FilterIterator-based class
access:  public


Parameters:

string   $class   Name of a class that extends FilterIterator

[ Top ]

method __call [line 484]

void __call( string $name, $args)

Proxies method calls to all plugins containing the called method.



Tags:

access:  public


Parameters:

string   $name   Name of the method called
array   $args   Arguments passed in the method call

[ Top ]

method __get [line 398]

Phergie_Plugin_Abstract __get( string $name)

Allows plugin instances to be accessed as properties of the handler.



Tags:

return:  Requested plugin instance
access:  public


Parameters:

string   $name   Short name of the plugin

[ Top ]

method __isset [line 410]

bool __isset( string $name)

Allows plugin instances to be detected as properties of the handler.



Tags:

return:  TRUE if the plugin is loaded, FALSE otherwise
access:  public


Parameters:

string   $name   Short name of the plugin

[ Top ]

method __unset [line 422]

void __unset( string $name)

Allows plugin instances to be removed as properties of handler.



Tags:

access:  public


Parameters:

string   $name   Short name of the plugin

[ Top ]


Documentation generated on Mon, 27 Sep 2010 23:03:48 -0500 by phpDocumentor 1.4.3