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.

Project Versions

Table Of Contents

Previous topic

The PrefixPathLoader

Next topic

Overview

This Page

Edit this document

Edit this document

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.

  1. Go to The PrefixPathMapper Interface on GitHub.
  2. Edit file contents using GitHub's text editor in your web browser
  3. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  4. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  5. Your changes are now queued for review under project's Pull requests tab on GitHub.