From 13500d92ee446167ddfeb1fad096afe877a52e80 Mon Sep 17 00:00:00 2001 From: Micha Hobert Date: Mon, 18 Dec 2023 15:20:38 +0100 Subject: [PATCH 1/4] 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)]); From bff3b4e6188c6062051f207df5d44b13facbdc40 Mon Sep 17 00:00:00 2001 From: Micha Hobert Date: Mon, 18 Dec 2023 15:47:02 +0100 Subject: [PATCH 2/4] Add _httpCache --- concepts/framework/http_cache.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concepts/framework/http_cache.md b/concepts/framework/http_cache.md index 33449573d..304a31a90 100644 --- a/concepts/framework/http_cache.md +++ b/concepts/framework/http_cache.md @@ -40,10 +40,10 @@ The Shopware HTTP cache has a variety of mechanisms to answer these questions. ## When will the page be cached? -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). +Set the defaults value of the `_httpCache` key to `true`. Examples for this can be found in the [ProductController](https://github.com/shopware/shopware/blob/trunk/src/Storefront/Controller/ProductController.php#L62). ```php -#[Route(path: '/detail/{productId}', name: 'frontend.detail.page', methods: ['GET'])] +#[Route(path: '/detail/{productId}', name: 'frontend.detail.page', methods: ['GET'], defaults: ['_httpCache' => true])] public function index(SalesChannelContext $context, Request $request): Response ``` From 2af0b74a9827b3dfa49135fde2e4e007b68a15eb Mon Sep 17 00:00:00 2001 From: Micha Hobert Date: Mon, 18 Dec 2023 15:50:58 +0100 Subject: [PATCH 3/4] Fix wrong replaces --- .../plugins/plugins/content/seo/add-custom-seo-url.md | 4 +--- .../rate-limiter/add-rate-limiter-to-api-route.md | 10 ++++------ .../store-api/add-caching-for-store-api-route.md | 5 +---- .../storefront/add-caching-to-custom-controller.md | 6 ++---- .../plugins/storefront/add-custom-controller.md | 10 +++------- guides/plugins/plugins/storefront/add-custom-page.md | 4 +--- 6 files changed, 12 insertions(+), 27 deletions(-) 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 8d70a449c..6b87e458c 100644 --- a/guides/plugins/plugins/content/seo/add-custom-seo-url.md +++ b/guides/plugins/plugins/content/seo/add-custom-seo-url.md @@ -57,9 +57,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class ExampleController extends StorefrontController { - /** - * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] - */ + #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] public function showExample(): Response { return $this->renderStorefront('@SwagBasicExample/storefront/page/example/index.html.twig', [ 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 af9070b3d..7e81e5042 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 @@ -150,9 +150,8 @@ If the limit has been exceeded, it throws `Shopware\Core\Framework\RateLimiter\E ```php // /src/Core/Content/Example/SalesChannel/ExampleRoute.php -/** - * #[Route(path: '/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 { // Limit ip address @@ -169,9 +168,8 @@ We just have to call the `reset` method as you can see below. ```php // /src/Core/Content/Example/SalesChannel/ExampleRoute.php -/** - * #[Route(path: '/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 { // Limit ip address for example 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 d3ee92f8c..536ccb6bb 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 @@ -90,10 +90,7 @@ class CachedExampleRoute extends AbstractExampleRoute return $this->decorated; } - /** - * @Entity("swag_example") - * #[Route(path: '/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 { // The context is provided with a state where the route cannot be cached 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 48915077c..7cf0da333 100644 --- a/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md +++ b/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md @@ -43,10 +43,8 @@ use Symfony\Component\Routing\Annotation\Route; */ class ExampleController extends StorefrontController { - /** - * @HttpCache() - * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] - */ + + #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'], defaults: ['_httpCache' => true])] public function showExample(): Response { return $this->renderStorefront('@SwagBasicExample/storefront/page/example/index.html.twig', [ diff --git a/guides/plugins/plugins/storefront/add-custom-controller.md b/guides/plugins/plugins/storefront/add-custom-controller.md index de88170a1..e553cde0c 100644 --- a/guides/plugins/plugins/storefront/add-custom-controller.md +++ b/guides/plugins/plugins/storefront/add-custom-controller.md @@ -68,9 +68,7 @@ use Symfony\Component\Routing\Annotation\Route; */ class ExampleController extends StorefrontController { - /** - * #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] - */ + #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] public function showExample(): Response { return $this->renderStorefront('@SwagBasicExample/storefront/page/example.html.twig', [ @@ -191,10 +189,8 @@ use Symfony\Component\Routing\Annotation\Route; * @Route(defaults={"_routeScope"={"storefront"}}) */ class ExampleController extends StorefrontController -{ - /** - * #[Route(path: '/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 6483eabb1..fe33e6086 100644 --- a/guides/plugins/plugins/storefront/add-custom-page.md +++ b/guides/plugins/plugins/storefront/add-custom-page.md @@ -149,9 +149,7 @@ class ExampleController extends StorefrontController $this->examplePageLoader = $examplePageLoader; } - /** - * #[Route(path: '/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 { $page = $this->examplePageLoader->load($request, $context); From 8c96a120eac94e8ba27e23e278614750b2b86990 Mon Sep 17 00:00:00 2001 From: Micha Hobert Date: Mon, 18 Dec 2023 16:29:50 +0100 Subject: [PATCH 4/4] Change routeScope --- .../plugins/checkout/cart/add-cart-items.md | 4 +--- .../plugins/content/seo/add-custom-seo-url.md | 4 +--- .../add-rate-limiter-to-api-route.md | 4 +--- .../store-api/add-caching-for-store-api-route.md | 4 +--- .../framework/store-api/add-store-api-route.md | 8 ++------ .../store-api/override-existing-route.md | 4 +--- .../add-caching-to-custom-controller.md | 4 +--- .../plugins/storefront/add-custom-controller.md | 16 ++++------------ .../plugins/storefront/add-custom-page.md | 4 +--- .../storefront/add-data-to-storefront-page.md | 4 +--- .../add-dynamic-content-via-ajax-calls.md | 4 +--- .../guidelines/code/storefront-controller.md | 7 +++---- 12 files changed, 18 insertions(+), 49 deletions(-) diff --git a/guides/plugins/plugins/checkout/cart/add-cart-items.md b/guides/plugins/plugins/checkout/cart/add-cart-items.md index bb3490f31..c8a10bb20 100644 --- a/guides/plugins/plugins/checkout/cart/add-cart-items.md +++ b/guides/plugins/plugins/checkout/cart/add-cart-items.md @@ -42,9 +42,7 @@ use Shopware\Storefront\Framework\Routing\StorefrontResponse; use Symfony\Component\Routing\Annotation\Route; use Shopware\Core\Checkout\Cart\Cart; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { private LineItemFactoryRegistry $factory; 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 6b87e458c..6f94b2e7c 100644 --- a/guides/plugins/plugins/content/seo/add-custom-seo-url.md +++ b/guides/plugins/plugins/content/seo/add-custom-seo-url.md @@ -52,9 +52,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] 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 7e81e5042..1693226b4 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 @@ -120,9 +120,7 @@ namespace Swag\BasicExample\Core\Content\Example\SalesChannel; use Shopware\Core\Framework\RateLimiter\RateLimiter; ... -/** - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class ExampleRoute extends AbstractExampleRoute { private RateLimiter $rateLimiter; 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 536ccb6bb..5af665b57 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 @@ -51,9 +51,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -/** - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class CachedExampleRoute extends AbstractExampleRoute { private AbstractExampleRoute $decorated; 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 11cc0ec71..d7e84c0a7 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 @@ -63,9 +63,7 @@ use Shopware\Core\Framework\Routing\Annotation\Entity; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class ExampleRoute extends AbstractExampleRoute { protected EntityRepository $exampleRepository; @@ -315,9 +313,7 @@ use Swag\BasicExample\Core\Content\Example\SalesChannel\AbstractExampleRoute; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { private AbstractExampleRoute $route; 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 9fb8f5ea5..751aba565 100644 --- a/guides/plugins/plugins/framework/store-api/override-existing-route.md +++ b/guides/plugins/plugins/framework/store-api/override-existing-route.md @@ -33,9 +33,7 @@ use Shopware\Core\Framework\Routing\Annotation\Entity; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class ExampleRouteDecorator extends AbstractExampleRoute { protected EntityRepository $exampleRepository; 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 7cf0da333..eba3c2343 100644 --- a/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md +++ b/guides/plugins/plugins/storefront/add-caching-to-custom-controller.md @@ -38,9 +38,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { diff --git a/guides/plugins/plugins/storefront/add-custom-controller.md b/guides/plugins/plugins/storefront/add-custom-controller.md index e553cde0c..bb768b5d4 100644 --- a/guides/plugins/plugins/storefront/add-custom-controller.md +++ b/guides/plugins/plugins/storefront/add-custom-controller.md @@ -39,9 +39,7 @@ namespace Swag\BasicExample\Storefront\Controller; use Shopware\Storefront\Controller\StorefrontController; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { } @@ -63,9 +61,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] @@ -96,9 +92,7 @@ use Shopware\Storefront\Controller\StorefrontController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'], defaults: ['_routeScope' => 'storefront'])] @@ -185,9 +179,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'])] diff --git a/guides/plugins/plugins/storefront/add-custom-page.md b/guides/plugins/plugins/storefront/add-custom-page.md index fe33e6086..af2c1cbb7 100644 --- a/guides/plugins/plugins/storefront/add-custom-page.md +++ b/guides/plugins/plugins/storefront/add-custom-page.md @@ -33,9 +33,7 @@ use Shopware\Storefront\Controller\StorefrontController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { #[Route(path: '/example-page', name: 'frontend.example.page', methods: ['GET'])] diff --git a/guides/plugins/plugins/storefront/add-data-to-storefront-page.md b/guides/plugins/plugins/storefront/add-data-to-storefront-page.md index 482e66d37..d2211bce9 100644 --- a/guides/plugins/plugins/storefront/add-data-to-storefront-page.md +++ b/guides/plugins/plugins/storefront/add-data-to-storefront-page.md @@ -99,9 +99,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] abstract class AbstractProductCountRoute { abstract public function getDecorated(): AbstractProductCountRoute; 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 19fc0712b..d4824cfc1 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 @@ -31,9 +31,7 @@ use Shopware\Storefront\Controller\StorefrontController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Annotation\Route; -/** - * @Route(defaults={"_routeScope"={"storefront"}}) - */ +#[Route(defaults: ['_routeScope' => ['storefront']])] class ExampleController extends StorefrontController { #[Route(path: '/example', name: 'frontend.example.example', methods: ['GET'], defaults: ['XmlHttpRequest' => 'true'])] diff --git a/resources/guidelines/code/storefront-controller.md b/resources/guidelines/code/storefront-controller.md index 161c769f0..7ca90801b 100644 --- a/resources/guidelines/code/storefront-controller.md +++ b/resources/guidelines/code/storefront-controller.md @@ -9,8 +9,7 @@ nav: ## Controller -* Each controller action has to be declared with a `@Since` tag. -* Each controller action requires a `@Route` annotation. +* Each controller action requires a `#Route` attribute. * The name of the route should start with "frontend". * Each route should define the corresponding HTTP Method \(GET, POST, DELETE, PATCH\). * The function name should be concise. @@ -19,7 +18,7 @@ nav: * Use Symfony flash bags for error reporting. * Each storefront functionality has to be available inside the Store API too. * A Storefront controller should never contain business logic. -* The class requires the annotation: `@Route(defaults={"_routeScope"={"storefront"}})`. +* The class requires the attribute: `#[Route(defaults: ['_routeScope' => ['storefront']])]`. * Depending services have to be injected over the class constructor. * Depending services have to be defined in the DI-Container service definition. * Depending services have to be assigned to a private class property. @@ -29,7 +28,7 @@ nav: * A Storefront controller should never use a repository directly. The data should be fetched over a route or page loader. * Routes that load a full Storefront page should use a page loader class to load all corresponding data. -* Pages that contain data that are the same for all customers should have the `@HttpCache` annotation. +* Pages that contain data that are the same for all customers should have the `_httpCache` annotation. ## Write operations inside Storefront controllers