[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
|
class Route
|
||||||
{
|
{
|
||||||
private $path;
|
private $path;
|
||||||
private $locales = array();
|
private $localizedPaths = array();
|
||||||
private $name;
|
private $name;
|
||||||
private $requirements = array();
|
private $requirements = array();
|
||||||
private $options = array();
|
private $options = array();
|
||||||
@ -39,17 +39,17 @@ class Route
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $data)
|
public function __construct(array $data)
|
||||||
{
|
{
|
||||||
if (isset($data['locales'])) {
|
if (isset($data['localized_paths'])) {
|
||||||
throw new \BadMethodCallException(sprintf('Unknown property "locales" on annotation "%s".', get_class($this)));
|
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', get_class($this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['value'])) {
|
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']);
|
unset($data['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['path']) && is_array($data['path'])) {
|
if (isset($data['path']) && is_array($data['path'])) {
|
||||||
$data['locales'] = $data['path'];
|
$data['localized_paths'] = $data['path'];
|
||||||
unset($data['path']);
|
unset($data['path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,14 +72,14 @@ class Route
|
|||||||
return $this->path;
|
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)
|
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)) {
|
if (0 === $collection->count() && $class->hasMethod('__invoke') && $annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) {
|
||||||
$globals['path'] = null;
|
$globals['path'] = null;
|
||||||
$globals['name'] = '';
|
$globals['name'] = '';
|
||||||
$globals['locales'] = array();
|
$globals['localized_paths'] = array();
|
||||||
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
|
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +155,8 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
$condition = $globals['condition'];
|
$condition = $globals['condition'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $annot->getLocales() ?: $annot->getPath();
|
$path = $annot->getLocalizedPaths() ?: $annot->getPath();
|
||||||
$prefix = $globals['locales'] ?: $globals['path'];
|
$prefix = $globals['localized_paths'] ?: $globals['path'];
|
||||||
$paths = array();
|
$paths = array();
|
||||||
|
|
||||||
if (\is_array($path)) {
|
if (\is_array($path)) {
|
||||||
@ -253,7 +253,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
{
|
{
|
||||||
$globals = array(
|
$globals = array(
|
||||||
'path' => null,
|
'path' => null,
|
||||||
'locales' => array(),
|
'localized_paths' => array(),
|
||||||
'requirements' => array(),
|
'requirements' => array(),
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
'defaults' => array(),
|
'defaults' => array(),
|
||||||
@ -273,7 +273,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
$globals['path'] = $annot->getPath();
|
$globals['path'] = $annot->getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
$globals['locales'] = $annot->getLocales();
|
$globals['localized_paths'] = $annot->getLocalizedPaths();
|
||||||
|
|
||||||
if (null !== $annot->getRequirements()) {
|
if (null !== $annot->getRequirements()) {
|
||||||
$globals['requirements'] = $annot->getRequirements();
|
$globals['requirements'] = $annot->getRequirements();
|
||||||
|
@ -53,7 +53,7 @@ class RouteTest extends TestCase
|
|||||||
array('methods', array('GET', 'POST'), 'getMethods'),
|
array('methods', array('GET', 'POST'), 'getMethods'),
|
||||||
array('host', '{locale}.example.com', 'getHost'),
|
array('host', '{locale}.example.com', 'getHost'),
|
||||||
array('condition', 'context.getMethod() == "GET"', 'getCondition'),
|
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