protected function parseDirectory(\RecursiveDirectoryIterator $iterator) { $page_tree = array(); foreach ($iterator as $file) { $item = NULL; if ($file->isFile() && strpos($file->getFilename(), '.') !== 0) { $uriProvider = new \stdClass(); // TEMP $item = new Page($file->getPathname(), $this->pages_path, $this->app['uri']->string(), (array) $this->app['config']); $this->route_map[$item->url] = $item; if ($item->id) { $this->id_map[$item->id] = $item; } } elseif ($iterator->hasChildren()) { $uriProvider = new \stdClass(); // TEMP $item = new Directory($file->getPathname(), $this->pages_path, $this->app['uri']->segments(), (array) $this->app['config']); $children = $this->parseDirectory($iterator->getChildren()); $item->add_children($children); $this->dir_map[$item->url] = $item; } if ($item) { $page_tree[] = $item; } } uasort($page_tree, function ($a, $b) { return strnatcasecmp($a->fs_path, $b->fs_path); }); return $page_tree; }