Skip to content

Commit

Permalink
Fix ZF2-204 - Make setModulePaths accept array or Traversable
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Mar 8, 2012
1 parent 450844a commit c87466f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ModuleAutoloader.php
Expand Up @@ -259,21 +259,22 @@ public function unregister()
*/
public function registerPaths($paths)
{
if (is_array($paths) || $paths instanceof Traversable) {
foreach ($paths as $module => $path) {
if (is_string($module)) {
$this->registerPath($path, $module);
} else {
$this->registerPath($path);
}
}
} else {
if (!is_array($paths) && !$paths instanceof Traversable) {
throw new \InvalidArgumentException(
'Parameter to \\Zend\\Loader\\ModuleAutoloader\'s '
. 'registerPaths method must be an array or '
. 'implement the \\Traversable interface'
);
}

foreach ($paths as $module => $path) {
if (is_string($module)) {
$this->registerPath($path, $module);
} else {
$this->registerPath($path);
}
}

return $this;
}

Expand Down

0 comments on commit c87466f

Please sign in to comment.