comparison vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.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\Traits;
13
14 use Symfony\Component\Routing\Route;
15 use Symfony\Component\Routing\RouteCollection;
16
17 trait RouteTrait
18 {
19 /**
20 * @var RouteCollection|Route
21 */
22 private $route;
23
24 /**
25 * Adds defaults.
26 *
27 * @return $this
28 */
29 final public function defaults(array $defaults)
30 {
31 $this->route->addDefaults($defaults);
32
33 return $this;
34 }
35
36 /**
37 * Adds requirements.
38 *
39 * @return $this
40 */
41 final public function requirements(array $requirements)
42 {
43 $this->route->addRequirements($requirements);
44
45 return $this;
46 }
47
48 /**
49 * Adds options.
50 *
51 * @return $this
52 */
53 final public function options(array $options)
54 {
55 $this->route->addOptions($options);
56
57 return $this;
58 }
59
60 /**
61 * Sets the condition.
62 *
63 * @param string $condition
64 *
65 * @return $this
66 */
67 final public function condition($condition)
68 {
69 $this->route->setCondition($condition);
70
71 return $this;
72 }
73
74 /**
75 * Sets the pattern for the host.
76 *
77 * @param string $pattern
78 *
79 * @return $this
80 */
81 final public function host($pattern)
82 {
83 $this->route->setHost($pattern);
84
85 return $this;
86 }
87
88 /**
89 * Sets the schemes (e.g. 'https') this route is restricted to.
90 * So an empty array means that any scheme is allowed.
91 *
92 * @param string[] $schemes
93 *
94 * @return $this
95 */
96 final public function schemes(array $schemes)
97 {
98 $this->route->setSchemes($schemes);
99
100 return $this;
101 }
102
103 /**
104 * Sets the HTTP methods (e.g. 'POST') this route is restricted to.
105 * So an empty array means that any method is allowed.
106 *
107 * @param string[] $methods
108 *
109 * @return $this
110 */
111 final public function methods(array $methods)
112 {
113 $this->route->setMethods($methods);
114
115 return $this;
116 }
117
118 /**
119 * Adds the "_controller" entry to defaults.
120 *
121 * @param callable|string $controller a callable or parseable pseudo-callable
122 *
123 * @return $this
124 */
125 final public function controller($controller)
126 {
127 $this->route->addDefaults(array('_controller' => $controller));
128
129 return $this;
130 }
131 }