From 13500d92ee446167ddfeb1fad096afe877a52e80 Mon Sep 17 00:00:00 2001 From: Micha Hobert Date: Mon, 18 Dec 2023 15:20:38 +0100 Subject: [PATCH] Replace old annotations --- concepts/framework/http_cache.md | 6 +----- guides/plugins/plugins/checkout/cart/add-cart-items.md | 4 +--- guides/plugins/plugins/content/seo/add-custom-seo-url.md | 2 +- guides/plugins/plugins/framework/event/finding-events.md | 6 +----- .../rate-limiter/add-rate-limiter-to-api-route.md | 4 ++-- .../store-api/add-caching-for-store-api-route.md | 2 +- .../plugins/framework/store-api/add-store-api-route.md | 9 ++------- .../framework/store-api/override-existing-route.md | 7 ++----- .../storefront/add-caching-to-custom-controller.md | 2 +- .../plugins/plugins/storefront/add-custom-controller.md | 8 +++----- guides/plugins/plugins/storefront/add-custom-page.md | 6 ++---- guides/plugins/plugins/storefront/add-custom-pagelet.md | 4 +--- .../storefront/add-dynamic-content-via-ajax-calls.md | 4 +--- 13 files changed, 19 insertions(+), 45 deletions(-) diff --git a/concepts/framework/http_cache.md b/concepts/framework/http_cache.md index 5e346f088..33449573d 100644 --- a/concepts/framework/http_cache.md +++ b/concepts/framework/http_cache.md @@ -43,11 +43,7 @@ The Shopware HTTP cache has a variety of mechanisms to answer these questions. The called route needs an `@HttpCache` annotation. Examples for this can be found in the [ProductController](https://github.com/shopware/shopware/blob/v6.3.4.1/src/Storefront/Controller/ProductController.php#L86). ```php -/** - * @Since("6.3.3.0") - * @HttpCache() - * @Route("/detail/{productId}", name="frontend.detail.page", methods={"GET"}) - */ +#[Route(path: '/detail/{productId}', name: 'frontend.detail.page', methods: ['GET'])] public function index(SalesChannelContext $context, Request $request): Response ``` diff --git a/guides/plugins/plugins/checkout/cart/add-cart-items.md b/guides/plugins/plugins/checkout/cart/add-cart-items.md index d2bc46a67..bb3490f31 100644 --- a/guides/plugins/plugins/checkout/cart/add-cart-items.md +++ b/guides/plugins/plugins/checkout/cart/add-cart-items.md @@ -57,9 +57,7 @@ class ExampleController extends StorefrontController $this->cartService = $cartService; } - /** - * @Route("/cartAdd", name="frontend.example", methods={"GET"}) - */ + #[Route(path: '/cartAdd', name: 'frontend.example', methods: ['GET'])] public function add(Cart $cart, SalesChannelContext $context): StorefrontResponse { // Create product line item diff --git a/guides/plugins/plugins/content/seo/add-custom-seo-url.md b/guides/plugins/plugins/content/seo/add-custom-seo-url.md index 2a1ec3243..8d70a449c 100644 --- a/guides/plugins/plugins/content/seo/add-custom-seo-url.md +++ b/guides/plugins/plugins/content/seo/add-custom-seo-url.md @@ -58,7 +58,7 @@ use Symfony\Component\Routing\Annotation\Route; class ExampleController extends StorefrontController { /** - * @Route("/example", name="frontend.example.example", methods={"GET"}) + * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] */ public function showExample(): Response { diff --git a/guides/plugins/plugins/framework/event/finding-events.md b/guides/plugins/plugins/framework/event/finding-events.md index d8fc61dda..4ab20870e 100644 --- a/guides/plugins/plugins/framework/event/finding-events.md +++ b/guides/plugins/plugins/framework/event/finding-events.md @@ -178,11 +178,7 @@ a `Criteria` instance. Let's have a look at an [example code](https://github.com/shopware/shopware/blob/v6.4.0.0/src/Core/Content/Product/SalesChannel/Listing/ResolveCriteriaProductListingRoute.php#L55-L59): ```php -/** - * @Since("6.2.0.0") - * @Entity("product") - * @Route("/store-api/product-listing/{categoryId}", name="store-api.product.listing", methods={"POST"}) - */ +#[Route(path: '/store-api/product-listing/{categoryId}', name: 'store-api.product.listing', methods: ['POST'], defaults: ['_entity' => 'product'])] public function load(string $categoryId, Request $request, SalesChannelContext $context, Criteria $criteria): ProductListingRouteResponse { $this->eventDispatcher->dispatch( diff --git a/guides/plugins/plugins/framework/rate-limiter/add-rate-limiter-to-api-route.md b/guides/plugins/plugins/framework/rate-limiter/add-rate-limiter-to-api-route.md index d32d0666b..af9070b3d 100644 --- a/guides/plugins/plugins/framework/rate-limiter/add-rate-limiter-to-api-route.md +++ b/guides/plugins/plugins/framework/rate-limiter/add-rate-limiter-to-api-route.md @@ -151,7 +151,7 @@ If the limit has been exceeded, it throws `Shopware\Core\Framework\RateLimiter\E ```php // /src/Core/Content/Example/SalesChannel/ExampleRoute.php /** - * @Route("/store-api/example", name="store-api.example.search", methods={"GET", "POST"}) + * #[Route(path: '/store-api/example', name: 'store-api.example.search', methods: ['GET','POST'])] */ public function load(Request $request, SalesChannelContext $context): ExampleRouteResponse { @@ -170,7 +170,7 @@ We just have to call the `reset` method as you can see below. ```php // /src/Core/Content/Example/SalesChannel/ExampleRoute.php /** - * @Route("/store-api/example", name="store-api.example.search", methods={"GET", "POST"}) + * #[Route(path: '/store-api/example', name: 'store-api.example.search', methods: ['GET','POST'])] */ public function load(Request $request, SalesChannelContext $context): ExampleRouteResponse { diff --git a/guides/plugins/plugins/framework/store-api/add-caching-for-store-api-route.md b/guides/plugins/plugins/framework/store-api/add-caching-for-store-api-route.md index 7371a2580..d3ee92f8c 100644 --- a/guides/plugins/plugins/framework/store-api/add-caching-for-store-api-route.md +++ b/guides/plugins/plugins/framework/store-api/add-caching-for-store-api-route.md @@ -92,7 +92,7 @@ class CachedExampleRoute extends AbstractExampleRoute /** * @Entity("swag_example") - * @Route("/store-api/example", name="store-api.example.search", methods={"GET", "POST"}) + * #[Route(path: '/store-api/example', name: 'store-api.example.search', methods: ['GET','POST'])] */ public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse { diff --git a/guides/plugins/plugins/framework/store-api/add-store-api-route.md b/guides/plugins/plugins/framework/store-api/add-store-api-route.md index e43fb3ca2..11cc0ec71 100644 --- a/guides/plugins/plugins/framework/store-api/add-store-api-route.md +++ b/guides/plugins/plugins/framework/store-api/add-store-api-route.md @@ -80,10 +80,7 @@ class ExampleRoute extends AbstractExampleRoute throw new DecorationPatternException(self::class); } - /** - * @Entity("swag_example") - * @Route("/store-api/example", name="store-api.example.search", methods={"GET", "POST"}) - */ + #[Route(path: '/store-api/example', name: 'store-api.example.search', methods: ['GET','POST'], defaults: ['_entity' => 'swag_example'])] public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse { return new ExampleRouteResponse($this->exampleRepository->search($criteria, $context->getContext())); @@ -330,9 +327,7 @@ class ExampleController extends StorefrontController $this->route = $route; } - /** - * @Route("/example", name="frontend.example.search", methods={"GET", "POST"}, defaults={"XmlHttpRequest"=true}) - */ + #[Route(path: '/example', name: 'frontend.example.search', methods: ['GET', 'POST'], defaults: ['XmlHttpRequest' => 'true']) public function load(Criteria $criteria, SalesChannelContext $context): Response { return $this->route->load($criteria, $context); diff --git a/guides/plugins/plugins/framework/store-api/override-existing-route.md b/guides/plugins/plugins/framework/store-api/override-existing-route.md index 43729771a..9fb8f5ea5 100644 --- a/guides/plugins/plugins/framework/store-api/override-existing-route.md +++ b/guides/plugins/plugins/framework/store-api/override-existing-route.md @@ -52,11 +52,8 @@ class ExampleRouteDecorator extends AbstractExampleRoute { return $this->decorated; } - - /** - * @Entity("swag_example") - * @Route("/store-api/example", name="store-api.example.search", methods={"GET", "POST"}) - */ + + #[Route(path: '/store-api/example', name: 'store-api.example.search', methods: ['GET', 'POST'], defaults: ['_entity' => 'category'])] public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse { // We must call this function when using the decorator approach diff --git a/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md b/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md index c51b6650b..48915077c 100644 --- a/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md +++ b/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md @@ -45,7 +45,7 @@ class ExampleController extends StorefrontController { /** * @HttpCache() - * @Route("/example", name="frontend.example.example", methods={"GET"}) + * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] */ public function showExample(): Response { diff --git a/guides/plugins/plugins/storefront/add-custom-controller.md b/guides/plugins/plugins/storefront/add-custom-controller.md index 15b513190..de88170a1 100644 --- a/guides/plugins/plugins/storefront/add-custom-controller.md +++ b/guides/plugins/plugins/storefront/add-custom-controller.md @@ -69,7 +69,7 @@ use Symfony\Component\Routing\Annotation\Route; class ExampleController extends StorefrontController { /** - * @Route("/example", name="frontend.example.example", methods={"GET"}) + * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] */ public function showExample(): Response { @@ -103,9 +103,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class ExampleController extends StorefrontController { - /** - * @Route("/example", name="frontend.example.example", methods={"GET"}, defaults={"_routeScope"={"storefront"}}) - */ + #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'], defaults: ['_routeScope' => 'storefront'])] public function showExample(): Response { ... @@ -195,7 +193,7 @@ use Symfony\Component\Routing\Annotation\Route; class ExampleController extends StorefrontController { /** - * @Route("/example", name="frontend.example.example", methods={"GET"}) + * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] */ public function showExample(Request $request, SalesChannelContext $context): Response { diff --git a/guides/plugins/plugins/storefront/add-custom-page.md b/guides/plugins/plugins/storefront/add-custom-page.md index 71e7b7882..6483eabb1 100644 --- a/guides/plugins/plugins/storefront/add-custom-page.md +++ b/guides/plugins/plugins/storefront/add-custom-page.md @@ -38,9 +38,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class ExampleController extends StorefrontController { - /** - * @Route("/example-page", name="frontend.example.page", methods={"GET"}) - */ + #[Route(path: '/example-page', name: 'frontend.example.page', methods: ['GET'])] public function examplePage(): Response { } @@ -152,7 +150,7 @@ class ExampleController extends StorefrontController } /** - * @Route("/example-page", name="frontend.example.page", methods={"GET"}) + * #[Route(path: '/example-page', name: 'frontend.example.page', methods: ['GET'])] */ public function examplePage(Request $request, SalesChannelContext $context): Response { diff --git a/guides/plugins/plugins/storefront/add-custom-pagelet.md b/guides/plugins/plugins/storefront/add-custom-pagelet.md index c059b7031..042c1a99a 100644 --- a/guides/plugins/plugins/storefront/add-custom-pagelet.md +++ b/guides/plugins/plugins/storefront/add-custom-pagelet.md @@ -175,9 +175,7 @@ Of course, in this example your `ExamplePage` struct needs a method `setExampleP As already mentioned, a pagelet can be loaded via a route if you want it to. For that case, you can simply add a new route to your controller and load the pagelet via the `ExamplePageletLoader`: ```php -/** - * @Route("/example-pagelet", name="frontend.example.pagelet", methods={"POST"}, defaults={"XmlHttpRequest"=true}) - */ +#[Route(path: '/example-pagelet', name: 'frontend.example.pagelet', methods: ['POST'], defaults: ['XmlHttpRequest' => 'true'])] public function examplePagelet(Request $request, SalesChannelContext $context): Response { $pagelet = $this->examplePageletLoader->load($request, $context); diff --git a/guides/plugins/plugins/storefront/add-dynamic-content-via-ajax-calls.md b/guides/plugins/plugins/storefront/add-dynamic-content-via-ajax-calls.md index 7a40ab0cd..19fc0712b 100644 --- a/guides/plugins/plugins/storefront/add-dynamic-content-via-ajax-calls.md +++ b/guides/plugins/plugins/storefront/add-dynamic-content-via-ajax-calls.md @@ -36,9 +36,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class ExampleController extends StorefrontController { - /** - * @Route("/example", name="frontend.example.example", defaults={"XmlHttpRequest"=true}, methods={"GET"}) - */ + #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'], defaults: ['XmlHttpRequest' => 'true'])] public function showExample(): JsonResponse { return new JsonResponse(['timestamp' => (new \DateTime())->format(\DateTimeInterface::W3C)]);