Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://git.zendframework.com/zf into mikaelkael
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkael committed Jun 21, 2010
2 parents 21e1e5f + e6835e3 commit 7c40ff9
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/PluginLoader/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,36 +122,49 @@ public function __construct(Array $prefixToPaths = array(), $staticRegistryName
* Format prefix for internal use
*
* @param string $prefix
* @param bool $namespaced Whether the paths are namespaced or prefixed; namespaced by default
* @return string
*/
protected function _formatPrefix($prefix)
protected function _formatPrefix($prefix, $namespaced = true)
{
if($prefix == "") {
return $prefix;
}

$last = strlen($prefix) - 1;
if ($prefix{$last} == '\\') {
return $prefix;
}

return rtrim($prefix, '\\') . '\\';
switch ($namespaced) {
case true:
$last = strlen($prefix) - 1;
if ($prefix{$last} == '\\') {
return $prefix;
}

return $prefix . '\\';
case false:
$last = strlen($prefix) - 1;
if ($prefix{$last} == '_') {
return $prefix;
}

return $prefix . '_';
}
}

/**
* Add prefixed paths to the registry of paths
*
* @param string $prefix
* @param string $path
* @param bool $namespaced Whether the paths are namespaced or prefixed; namespaced by default
* @return \Zend\Loader\PluginLoader\PluginLoader
*/
public function addPrefixPath($prefix, $path)
public function addPrefixPath($prefix, $path, $namespaced = true)
{
if (!is_string($prefix) || !is_string($path)) {
throw new Exception('Zend\\Loader\\PluginLoader::addPrefixPath() method only takes strings for prefix and path.');
}

$prefix = $this->_formatPrefix($prefix);
$prefix = $this->_formatPrefix($prefix, $namespaced);
$path = rtrim($path, '/\\') . '/';

if ($this->_useStaticRegistry) {
Expand Down

0 comments on commit 7c40ff9

Please sign in to comment.