One approach to resolving plugin names to class names utilizes prefix/path pairs. In this methodology, the developer specifies one or more directories containing plugins that have a common namespace or prefix. When resolving a plugin, the mapper will loop through these prefixes, and look for a class file matching the requested plugin; if found, that plugin class is loaded from the file and used. The PrefixPathMapper interface defines a common interface for specifying and modifying a map of prefix/path pairs.
The PrefixPathMapper provides simply two methods: one for registering a prefix path, and another for removing one.
1 2 3 4 5 6 7 | namespace Zend\Loader;
interface PrefixPathMapper
{
public function addPrefixPath($prefix, $path);
public function removePrefixPath($prefix, $path);
}
|
This component defines no configuration options, as it is an interface.
Register a prefix/path association addPrefixPath($prefix, $path)
addPrefixPath() Implement this method to allow registering a prefix/path pair. The prefix may be either an older, PHP 5.2-style vendor prefix or a true PHP 5.3 namespace; the path should be a path to a directory of files using the given prefix or namespace. The implemenation should determine whether or not to aggregate paths for each namespace, or simply maintain a 1:1 association.
Remove a prefix/path association removePrefixPath($prefix, $path)
removePrefixPath() Implement this method to remove a prefix/path association from the internal map.
Please see the Quick Start for the interface specification.
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.