[Routing] rename Route::getLocales() to Route::getLocalizedPaths()
This commit is contained in:
parent
5e5216017a
commit
7101893b51
@ -22,7 +22,7 @@ namespace Symfony\Component\Routing\Annotation;
|
||||
class Route
|
||||
{
|
||||
private $path;
|
||||
private $locales = array();
|
||||
private $localizedPaths = array();
|
||||
private $name;
|
||||
private $requirements = array();
|
||||
private $options = array();
|
||||
@ -39,17 +39,17 @@ class Route
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (isset($data['locales'])) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "locales" on annotation "%s".', get_class($this)));
|
||||
if (isset($data['localized_paths'])) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', get_class($this)));
|
||||
}
|
||||
|
||||
if (isset($data['value'])) {
|
||||
$data[is_array($data['value']) ? 'locales' : 'path'] = $data['value'];
|
||||
$data[is_array($data['value']) ? 'localized_paths' : 'path'] = $data['value'];
|
||||
unset($data['value']);
|
||||
}
|
||||
|
||||
if (isset($data['path']) && is_array($data['path'])) {
|
||||
$data['locales'] = $data['path'];
|
||||
$data['localized_paths'] = $data['path'];
|
||||
unset($data['path']);
|
||||
}
|
||||
|
||||
@ -72,14 +72,14 @@ class Route
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setLocales(array $locales)
|
||||
public function setLocalizedPaths(array $localizedPaths)
|
||||
{
|
||||
$this->locales = $locales;
|
||||
$this->localizedPaths = $localizedPaths;
|
||||
}
|
||||
|
||||
public function getLocales(): array
|
||||
public function getLocalizedPaths(): array
|
||||
{
|
||||
return $this->locales;
|
||||
return $this->localizedPaths;
|
||||
}
|
||||
|
||||
public function setHost($pattern)
|
||||
|
@ -124,7 +124,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
if (0 === $collection->count() && $class->hasMethod('__invoke') && $annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) {
|
||||
$globals['path'] = null;
|
||||
$globals['name'] = '';
|
||||
$globals['locales'] = array();
|
||||
$globals['localized_paths'] = array();
|
||||
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
|
||||
}
|
||||
|
||||
@ -155,8 +155,8 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
$condition = $globals['condition'];
|
||||
}
|
||||
|
||||
$path = $annot->getLocales() ?: $annot->getPath();
|
||||
$prefix = $globals['locales'] ?: $globals['path'];
|
||||
$path = $annot->getLocalizedPaths() ?: $annot->getPath();
|
||||
$prefix = $globals['localized_paths'] ?: $globals['path'];
|
||||
$paths = array();
|
||||
|
||||
if (\is_array($path)) {
|
||||
@ -253,7 +253,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
{
|
||||
$globals = array(
|
||||
'path' => null,
|
||||
'locales' => array(),
|
||||
'localized_paths' => array(),
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
@ -273,7 +273,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
$globals['path'] = $annot->getPath();
|
||||
}
|
||||
|
||||
$globals['locales'] = $annot->getLocales();
|
||||
$globals['localized_paths'] = $annot->getLocalizedPaths();
|
||||
|
||||
if (null !== $annot->getRequirements()) {
|
||||
$globals['requirements'] = $annot->getRequirements();
|
||||
|
@ -53,7 +53,7 @@ class RouteTest extends TestCase
|
||||
array('methods', array('GET', 'POST'), 'getMethods'),
|
||||
array('host', '{locale}.example.com', 'getHost'),
|
||||
array('condition', 'context.getMethod() == "GET"', 'getCondition'),
|
||||
array('value', array('nl' => '/hier', 'en' => '/here'), 'getLocales'),
|
||||
array('value', array('nl' => '/hier', 'en' => '/here'), 'getLocalizedPaths'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user