Skip to content

Commit

Permalink
Update upgrade file with AsProductVariantResolver attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
NoResponseMate committed Jun 16, 2023
1 parent 8a16711 commit f03b8a1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions UPGRADE-1.13.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
1. Not passing `Doctrine\Persistence\ObjectManager` to `Sylius\Component\Core\Updater\UnpaidOrdersStateUpdater`
as a fifth argument is deprecated.

1. To allow to autoconfigure order processors and cart context and define a priority for them in `1.13` we have introduced
`Sylius\Bundle\OrderBundle\Attribute\AsCartContext` and `Sylius\Bundle\OrderBundle\Attribute\AsOrderProcessor` attributes. By default, Sylius still configures them using interfaces, but this way you cannot define a priority.
1. To ease customization we've introduces attributes for some services in `1.13`:
- `Sylius\Bundle\OrderBundle\Attribute\AsCartContext` for cart contexts
- `Sylius\Bundle\OrderBundle\Attribute\AsOrderProcessor` for order processors
- `Sylius\Bundle\ProductBundle\Attribute\AsProductVariantResolver` for product variant resolvers

By default, Sylius still configures them using interfaces, but this way you cannot define a priority.
If you want to define a priority, you need to set the following configuration in your `_sylius.yaml` file:
```yaml
sylius_core:
autoconfigure_with_attributes: true
```
and use one of the new attributes accordingly to a type of your class, e.g.:
and use one of the new attributes accordingly to the type of your class, e.g.:
```php
<?php

Expand All @@ -35,8 +39,7 @@
use Sylius\Component\Order\Model\OrderInterface;
use Sylius\Component\Order\Processor\OrderProcessorInterface;

#[AsOrderProcessor(priority: 10)] //priority is optional
//#[AsOrderProcessor] can be used as well
#[AsOrderProcessor(/*priority: 10*/)] //priority is optional
final class OrderProcessorWithAttributeStub implements OrderProcessorInterface
{
public function process(OrderInterface $order): void
Expand Down Expand Up @@ -72,7 +75,7 @@
depending on your Guzzle version.
Subsequently, you need to register the adapter as a `Psr\Http\Client\ClientInterface` service as the following:
```yaml
services:
services:
Psr\Http\Client\ClientInterface:
class: Http\Adapter\Guzzle7\Client # for Guzzle 6 use Http\Adapter\Guzzle6\Client instead
```
Expand Down Expand Up @@ -111,6 +114,3 @@

All internal usages of service `sylius.product_variant_resolver.default` have been switched to `Sylius\Component\Product\Resolver\ProductVariantResolverInterface`, if you have been using the
`sylius.product_variant_resolver.default` service apply this change accordingly.

To add a new product variant resolver, you need to create a service implementing `Sylius\Component\Product\Resolver\ProductVariantResolverInterface`
and tag it with `sylius.product_variant_resolver` with an appropriate priority.

0 comments on commit f03b8a1

Please sign in to comment.