Skip to content

Commit

Permalink
Replace old annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Isengo1989 committed Dec 18, 2023
1 parent 13cab6d commit 13500d9
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 45 deletions.
6 changes: 1 addition & 5 deletions concepts/framework/http_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
4 changes: 1 addition & 3 deletions guides/plugins/plugins/checkout/cart/add-cart-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion guides/plugins/plugins/content/seo/add-custom-seo-url.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 1 addition & 5 deletions guides/plugins/plugins/framework/event/finding-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ If the limit has been exceeded, it throws `Shopware\Core\Framework\RateLimiter\E
```php
// <plugin root>/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
{
Expand All @@ -170,7 +170,7 @@ We just have to call the `reset` method as you can see below.
```php
// <plugin root>/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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 3 additions & 5 deletions guides/plugins/plugins/storefront/add-custom-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
...
Expand Down Expand Up @@ -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
{
Expand Down
6 changes: 2 additions & 4 deletions guides/plugins/plugins/storefront/add-custom-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 1 addition & 3 deletions guides/plugins/plugins/storefront/add-custom-pagelet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
Expand Down

0 comments on commit 13500d9

Please sign in to comment.