8000 minor #51285 Add before/after examples to 6.3 UPGRADE guide (wouterj) · symfony/symfony@ceb0103 · GitHub
[go: up one dir, main page]

Skip to content

Commit ceb0103

Browse files
minor #51285 Add before/after examples to 6.3 UPGRADE guide (wouterj)
This PR was merged into the 6.3 branch. Discussion ---------- Add before/after examples to 6.3 UPGRADE guide | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- c5e5391 Add before/after examples to 6.3 UPGRADE guide
2 parents 6157e3c + c5e5391 commit ceb0103

File tree

1 file changed

+129
-11
lines changed

1 file changed

+129
-11
lines changed

UPGRADE-6.3.md

Lines changed: 129 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,44 @@ DoctrineBridge
2424
--------------
2525

2626
* Deprecate passing Doctrine subscribers to `ContainerAwareEventManager` class, use listeners instead
27+
28+
*Before*
29+
```php
30+
use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface;
31+
use Doctrine\ORM\Event\PostFlushEventArgs;
32+
use Doctrine\ORM\Events;
33+
34+
class InvalidateCacheSubscriber implements EventSubscriberInterface
35+
{
36+
public function getSubscribedEvents(): array
37+
{
38+
return [Events::postFlush];
39+
}
40+< 8000 /span>
41+
public function postFlush(PostFlushEventArgs $args): void
42+
{
43+
// ...
44+
}
45+
}
46+
```
47+
48+
*After*
49+
```php
50+
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
51+
use Doctrine\ORM\Event\PostFlushEventArgs;
52+
use Doctrine\ORM\Events;
53+
54+
// Instead of PHP attributes, you can also tag this service with "doctrine.event_listener"
55+
#[AsDoctrineListener(event: Events::postFlush)]
56+
class InvalidateCacheSubscriber
57+
{
58+
public function postFlush(PostFlushEventArgs $args): void
59+
{
60+
// ...
61+
}
62+
}
63+
```
64+
2765
* Deprecate `DoctrineDbalCacheAdapterSchemaSubscriber` in favor of `DoctrineDbalCacheAdapterSchemaListener`
2866
* Deprecate `MessengerTransportDoctrineSchemaSubscriber` in favor of `MessengerTransportDoctrineSchemaListener`
2967
* Deprecate `RememberMeTokenProviderDoctrineSchemaSubscriber` in favor of `RememberMeTokenProviderDoctrineSchemaListener`
@@ -65,10 +103,6 @@ FrameworkBundle
65103
/>
66104
</framework:config>
67105
```
68-
69-
FrameworkBundle
70-
---------------
71-
72106
* Deprecate the `notifier.logger_notification_listener` service, use the `notifier.notification_logger_listener` service instead
73107
* Deprecate the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
74108

@@ -126,19 +160,57 @@ Security
126160
SecurityBundle
127161
--------------
128162

129-
* Deprecate enabling bundle and not configuring it
163+
* Deprecate enabling bundle and not configuring it, either remove the bundle or configure at least one firewall
130164
* Deprecate the `security.firewalls.logout.csrf_token_generator` config option, use `security.firewalls.logout.csrf_token_manager` instead
131165

132-
Validator
133-
---------
134-
135-
* Implementing the `ConstraintViolationInterface` without implementing the `getConstraint()` method is deprecated
136-
137166
Serializer
138167
----------
139168

140169
* Deprecate `CacheableSupportsMethodInterface` in favor of the new `getSupportedTypes(?string $format)` methods
141-
* The following Normalizer classes will become final in 7.0:
170+
171+
*Before*
172+
```php
173+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
174+
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
175+
176+
class TopicNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
177+
{
178+
public function supportsNormalization($data, string $format = null, array $context = []): bool
179+
{
180+
return $data instanceof Topic;
181+
}
182+
183+
public function hasCacheableSupportsMethod(): bool
184+
{
185+
return true;
186+
}
187+
188+
// ...
189+
}
190+
```
191+
192+
*After*
193+
```php
194+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
195+
196+
class TopicNormalizer implements NormalizerInterface
197+
{
198+
public function supportsNormalization($data, string $format = null, array $context = []): bool
199+
{
200+
return $data instanceof Topic;
201+
}
202+
< A935 /td>203+
public function getSupportedTypes(?string $format): array
204+
{
205+
return [
206+
Topic::class => true,
207+
];
208+
}
209+
210+
// ...
211+
}
212+
```
213+
* The following Normalizer classes will become final in 7.0, use decoration instead of inheritance:
142214
* `ConstraintViolationListNormalizer`
143215
* `CustomNormalizer`
144216
* `DataUriNormalizer`
@@ -149,3 +221,49 @@ Serializer
149221
* `JsonSerializableNormalizer`
150222
* `ObjectNormalizer`
151223
* `PropertyNormalizer`
224+
225+
*Before*
226+
```php
227+
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
228+
229+
class TopicNormalizer extends ObjectNormalizer
230+
{
231+
// ...
232+
233+
public function normalize($topic, string $format = null, array $context = []): array
234+
{
235+
$data = parent::normalize($topic, $format, $context);
236+
237+
// ...
238+
}
239+
}
240+
```
241+
242+
*After*
243+
```php
244+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
245+
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
246+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
247+
248+
class TopicNormalizer implements NormalizerInterface
249+
{
250+
public function __construct(
251+
#[Autowire(service: 'serializer.normalizer.object')] private NormalizerInterface&DenormalizerInterface $objectNormalizer,
252+
) {
253+
}
254+
255+
public function normalize($topic, string $format = null, array $context = []): array
256+
{
257+
$data = $this->objectNormalizer->normalize($topic, $format, $context);
258+
259+
// ...
260+
}
261+
262+
// ...
263+
}
264+
```
265+
266+
Validator
267+
---------
268+
269+
* Implementing the `ConstraintViolationInterface` without implementing the `getConstraint()` method is deprecated

0 commit comments

Comments
 (0)
0