Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.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 |
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\Traits; | |
13 | |
14 use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator; | |
15 use Symfony\Component\Routing\Route; | |
16 use Symfony\Component\Routing\RouteCollection; | |
17 | |
18 trait AddTrait | |
19 { | |
20 /** | |
21 * @var RouteCollection | |
22 */ | |
23 private $collection; | |
24 | |
25 private $name = ''; | |
26 | |
27 /** | |
28 * Adds a route. | |
29 * | |
30 * @param string $name | |
31 * @param string $path | |
32 * | |
33 * @return RouteConfigurator | |
34 */ | |
35 final public function add($name, $path) | |
36 { | |
37 $parentConfigurator = $this instanceof RouteConfigurator ? $this->parentConfigurator : null; | |
38 $this->collection->add($this->name.$name, $route = new Route($path)); | |
39 | |
40 return new RouteConfigurator($this->collection, $route, '', $parentConfigurator); | |
41 } | |
42 | |
43 /** | |
44 * Adds a route. | |
45 * | |
46 * @param string $name | |
47 * @param string $path | |
48 * | |
49 * @return RouteConfigurator | |
50 */ | |
51 final public function __invoke($name, $path) | |
52 { | |
53 return $this->add($name, $path); | |
54 } | |
55 } |