Skip to content

Commit 3246095

Browse files
committed
Replace Annotation\Route with Attribute\Route
Inspired by #19619 :)
1 parent 58e888b commit 3246095

19 files changed

+59
-59
lines changed

cache.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ In the following example, the value is requested from a controller::
910910

911911
use App\Cache\CacheComputation;
912912
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
913-
use Symfony\Component\Routing\Annotation\Route;
913+
use Symfony\Component\Routing\Attribute\Route;
914914
use Symfony\Contracts\Cache\CacheInterface;
915915
use Symfony\Contracts\Cache\ItemInterface;
916916

configuration/micro_kernel_trait.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Next, create an ``index.php`` file that defines the kernel class and runs it:
3232
use Symfony\Component\HttpFoundation\JsonResponse;
3333
use Symfony\Component\HttpFoundation\Request;
3434
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
35-
use Symfony\Component\Routing\Annotation\Route;
35+
use Symfony\Component\Routing\Attribute\Route;
3636
3737
require __DIR__.'/vendor/autoload.php';
3838
@@ -390,7 +390,7 @@ has one file in it::
390390

391391
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
392392
use Symfony\Component\HttpFoundation\Response;
393-
use Symfony\Component\Routing\Annotation\Route;
393+
use Symfony\Component\Routing\Attribute\Route;
394394

395395
class MicroController extends AbstractController
396396
{

controller.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class::
2323
namespace App\Controller;
2424

2525
use Symfony\Component\HttpFoundation\Response;
26-
use Symfony\Component\Routing\Annotation\Route;
26+
use Symfony\Component\Routing\Attribute\Route;
2727

2828
class LuckyController
2929
{
@@ -763,7 +763,7 @@ method::
763763

764764
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
765765
use Symfony\Component\HttpFoundation\Response;
766-
use Symfony\Component\Routing\Annotation\Route;
766+
use Symfony\Component\Routing\Attribute\Route;
767767
use Symfony\Component\WebLink\Link;
768768

769769
class HomepageController extends AbstractController

controller/service.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ apply the ``controller.service_arguments`` tag to your controller services::
6666

6767
use Symfony\Component\HttpFoundation\Response;
6868
use Symfony\Component\HttpKernel\Attribute\AsController;
69-
use Symfony\Component\Routing\Annotation\Route;
69+
use Symfony\Component\Routing\Attribute\Route;
7070

7171
#[AsController]
7272
class HelloController
@@ -95,7 +95,7 @@ a service like: ``App\Controller\HelloController::index``:
9595
namespace App\Controller;
9696
9797
use Symfony\Component\HttpFoundation\Response;
98-
use Symfony\Component\Routing\Annotation\Route;
98+
use Symfony\Component\Routing\Attribute\Route;
9999
100100
class HelloController
101101
{
@@ -157,7 +157,7 @@ which is a common practice when following the `ADR pattern`_
157157
namespace App\Controller;
158158
159159
use Symfony\Component\HttpFoundation\Response;
160-
use Symfony\Component\Routing\Annotation\Route;
160+
use Symfony\Component\Routing\Attribute\Route;
161161
162162
#[Route('/hello/{name}', name: 'hello')]
163163
class Hello

controller/upload_file.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Finally, you need to update the code of the controller that handles the form::
124124
use Symfony\Component\HttpFoundation\File\UploadedFile;
125125
use Symfony\Component\HttpFoundation\Request;
126126
use Symfony\Component\HttpFoundation\Response;
127-
use Symfony\Component\Routing\Annotation\Route;
127+
use Symfony\Component\Routing\Attribute\Route;
128128
use Symfony\Component\String\Slugger\SluggerInterface;
129129

130130
class ProductController extends AbstractController

controller/value_resolver.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Symfony ships with the following value resolvers in the
147147
namespace App\Controller;
148148

149149
use Symfony\Component\HttpFoundation\Response;
150-
use Symfony\Component\Routing\Annotation\Route;
150+
use Symfony\Component\Routing\Attribute\Route;
151151
use Symfony\Component\Uid\UuidV4;
152152

153153
class DefaultController
@@ -201,7 +201,7 @@ In addition, some components, bridges and official bundles provide other value r
201201
namespace App\Controller;
202202

203203
use Symfony\Component\HttpFoundation\Response;
204-
use Symfony\Component\Routing\Annotation\Route;
204+
use Symfony\Component\Routing\Attribute\Route;
205205

206206
class DefaultController
207207
{
@@ -250,7 +250,7 @@ lets you do this by "targeting" the resolver you want::
250250
use Symfony\Component\HttpFoundation\Session\SessionInterface;
251251
use Symfony\Component\HttpKernel\Attribute\ValueResolver;
252252
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver;
253-
use Symfony\Component\Routing\Annotation\Route;
253+
use Symfony\Component\Routing\Attribute\Route;
254254

255255
class SessionController
256256
{

doctrine.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ and save it::
356356
use App\Entity\Product;
357357
use Doctrine\ORM\EntityManagerInterface;
358358
use Symfony\Component\HttpFoundation\Response;
359-
use Symfony\Component\Routing\Annotation\Route;
359+
use Symfony\Component\Routing\Attribute\Route;
360360

361361
class ProductController extends AbstractController
362362
{
@@ -438,7 +438,7 @@ Consider the following controller code::
438438

439439
use App\Entity\Product;
440440
use Symfony\Component\HttpFoundation\Response;
441-
use Symfony\Component\Routing\Annotation\Route;
441+
use Symfony\Component\Routing\Attribute\Route;
442442
use Symfony\Component\Validator\Validator\ValidatorInterface;
443443
// ...
444444

@@ -502,7 +502,7 @@ be able to go to ``/product/1`` to see your new product::
502502
use App\Entity\Product;
503503
use Doctrine\ORM\EntityManagerInterface;
504504
use Symfony\Component\HttpFoundation\Response;
505-
use Symfony\Component\Routing\Annotation\Route;
505+
use Symfony\Component\Routing\Attribute\Route;
506506
// ...
507507

508508
class ProductController extends AbstractController
@@ -535,7 +535,7 @@ and injected by the dependency injection container::
535535
use App\Entity\Product;
536536
use App\Repository\ProductRepository;
537537
use Symfony\Component\HttpFoundation\Response;
538-
use Symfony\Component\Routing\Annotation\Route;
538+
use Symfony\Component\Routing\Attribute\Route;
539539
// ...
540540

541541
class ProductController extends AbstractController
@@ -624,7 +624,7 @@ automatically! You can simplify the controller to::
624624
use App\Entity\Product;
625625
use App\Repository\ProductRepository;
626626
use Symfony\Component\HttpFoundation\Response;
627-
use Symfony\Component\Routing\Annotation\Route;
627+
use Symfony\Component\Routing\Attribute\Route;
628628
// ...
629629

630630
class ProductController extends AbstractController
@@ -700,7 +700,7 @@ the ``EntityValueResolver`` behavior by using the `MapEntity options`_ ::
700700
use App\Entity\Product;
701701
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
702702
use Symfony\Component\HttpFoundation\Response;
703-
use Symfony\Component\Routing\Annotation\Route;
703+
use Symfony\Component\Routing\Attribute\Route;
704704
// ...
705705

706706
class ProductController extends AbstractController
@@ -841,7 +841,7 @@ with any PHP model::
841841
use App\Repository\ProductRepository;
842842
use Doctrine\ORM\EntityManagerInterface;
843843
use Symfony\Component\HttpFoundation\Response;
844-
use Symfony\Component\Routing\Annotation\Route;
844+
use Symfony\Component\Routing\Attribute\Route;
845845
// ...
846846

847847
class ProductController extends AbstractController

doctrine/associations.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Now you can see this new code in action! Imagine you're inside a controller::
312312
use App\Entity\Product;
313313
use Doctrine\ORM\EntityManagerInterface;
314314
use Symfony\Component\HttpFoundation\Response;
315-
use Symfony\Component\Routing\Annotation\Route;
315+
use Symfony\Component\Routing\Attribute\Route;
316316

317317
class ProductController extends AbstractController
318318
{

mailer.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object::
470470
use Symfony\Component\HttpFoundation\Response;
471471
use Symfony\Component\Mailer\MailerInterface;
472472
use Symfony\Component\Mime\Email;
473-
use Symfony\Component\Routing\Annotation\Route;
473+
use Symfony\Component\Routing\Attribute\Route;
474474

475475
class MailerController extends AbstractController
476476
{
@@ -1629,7 +1629,7 @@ Here's an example of making one available to download::
16291629
use Symfony\Component\HttpFoundation\Response;
16301630
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
16311631
use Symfony\Component\Mime\DraftEmail;
1632-
use Symfony\Component\Routing\Annotation\Route;
1632+
use Symfony\Component\Routing\Attribute\Route;
16331633

16341634
class DownloadEmailController extends AbstractController
16351635
{

page_creation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ metadata to code):
6969
// src/Controller/LuckyController.php
7070
7171
// ...
72-
+ use Symfony\Component\Routing\Annotation\Route;
72+
+ use Symfony\Component\Routing\Attribute\Route;
7373
7474
class LuckyController
7575
{

quick_tour/flex_recipes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Thanks to Flex, after one command, you can start using Twig immediately:
7979
// src/Controller/DefaultController.php
8080
namespace App\Controller;
8181
82-
use Symfony\Component\Routing\Annotation\Route;
82+
use Symfony\Component\Routing\Attribute\Route;
8383
- use Symfony\Component\HttpFoundation\Response;
8484
+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8585
@@ -157,7 +157,7 @@ Are you building an API? You can already return JSON from any controller::
157157

158158
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
159159
use Symfony\Component\HttpFoundation\JsonResponse;
160-
use Symfony\Component\Routing\Annotation\Route;
160+
use Symfony\Component\Routing\Attribute\Route;
161161

162162
class DefaultController extends AbstractController
163163
{

quick_tour/the_architecture.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use the logger in a controller, add a new argument type-hinted with ``LoggerInte
2727
use Psr\Log\LoggerInterface;
2828
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2929
use Symfony\Component\HttpFoundation\Response;
30-
use Symfony\Component\Routing\Annotation\Route;
30+
use Symfony\Component\Routing\Attribute\Route;
3131

3232
class DefaultController extends AbstractController
3333
{
@@ -108,7 +108,7 @@ Great! You can use it immediately in your controller::
108108
use Psr\Log\LoggerInterface;
109109
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
110110
use Symfony\Component\HttpFoundation\Response;
111-
use Symfony\Component\Routing\Annotation\Route;
111+
use Symfony\Component\Routing\Attribute\Route;
112112

113113
class DefaultController extends AbstractController
114114
{

quick_tour/the_big_picture.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Instead, add the route *right above* the controller method:
154154
namespace App\Controller;
155155
156156
use Symfony\Component\HttpFoundation\Response;
157-
+ use Symfony\Component\Routing\Annotation\Route;
157+
+ use Symfony\Component\Routing\Attribute\Route;
158158
159159
class DefaultController
160160
{
@@ -173,7 +173,7 @@ in ``DefaultController``::
173173
namespace App\Controller;
174174

175175
use Symfony\Component\HttpFoundation\Response;
176-
use Symfony\Component\Routing\Annotation\Route;
176+
use Symfony\Component\Routing\Attribute\Route;
177177

178178
class DefaultController
179179
{

0 commit comments

Comments
 (0)