Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
29 * | 29 * |
30 * @param array $options An array of options | 30 * @param array $options An array of options |
31 * | 31 * |
32 * @return string A PHP class representing the generator class | 32 * @return string A PHP class representing the generator class |
33 */ | 33 */ |
34 public function dump(array $options = array()) | 34 public function dump(array $options = []) |
35 { | 35 { |
36 $options = array_merge(array( | 36 $options = array_merge([ |
37 'class' => 'ProjectUrlGenerator', | 37 'class' => 'ProjectUrlGenerator', |
38 'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', | 38 'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', |
39 ), $options); | 39 ], $options); |
40 | 40 |
41 return <<<EOF | 41 return <<<EOF |
42 <?php | 42 <?php |
43 | 43 |
44 use Symfony\Component\Routing\RequestContext; | 44 use Symfony\Component\Routing\RequestContext; |
74 * | 74 * |
75 * @return string PHP code | 75 * @return string PHP code |
76 */ | 76 */ |
77 private function generateDeclaredRoutes() | 77 private function generateDeclaredRoutes() |
78 { | 78 { |
79 $routes = "array(\n"; | 79 $routes = "[\n"; |
80 foreach ($this->getRoutes()->all() as $name => $route) { | 80 foreach ($this->getRoutes()->all() as $name => $route) { |
81 $compiledRoute = $route->compile(); | 81 $compiledRoute = $route->compile(); |
82 | 82 |
83 $properties = array(); | 83 $properties = []; |
84 $properties[] = $compiledRoute->getVariables(); | 84 $properties[] = $compiledRoute->getVariables(); |
85 $properties[] = $route->getDefaults(); | 85 $properties[] = $route->getDefaults(); |
86 $properties[] = $route->getRequirements(); | 86 $properties[] = $route->getRequirements(); |
87 $properties[] = $compiledRoute->getTokens(); | 87 $properties[] = $compiledRoute->getTokens(); |
88 $properties[] = $compiledRoute->getHostTokens(); | 88 $properties[] = $compiledRoute->getHostTokens(); |
89 $properties[] = $route->getSchemes(); | 89 $properties[] = $route->getSchemes(); |
90 | 90 |
91 $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); | 91 $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); |
92 } | 92 } |
93 $routes .= ' )'; | 93 $routes .= ' ]'; |
94 | 94 |
95 return $routes; | 95 return $routes; |
96 } | 96 } |
97 | 97 |
98 /** | 98 /** |
101 * @return string PHP code | 101 * @return string PHP code |
102 */ | 102 */ |
103 private function generateGenerateMethod() | 103 private function generateGenerateMethod() |
104 { | 104 { |
105 return <<<'EOF' | 105 return <<<'EOF' |
106 public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) | 106 public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) |
107 { | 107 { |
108 if (!isset(self::$declaredRoutes[$name])) { | 108 if (!isset(self::$declaredRoutes[$name])) { |
109 throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name)); | 109 throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name)); |
110 } | 110 } |
111 | 111 |