Skip to content
Browse files

Fix/improve Zend\Loader docs

  • Loading branch information...
1 parent 1b3165f commit fa166d99a6591a6c49027c446a1a077fa9e768eb @robertbasic robertbasic committed Oct 4, 2012
View
30 docs/languages/en/modules/zend.loader.autoloader-factory.rst
@@ -107,6 +107,36 @@ getRegisteredAutoloaders
This method is **static**, and may be used to retrieve a list of all autoloaders registered via the
``factory()`` method. It returns simply an array of autoloader instances.
+.. _zend.loader.autoloader-factory.methods.get-registered-autoloader:
+
+getRegisteredAutoloader
+ Retrieve an autoloader by class name
+ ``getRegisteredAutoloader($class)``
+
+ **getRegisteredAutoloader()**
+ This method is **static**, and is used to retrieve a specific autoloader. It expects a string with the autoloader
+ class name. If the autoloader is not registered, an exception will be thrown.
+
+.. _zend.loader.autoloader-factory.methods.unregister-autoloaders:
+
+unregisterAutoloaders
+ Unregister all autoloaders registered via the factory.
+ ``unregisterAutoloaders()``
+
+ **unregisterAutoloaders()**
+ This method is **static**, and can be used to unregister all autoloaders that were registered via the factory.
+ Note that this will **not** unregister autoloaders that were registered outside of the factory.
+
+.. _zend.loader.autoloader-factory.methods.unregister-autoloader:
+
+unregisterAutoloader
+ Unregister an autoloader registered via the factory.
+ ``unregisterAutoloader($class)``
+
+ **unregisterAutoloader()**
+ This method is **static**, and can be used to unregister an autoloader that was registered via the factory.
+ Note that this will **not** unregister autoloaders that were registered outside of the factory. If the
+ autoloader is registered via the factory, after unregistering it will return ``TRUE``, otherwise ``FALSE``.
.. _zend.loader.autoloader-factory.examples:
View
23 docs/languages/en/modules/zend.loader.class-map-autoloader.rst
@@ -13,14 +13,9 @@ class, see if it's in the map, and, if so, load the file associated with the cla
unnecessary filesystem operations, and can also ensure the autoloader "plays nice" with opcode caches and PHP's
realpath cache.
-In order to use the ``ClassMapAutoloader``, you first need class maps. Zend Framework ships with a class map per
-component or, if you grabbed the entire ZF distribution, a class map for the entire Zend Framework. These maps are
-typically in a file named ``.classmap.php`` within either the "Zend" directory, or an individual component's source
-directory.
-
-Zend Framework also provides a tool for generating these class maps; you can find it in
-``bin/classmap_generator.php`` of the distribution. Full documentation of this too is provided in :ref:`
-<zend.loader.classmap-generator>`.
+Zend Framework provides a tool for generating these class maps; you can find it in
+``bin/classmap_generator.php`` of the distribution. Full documentation of this is provided in the :ref:`Class Map
+generator <zend.loader.classmap-generator>` section.
.. _zend.loader.class-map-autoloader.quick-start:
@@ -35,8 +30,8 @@ underneath it.
php classmap_generator.php Some/Directory/
-This will create a file named ``Some/Directory/.classmap.php``, which is a PHP file returning an associative array
-that represents the class map.
+This will create a file named ``Some/Directory/autoload_classmap.php``, which is a PHP file returning an associative
+array that represents the class map.
Within your code, you will now instantiate the ``ClassMapAutoloader``, and provide it the location of the map.
@@ -50,7 +45,7 @@ Within your code, you will now instantiate the ``ClassMapAutoloader``, and provi
$loader = new Zend\Loader\ClassMapAutoloader();
// Register the class map:
- $loader->registerAutoloadMap('Some/Directory/.classmap.php');
+ $loader->registerAutoloadMap('Some/Directory/autoload_classmap.php');
// Register with spl_autoload:
$loader->register();
@@ -77,7 +72,7 @@ The ``ClassMapAutoloader`` defines the following options.
// Configuration defining both a file-based class map, and an array map
$config = array(
- __DIR__ . '/library/.classmap.php', // file-based class map
+ __DIR__ . '/library/autoloader_classmap.php', // file-based class map
array( // array class map
'Application\Bootstrap' => __DIR__ . '/application/Bootstrap.php',
'Test\Bootstrap' => __DIR__ . '/tests/Bootstrap.php',
@@ -188,7 +183,7 @@ used to configure the autoloader:
// Configuration defining both a file-based class map, and an array map
$config = array(
- APPLICATION_PATH . '/../library/.classmap.php', // file-based class map
+ APPLICATION_PATH . '/../library/autoloader_classmap.php', // file-based class map
array( // array class map
'Application\Bootstrap' => APPLICATION_PATH . '/Bootstrap.php',
'Test\Bootstrap' => APPLICATION_PATH . '/../tests/Bootstrap.php',
@@ -200,7 +195,7 @@ An eqivalent INI style configuration might look like this:
.. code-block:: ini
:linenos:
- classmap.library = APPLICATION_PATH "/../library/.classmap.php"
+ classmap.library = APPLICATION_PATH "/../library/autoloader_classmap.php"
classmap.resources.Application\Bootstrap = APPLICATION_PATH "/Bootstrap.php"
classmap.resources.Test\Bootstrap = APPLICATION_PATH "/../tests/Bootstrap.php"
View
7 docs/languages/en/modules/zend.loader.classmap-generator.rst
@@ -21,7 +21,7 @@ Quick Start
-----------
You may run the script over any directory containing source code. By default, it will look in the current
-directory, and will write the script to ``.classmap.php`` in the directory you specify.
+directory, and will write the script to ``autoloader_classmap.php`` in the directory you specify.
.. code-block:: sh
:linenos:
@@ -43,7 +43,10 @@ Configuration Options
it will assume the current working directory.
**--output or -o**
- Where to write the autoload class map file. If not provided, assumes ".classmap.php" in the library directory.
+ Where to write the autoload class map file. If not provided, assumes "autoload_classmap.php" in the library directory.
+
+**--append or -a**
+ Append to autoload file if it exists.
**--overwrite or -w**
If an autoload class map file already exists with the name as specified via the ``--output`` option, you can
View
28 docs/languages/en/modules/zend.loader.plugin-class-loader.rst
@@ -33,29 +33,29 @@ name associations, and then using it to retrieve the class name associated with
.. code-block:: php
:linenos:
- use Zend\View\HelperLoader;
+ use Zend\Http\HeaderLoader;
// Provide a global map, or override defaults:
- HelperLoader::addStaticMap(array(
- 'url' => 'My\Custom\UrlHelper',
+ HeaderLoader::addStaticMap(array(
+ 'xrequestedfor' => 'My\Http\Header\XRequestedFor',
));
// Instantiate the loader:
- $loader = new Zend\View\HelperLoader();
+ $loader = new Zend\Http\HeaderLoader();
// Register a new plugin:
- $loader->registerPlugin('bugUrl', 'My\Custom\BugUrlHelper');
+ $loader->registerPlugin('xForwardedFor', 'My\Http\Header\XForwardedFor');
// Load/retrieve the associated plugin class:
- $class = $loader->load('url'); // 'My\Custom\UrlHelper'
+ $class = $loader->load('xrequestedfor'); // 'My\Http\Header\XRequestedFor'
.. note::
**Case Sensitivity**
The ``PluginClassLoader`` is designed to do case-insensitive plugin name lookups. While the above example
- defines a "bugUrl" plugin name, internally, this will be stored as simply "bugurl". If another plugin is
- registered with simply a different word case, it will overwrite this entry.
+ defines a "xForwarededFor" plugin name, internally, this will be stored as simply "xforwardedfor". If another
+ plugin is registered with simply a different word case, it will overwrite this entry.
.. _zend.loader.plugin-class-loader.options:
@@ -219,7 +219,7 @@ This can be done using the ``addStaticMap()`` method:
use Zend\Loader\PluginClassLoader;
PluginClassLoader::addStaticMap(array(
- 'url' => 'Zend\View\Helper\Url',
+ 'xrequestedfor' => 'My\Http\Header\XRequestedFor',
));
Any later instances created will now have this map defined, allowing you to load that plugin.
@@ -230,7 +230,7 @@ Any later instances created will now have this map defined, allowing you to load
use Zend\Loader\PluginClassLoader;
$loader = new PluginClassLoader();
- $helper = $loader->load('url'); // Zend\View\Helper\Url
+ $class = $loader->load('xrequestedfor'); // My\Http\Header\XRequestedFor
.. _zend.loader.plugin-class-loader.examples.extended-loader:
@@ -290,7 +290,7 @@ To inject the static map, use the extending class' name to call the static ``add
:linenos:
PluginLoader::addStaticMap(array(
- 'url' => 'Zend\View\Helper\Url',
+ 'baz' => 'My\Plugins\Baz',
));
.. _zend.loader.plugin-class-loader.examples.using-as-plugin-map:
@@ -314,7 +314,7 @@ passed to the constructor or ``registerPlugins()``.
namespace My\Plugins;
use Zend\Loader\PluginClassLoader;
- use Zend\View\Helper\HelperLoader;
+ use Zend\Http\HeaderLoader;
class PluginLoader extends PluginClassLoader
{
@@ -329,8 +329,8 @@ passed to the constructor or ``registerPlugins()``.
}
// Inject in constructor:
- $loader = new HelperLoader('My\Plugins\PluginLoader');
- $loader = new HelperLoader(new PluginLoader());
+ $loader = new HeaderLoader('My\Plugins\PluginLoader');
+ $loader = new HeaderLoader(new PluginLoader());
// Or via registerPlugins():
$loader->registerPlugins('My\Plugins\PluginLoader');
View
3 docs/languages/en/modules/zend.loader.short-name-locator.rst
@@ -23,8 +23,7 @@ alias an alternate class to utilize.
Classes implementing the ``ShortNameLocator`` interface provide a mechanism for resolving a short name to a fully
qualified class name; how they do so is left to the implementers, and may combine strategies defined by other
-interfaces, such as :ref:`PluginClassLocator <zend.loader.plugin-class-locator>` or :ref:`PrefixPathMapper
-<zend.loader.prefix-path-mapper>`.
+interfaces, such as :ref:`PluginClassLocator <zend.loader.plugin-class-locator>`.
.. _zend.loader.short-name-locator.quick-start:
View
12 docs/languages/en/modules/zend.loader.spl-autoloader.rst
@@ -75,6 +75,18 @@ registered directories.
}
}
+To use this ``ModifiedIncludePathAutoloader`` from the previous example:
+
+.. code-block:: php
+ :linenos:
+
+ $options = array(
+ '/path/one',
+ '/path/two'
+ );
+ $autoloader = new Custom\ModifiedIncludePathAutoloader($options);
+ $autoloader->register();
+
.. _zend.loader.spl-autoloader.options:
Configuration Options
View
6 docs/languages/en/modules/zend.loader.standard-autoloader.rst
@@ -99,7 +99,7 @@ directory above where its own classfile is located on the filesystem.
The ``StandardAutoloader`` may also be configured at instantiation. Please note:
-- The argument passed may be either an array or a ``Traversable`` object (such as a ``Zend\Config`` object.
+- The argument passed may be either an array or a ``Traversable`` object.
- The argument passed is also a valid argument for passing to the ``setOptions()`` method.
@@ -135,7 +135,7 @@ The ``StandardAutoloader`` defines the following options.
**namespaces**
An associative array of namespace/path pairs. The path should be an absolute path or path relative to the
calling script, and contain only classes that live in that namespace (or its subnamespaces). By default, the
- "Zend" namespace is registered, pointing to the arent directory of the file defining the ``StandardAutoloader``.
+ "Zend" namespace is registered, pointing to the parent directory of the file defining the ``StandardAutoloader``.
**prefixes**
An associative array of vendor prefix/path pairs. The path should be an absolute path or path relative to the
@@ -173,7 +173,7 @@ setOptions
**setOptions()**
Takes an argument of either an associative array or ``Traversable`` object. Recognized keys are detailed under
- :ref:` <zend.loader.standard-autoloader.options>`, with the following behaviors:
+ :ref:`Configuration options <zend.loader.standard-autoloader.options>`, with the following behaviors:
- The ``namespaces`` value will be passed to :ref:`registerNamespaces()
<zend.loader.standard-autoloader.methods.register-namespaces>`.

0 comments on commit fa166d9

Please sign in to comment.
Something went wrong with that request. Please try again.