/** * Loads a config file * * @param string $name * @param null|string|boolean $group * * @return array|null */ public function load($name, $group = null) { if ($group === true) { $group = pathinfo($name, PATHINFO_FILENAME); } if ($group and $cached = $this->get($group)) { return $cached; } $name = $this->ensureDefaultFormat($name); $paths = $this->finder->findAllFiles($name); if (empty($paths)) { return false; } $config = array(); foreach ($paths as $path) { $extension = pathinfo($path, PATHINFO_EXTENSION); $handler = $this->getHandler($extension); $config = Arr::merge($config, $handler->load($path)); } if ($group) { $this->set($group, $config); } elseif ($group === null) { $this->merge($config); } return $config; }
public function testFindHandler() { $f = new Finder(); $f->addPath(__DIR__ . '/../resources/one'); $f->returnHandlers(); $this->assertInstanceOf('Fuel\\FileSystem\\File', $f->findFile('a')); $f = new Finder(); $f->addPath(__DIR__ . '/../resources/one'); $f->addPath(__DIR__ . '/../resources'); $f->asHandlers(); $this->assertInstanceOf('Fuel\\FileSystem\\File', $f->findFile('a')); $f->asHandlers(); $this->assertInstanceOf('Fuel\\FileSystem\\Directory', $f->findDir('one')); $f->returnHandlers(); $this->assertContainsOnlyInstancesOf('Fuel\\FileSystem\\File', $f->findAllFiles('a')); $this->assertContainsOnlyInstancesOf('Fuel\\FileSystem\\Directory', $f->findAllDirs('one')); }