public function load($file, $type = null) { $path = $this->locator->locate($file); $config = Yaml::parse($path); $collection = new TrailCollection(); $collection->addResource(new FileResource($path)); // empty file if (null === $config) { $config = array(); } // not an array if (!is_array($config)) { throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $file)); } foreach ($config as $name => $config) { $config = $this->normalizeTrailConfig($config); if (isset($config['resource'])) { $root = isset($config['root']) ? $config['root'] : null; $type = isset($config['type']) ? $config['type'] : null; $this->setCurrentDir(dirname($path)); $collection->addCollection($this->import($config['resource'], $type, false, $file), $root); } else { $this->parseTrail($collection, $name, $config, $path); } } return $collection; }