Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\Routing\Loader\Configurator; Chris@14: Chris@14: use Symfony\Component\Routing\Loader\PhpFileLoader; Chris@14: use Symfony\Component\Routing\RouteCollection; Chris@14: Chris@14: /** Chris@14: * @author Nicolas Grekas
Chris@14: */ Chris@14: class RoutingConfigurator Chris@14: { Chris@14: use Traits\AddTrait; Chris@14: Chris@14: private $loader; Chris@14: private $path; Chris@14: private $file; Chris@14: Chris@14: public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file) Chris@14: { Chris@14: $this->collection = $collection; Chris@14: $this->loader = $loader; Chris@14: $this->path = $path; Chris@14: $this->file = $file; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return ImportConfigurator Chris@14: */ Chris@14: final public function import($resource, $type = null, $ignoreErrors = false) Chris@14: { Chris@17: $this->loader->setCurrentDir(\dirname($this->path)); Chris@14: $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file); Chris@17: if (!\is_array($imported)) { Chris@14: return new ImportConfigurator($this->collection, $imported); Chris@14: } Chris@14: Chris@14: $mergedCollection = new RouteCollection(); Chris@14: foreach ($imported as $subCollection) { Chris@14: $mergedCollection->addCollection($subCollection); Chris@14: } Chris@14: Chris@14: return new ImportConfigurator($this->collection, $mergedCollection); Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return CollectionConfigurator Chris@14: */ Chris@14: final public function collection($name = '') Chris@14: { Chris@14: return new CollectionConfigurator($this->collection, $name); Chris@14: } Chris@14: }