Skip to content

Commit 4e64680

Browse files
committed
Fix the BC layer of the Route annotation for symfony 6
1 parent 36df32c commit 4e64680

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

Controller/Annotations/Route.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,31 @@ public function __construct(
8686
$env
8787
);
8888
} else {
89+
if (\is_string($data)) {
90+
$data = ['path' => $data];
91+
} elseif (!\is_array($data)) {
92+
throw new \TypeError(sprintf('"%s": Argument $data is expected to be a string or array, got "%s".', __METHOD__, get_debug_type($data)));
93+
} elseif (0 !== count($data) && [] === \array_intersect(\array_keys($data), ['path', 'name', 'requirements', 'options', 'defaults', 'host', 'methods', 'schemes', 'condition', 'priority', 'locale', 'format', 'utf8', 'stateless', 'env'])) {
94+
$localizedPaths = $data;
95+
$data = ['path' => $localizedPaths];
96+
}
97+
8998
parent::__construct(
90-
$path,
91-
$name,
92-
$requirements,
93-
$options,
94-
$defaults,
95-
$host,
96-
$methods,
97-
$schemes,
98-
$condition,
99-
$priority,
100-
$locale,
101-
$format,
102-
$utf8,
103-
$stateless,
104-
$env
99+
$data['path'] ?? $path,
100+
$data['name'] ?? $name,
101+
$data['requirements'] ?? $requirements,
102+
$data['options'] ?? $options,
103+
$data['defaults'] ?? $defaults,
104+
$data['host'] ?? $host,
105+
$data['methods'] ?? $methods,
106+
$data['schemes'] ?? $schemes,
107+
$data['condition'] ?? $condition,
108+
$data['priority'] ?? $priority,
109+
$data['locale'] ?? $locale,
110+
$data['format'] ?? $format,
111+
$data['utf8'] ?? $utf8,
112+
$data['stateless'] ?? $stateless,
113+
$data['env'] ?? $env
105114
);
106115
}
107116
}

0 commit comments

Comments
 (0)