Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\Routing\Loader\Configurator; | |
13 | |
14 use Symfony\Component\Routing\Loader\PhpFileLoader; | |
15 use Symfony\Component\Routing\RouteCollection; | |
16 | |
17 /** | |
18 * @author Nicolas Grekas <p@tchwork.com> | |
19 */ | |
20 class RoutingConfigurator | |
21 { | |
22 use Traits\AddTrait; | |
23 | |
24 private $loader; | |
25 private $path; | |
26 private $file; | |
27 | |
28 public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file) | |
29 { | |
30 $this->collection = $collection; | |
31 $this->loader = $loader; | |
32 $this->path = $path; | |
33 $this->file = $file; | |
34 } | |
35 | |
36 /** | |
37 * @return ImportConfigurator | |
38 */ | |
39 final public function import($resource, $type = null, $ignoreErrors = false) | |
40 { | |
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); | |
45 } | |
46 | |
47 $mergedCollection = new RouteCollection(); | |
48 foreach ($imported as $subCollection) { | |
49 $mergedCollection->addCollection($subCollection); | |
50 } | |
51 | |
52 return new ImportConfigurator($this->collection, $mergedCollection); | |
53 } | |
54 | |
55 /** | |
56 * @return CollectionConfigurator | |
57 */ | |
58 final public function collection($name = '') | |
59 { | |
60 return new CollectionConfigurator($this->collection, $name); | |
61 } | |
62 } |