public function load($resource)
{
$dir = $this->getAbsolutePath(substr($resource, 12));
if (!file_exists($dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist (in: %s).', $dir, implode(', ', $this->paths)));
}
$collection = new RouteCollection();
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) {
continue;
}
if ($class = $this->findClass($file)) {
$collection->addCollection($this->loader->load($class));
}
}
return $collection;
}