-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Allow aliases in #[Route]
attribute
#58819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/Symfony/Component/Routing/Attribute/DeprecatedAlias.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Attribute; | ||
|
||
/** | ||
* This class is meant to be used in {@see Route} to define an alias for a route. | ||
*/ | ||
class DeprecatedAlias | ||
{ | ||
public function __construct( | ||
private string $aliasName, | ||
private string $package, | ||
private string $version, | ||
private string $message = '', | ||
) { | ||
} | ||
|
||
public function getMessage(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
public function getAliasName(): string | ||
{ | ||
return $this->aliasName; | ||
} | ||
|
||
public function getPackage(): string | ||
{ | ||
return $this->package; | ||
} | ||
|
||
public function getVersion(): string | ||
{ | ||
return $this->version; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
7.3 | ||
--- | ||
|
||
* Allow aliases and deprecations in `#[Route]` attribute | ||
|
||
7.2 | ||
--- | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/AliasClassController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures; | ||
damienfern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
#[Route('/hello', alias: ['alias', 'completely_different_name'])] | ||
fabpot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class AliasClassController | ||
{ | ||
#[Route('/world')] | ||
public function actionWorld() | ||
{ | ||
} | ||
|
||
#[Route('/symfony')] | ||
public function actionSymfony() | ||
{ | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/AliasInvokableController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures; | ||
damienfern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
#[Route('/path', name:'invokable_path', alias: ['alias', 'completely_different_name'])] | ||
class AliasInvokableController | ||
{ | ||
public function __invoke() | ||
{ | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/AliasRouteController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures; | ||
damienfern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
class AliasRouteController | ||
{ | ||
#[Route('/path', name: 'action_with_alias', alias: ['alias', 'completely_different_name'])] | ||
public function action() | ||
{ | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../Routing/Tests/Fixtures/AttributeFixtures/DeprecatedAliasCustomMessageRouteController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures; | ||
|
||
use Symfony\Component\Routing\Attribute\DeprecatedAlias; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
class DeprecatedAliasCustomMessageRouteController | ||
{ | ||
|
||
#[Route('/path', name: 'action_with_deprecated_alias', alias: new DeprecatedAlias('my_other_alias_deprecated', 'MyBundleFixture', '1.0', message: '%alias_id% alias is deprecated.'))] | ||
public function action() | ||
{ | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ony/Component/Routing/Tests/Fixtures/AttributeFixtures/DeprecatedAliasRouteController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures; | ||
|
||
use Symfony\Component\Routing\Attribute\DeprecatedAlias; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
class DeprecatedAliasRouteController | ||
{ | ||
#[Route('/path', name: 'action_with_deprecated_alias', alias: new DeprecatedAlias('my_other_alias_deprecated', 'MyBundleFixture', '1.0'))] | ||
public function action() | ||
{ | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...onent/Routing/Tests/Fixtures/AttributeFixtures/MultipleDeprecatedAliasRouteController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures; | ||
|
||
use Symfony\Component\Routing\Attribute\DeprecatedAlias; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
|
||
class MultipleDeprecatedAliasRouteController | ||
{ | ||
#[Route('/path', name: 'action_with_multiple_deprecated_alias', alias: [ | ||
new DeprecatedAlias('my_first_alias_deprecated', 'MyFirstBundleFixture', '1.0'), | ||
new DeprecatedAlias('my_second_alias_deprecated', 'MySecondBundleFixture', '2.0'), | ||
new DeprecatedAlias('my_third_alias_deprecated', 'SurprisedThirdBundleFixture', '3.0'), | ||
])] | ||
public function action() | ||
{ | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.