Skip to content

Instantly share code, notes, and snippets.

@Freeaqingme
Created November 4, 2012 22:12
Show Gist options
  • Save Freeaqingme/4013995 to your computer and use it in GitHub Desktop.
Save Freeaqingme/4013995 to your computer and use it in GitHub Desktop.
<?php
class ServiceManager extends ZendServiceManager
{
public function getSubClasses($class, $directOnly = true)
{
$class .= '\\';
$length = strlen($class);
$filtered = array();
$cNames = $this->getCanonicalNames();
array_walk($cNames, function ($value, $key) use (&$filtered, $class, $directOnly, $length)
{
if (substr($key, 0, $length) != $class) {
return;
}
$strrpos = strrpos($key, '\\');
if (!$directOnly || !$strrpos || $strrpos <= $length-1) {
$filtered[$key] = $value;
}
});
return $filtered;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment