Skip to content

Commit 192c716

Browse files
Merge branch '6.4' into 7.0
* 6.4: [AssetMapper] Handle assets with non-ascii characters in dev server [Translation] Fix `TranslationNodeVisitor` with constant domain CS fix [Routing] Remove `@final` annotation from `Route` attribute [Messenger] [AMQP] Throw exception on `nack` callback [Validator] revise Latvian translations [ErrorHandler] Fix `RecursiveDirectoryIterator` exception with wrong composer autoload [HttpFoundation] Request without content-type or content-length header should result in null values, not empty strings [Cache] Fix possible infinite loop in `CachePoolPass` grab a service from the container only if it exists [Mime] Fix undefined array key 0 when empty sender [Console] Allow '0' as a $shortcut in InputOption.php fix multi-byte code area to convert [Validator] Make it explicit when English translation differs from its resource name
2 parents d567970 + 455e5b8 commit 192c716

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

Attribute/Route.php

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
/**
1515
* @author Fabien Potencier <fabien@symfony.com>
1616
* @author Alexander M. Turek <me@derrabus.de>
17-
*
18-
* @final
1917
*/
2018
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
2119
class Route
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures;
4+
5+
use Symfony\Component\Routing\Attribute\Route;
6+
7+
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
8+
class ExtendedRoute extends Route
9+
{
10+
public function __construct(array|string $path = null, ?string $name = null, array $defaults = [])
11+
{
12+
parent::__construct("/{section<(foo|bar|baz)>}" . $path, $name, [], [], array_merge(['section' => 'foo'], $defaults));
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures;
4+
5+
use Symfony\Component\Routing\Attribute\Route;
6+
7+
#[ExtendedRoute('/class-level')]
8+
class ExtendedRouteOnClassController
9+
{
10+
#[Route(path: '/method-level', name: 'action')]
11+
public function action()
12+
{
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures;
4+
5+
class ExtendedRouteOnMethodController
6+
{
7+
#[ExtendedRoute(path: '/method-level', name: 'action')]
8+
public function action()
9+
{
10+
}
11+
}

Tests/Loader/AttributeClassLoaderTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\DefaultValueController;
2020
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\EncodingClass;
2121
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\ExplicitLocalizedActionPathController;
22+
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\ExtendedRouteOnClassController;
23+
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\ExtendedRouteOnMethodController;
2224
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\GlobalDefaultsClass;
2325
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableController;
2426
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableLocalizedController;
@@ -332,6 +334,22 @@ public function testMethodsAndSchemes()
332334
$this->assertSame(['https'], $routes->get('string')->getSchemes());
333335
}
334336

337+
public function testLoadingExtendedRouteOnClass()
338+
{
339+
$routes = $this->loader->load(ExtendedRouteOnClassController::class);
340+
$this->assertCount(1, $routes);
341+
$this->assertSame('/{section}/class-level/method-level', $routes->get('action')->getPath());
342+
$this->assertSame(['section' => 'foo'], $routes->get('action')->getDefaults());
343+
}
344+
345+
public function testLoadingExtendedRouteOnMethod()
346+
{
347+
$routes = $this->loader->load(ExtendedRouteOnMethodController::class);
348+
$this->assertCount(1, $routes);
349+
$this->assertSame('/{section}/method-level', $routes->get('action')->getPath());
350+
$this->assertSame(['section' => 'foo'], $routes->get('action')->getDefaults());
351+
}
352+
335353
public function testDefaultRouteName()
336354
{
337355
$routeCollection = $this->loader->load(EncodingClass::class);

0 commit comments

Comments
 (0)