forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to configure PluginBroker and PluginSpecBroker via cons…
…tructor
- Loading branch information
1 parent
4ba41f7
commit 3575650
Showing
8 changed files
with
626 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 240 additions & 0 deletions
240
documentation/manual/en/module_specs/Zend_Loader-PluginSpecBroker.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Reviewed: no --> | ||
<sect1 id="zend.loader.plugin-spec-broker"> | ||
<title>The PluginSpecBroker</title> | ||
|
||
<sect2 id="zend.loader.plugin-spec-broker.intro"> | ||
<title>Overview</title> | ||
|
||
<para> | ||
This class is an extension of <link linkend="zend.loader.plugin-broker">the | ||
PluginBroker</link>. It provides the additional ability of allowing the registration | ||
of plugin <emphasis>names</emphasis> with related options, for the purposes of allowing | ||
lazy-loading of plugins and/or specifying default options. | ||
</para> | ||
</sect2> | ||
|
||
<sect2 id="zend.loader.plugin-spec-broker.quick-start"> | ||
<title>Quick Start</title> | ||
|
||
<para> | ||
Typically, a component will define an extension to the | ||
<classname>PluginSpecBroker</classname>. In these cases, you instantiate the broker, | ||
optionally providing specifications. | ||
</para> | ||
|
||
<programlisting language="php"><![CDATA[ | ||
use Zend\Application\ResourceBroker; | ||
$broker = new ResourceBroker(array( | ||
'router' => array('routes' => array( | ||
'foo' => array( | ||
'route' => '/foo/:id', | ||
'defaults' => array( | ||
'module' => 'foo', | ||
'controller' => 'products', | ||
'action' => 'item', | ||
), | ||
'reqs' => array( | ||
'id' => '\d+', | ||
), | ||
), | ||
)), | ||
)); | ||
$router = $broker->load('router'); | ||
// routes will be configured per specification | ||
]]></programlisting> | ||
</sect2> | ||
|
||
<sect2 id="zend.loader.plugin-spec-broker.options"> | ||
<title>Configuration Options</title> | ||
|
||
<para> | ||
All <link linkend="zend.loader.plugin-broker.options">PluginBroker options</link> are | ||
supported, in addition to those listed below. | ||
</para> | ||
|
||
<variablelist> | ||
<title>PluginSpecBroker Options</title> | ||
|
||
<varlistentry> | ||
<term>specs</term> | ||
|
||
<listitem> | ||
<para> | ||
The value of this option should be an array or | ||
<interfacename>Traversable</interfacename> object, containing plugin | ||
name/configuration pairs. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
</sect2> | ||
|
||
<sect2 id="zend.loader.plugin-spec-broker.methods"> | ||
<title>Available Methods</title> | ||
|
||
<para> | ||
All <link linkend="zend.loader.plugin-broker.methods">PluginBroker methods</link> are | ||
available. The methods below either differ in capabilities, or are specific to this | ||
implementation. | ||
</para> | ||
|
||
<refentry id="zend.loader.plugin-spec-broker.methods.load"> | ||
<refnamediv> | ||
<refname>load</refname> | ||
<refpurpose>Resolve a plugin name to an object instance</refpurpose> | ||
</refnamediv> | ||
|
||
<refsynopsisdiv> | ||
<methodsynopsis> | ||
<methodname>load</methodname> | ||
<methodparam> | ||
<funcparams>$plugin, array $options = null</funcparams> | ||
</methodparam> | ||
</methodsynopsis> | ||
</refsynopsisdiv> | ||
|
||
<refsect1> | ||
<title>load()</title> | ||
|
||
<para> | ||
This method acts like <link | ||
linkend="zend.loader.plugin-broker.methods.load">parent</link> in all ways. | ||
However, if a specification has been loaded previously via the constructor, | ||
<methodname>setOptions()</methodname>, or | ||
<methodname>registerSpec()</methodname>, those options will be used if | ||
<varname>$options</varname> is null. | ||
</para> | ||
</refsect1> | ||
</refentry> | ||
|
||
<refentry id="zend.loader.plugin-spec-broker.methods.register-spec"> | ||
<refnamediv> | ||
<refname>registerSpec</refname> | ||
<refpurpose>Register a plugin specification by name</refpurpose> | ||
</refnamediv> | ||
|
||
<refsynopsisdiv> | ||
<methodsynopsis> | ||
<methodname>registerSpec</methodname> | ||
<methodparam> | ||
<funcparams>$name, array $spec = null</funcparams> | ||
</methodparam> | ||
</methodsynopsis> | ||
</refsynopsisdiv> | ||
|
||
<refsect1> | ||
<title>registerSpec()</title> | ||
|
||
<para> | ||
Registers a plugin specification using the given <varname>$name</varname>. The | ||
specification is simply a set of arguments to pass to the object constructor | ||
when first loaded by the broker. | ||
</para> | ||
</refsect1> | ||
</refentry> | ||
|
||
<refentry id="zend.loader.plugin-spec-broker.methods.register-specs"> | ||
<refnamediv> | ||
<refname>registerSpecs</refname> | ||
<refpurpose>Register many plugin specifications at once</refpurpose> | ||
</refnamediv> | ||
|
||
<refsynopsisdiv> | ||
<methodsynopsis> | ||
<methodname>registerSpecs</methodname> | ||
<methodparam> | ||
<funcparams>$specs</funcparams> | ||
</methodparam> | ||
</methodsynopsis> | ||
</refsynopsisdiv> | ||
|
||
<refsect1> | ||
<title>registerSpecs()</title> | ||
|
||
<para> | ||
Registers many plugin specifications at once. <varname>$specs</varname> must be | ||
an array or <interfacename>Traversable</interfacename> object. It is iterated, | ||
and the key/value pairs are passed as arguments to | ||
<methodname>registerSpec()</methodname>. | ||
</para> | ||
</refsect1> | ||
</refentry> | ||
|
||
<refentry id="zend.loader.plugin-spec-broker.methods.unregister-spec"> | ||
<refnamediv> | ||
<refname>unregisterSpec</refname> | ||
<refpurpose>Unregister a plugin specification</refpurpose> | ||
</refnamediv> | ||
|
||
<refsynopsisdiv> | ||
<methodsynopsis> | ||
<methodname>unregisterSpec</methodname> | ||
<methodparam> | ||
<funcparams>$name</funcparams> | ||
</methodparam> | ||
</methodsynopsis> | ||
</refsynopsisdiv> | ||
|
||
<refsect1> | ||
<title>unregisterSpec()</title> | ||
|
||
<para> | ||
If a plugin specficiation referenced by <varname>$name</varname> has been | ||
previously registered, that specification is removed. | ||
</para> | ||
</refsect1> | ||
</refentry> | ||
|
||
<refentry id="zend.loader.plugin-spec-broker.methods.get-registered-plugins"> | ||
<refnamediv> | ||
<refname>getRegisteredPlugins</refname> | ||
<refpurpose>Retrieve all registered plugins and specifications</refpurpose> | ||
</refnamediv> | ||
|
||
<refsynopsisdiv> | ||
<methodsynopsis> | ||
<methodname>getRegisteredPlugins</methodname> | ||
<methodparam> | ||
<funcparams></funcparams> | ||
</methodparam> | ||
</methodsynopsis> | ||
</refsynopsisdiv> | ||
|
||
<refsect1> | ||
<title>getRegisteredPlugins()</title> | ||
|
||
<para> | ||
Retrieves the names of all loaded plugins, as well as all plugin specifications | ||
registered. | ||
</para> | ||
</refsect1> | ||
</refentry> | ||
|
||
<refentry id="zend.loader.plugin-spec-broker.methods.has-plugin"> | ||
<refnamediv> | ||
<refname>hasPlugin</refname> | ||
<refpurpose>Determine if a plugin has been loaded or registered</refpurpose> | ||
</refnamediv> | ||
|
||
<refsynopsisdiv> | ||
<methodsynopsis> | ||
<methodname>hasPlugin</methodname> | ||
<methodparam> | ||
<funcparams>$name</funcparams> | ||
</methodparam> | ||
</methodsynopsis> | ||
</refsynopsisdiv> | ||
|
||
<refsect1> | ||
<title>hasPlugin()</title> | ||
|
||
<para> | ||
Use this method to determine whether or not the plugin by the name of | ||
<varname>$name</varname> has been loaded or registered, or whether or not a | ||
plugin specification has been provided. | ||
</para> | ||
</refsect1> | ||
</refentry> | ||
</sect2> | ||
</sect1> |
Oops, something went wrong.