The PrefixPathMapper Interface¶
Overview¶
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.
Quick Start¶
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);
}
|
Configuration Options¶
This component defines no configuration options, as it is an interface.
Available Methods¶
- addPrefixPath
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.
- removePrefixPath
Remove a prefix/path association removePrefixPath($prefix, $path)
removePrefixPath() Implement this method to remove a prefix/path association from the internal map.
Examples¶
Please see the Quick Start for the interface specification.