4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Loader\Configurator;
14 use Symfony\Component\Routing\Loader\PhpFileLoader;
15 use Symfony\Component\Routing\RouteCollection;
18 * @author Nicolas Grekas <p@tchwork.com>
20 class RoutingConfigurator
28 public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file)
30 $this->collection = $collection;
31 $this->loader = $loader;
37 * @return ImportConfigurator
39 final public function import($resource, $type = null, $ignoreErrors = false)
41 $this->loader->setCurrentDir(\dirname($this->path));
42 $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
43 if (!\is_array($imported)) {
44 return new ImportConfigurator($this->collection, $imported);
47 $mergedCollection = new RouteCollection();
48 foreach ($imported as $subCollection) {
49 $mergedCollection->addCollection($subCollection);
52 return new ImportConfigurator($this->collection, $mergedCollection);
56 * @return CollectionConfigurator
58 final public function collection($name = '')
60 return new CollectionConfigurator($this->collection, $name);