Skip to content

Commit 147d6c9

Browse files
author
Sander De la Marche
committed
Add draft for upgrade guide
1 parent 3a01c0d commit 147d6c9

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

UPGRADE.md

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Upgrade guide
2+
3+
## JS
4+
5+
Sinds versie 5 zijn ale data attrbiuten van Bootstrap ge"namespaced". Dit wil dus zeggen dat ipv data-toggle, het nu data-*bs*-toggle is.
6+
7+
Je kan dit oplossen door een search & replace te doen door heel je project.
8+
9+
## PHP
10+
11+
### Breadcrumbs
12+
De breadcrumbs in onze core bundle zijn niet BC. Als ze nog op de oude manier werken (met de listener in de controller) dan moet je dit manueel refactoren.
13+
14+
Als het enkel annotation -> attributen is, kan je volgende Rector sets gebruiken:
15+
16+
```php
17+
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
18+
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
19+
```
20+
21+
### Pagination
22+
Sinds v5.1.0 van de core bundle is paginatie niet meer met Pagerfanta, maar met onze eigen versie. Hiervoor zijn er een aantal changes (manueel) nodig:
23+
* Vervang in de repository alle oude `Pagerfanta` objecten door onze eigen `Paginator` objecten. Beide hebben een QueryBuilder als parameter, zelfde werking.
24+
* Vervang in je template de oude Pagerfanta Twig helper door onze eigen Twig helper.
25+
```twig
26+
{{ pagination(your_paginated_items) }}
27+
```
28+
* Pas je Controllers aan naar de nieuwe werking:
29+
```php
30+
// getItems returns a Paginator object with a QueryBuilder inside.
31+
$paginatedItems = $itemRepository->getItems();
32+
33+
$paginatedItems->paginate($request->query->getInt('page', 1));
34+
```
35+
36+
### VO -> ENUM
37+
Vroeger gebruikten we veel ValueObjects, ook om simpele string values op te slaan. Sinds PHP8 hebben we hiervoor native enums.
38+
39+
Je kan je VOs dus omzetten naar enums (indien ze enkel een vaste lijst string values kunnen hebben). Zaken zoals Money, Coordinates of Range zijn nog steeds VOs. Zaken zoals Gender, Province, etc.. zijn dus enums.
40+
41+
```php
42+
enum Gender: string
43+
{
44+
case MALE = 'male';
45+
case FEMALE = 'female';
46+
}
47+
```
48+
### Annotation -> attributes
49+
Gebruik Rector, met volgende config:
50+
```php
51+
<?php
52+
53+
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
54+
use Rector\Doctrine\Set\DoctrineSetList;
55+
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector;
56+
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
57+
use Rector\Symfony\Set\SymfonySetList;
58+
use Rector\Symfony\Set\SensiolabsSetList;
59+
use Rector\Config\RectorConfig;
60+
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
61+
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
62+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
63+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
64+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
65+
66+
return function (RectorConfig $rectorConfig): void {
67+
$rectorConfig->sets([
68+
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
69+
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
70+
SymfonySetList::SYMFONY_53,
71+
SymfonySetList::SYMFONY_54,
72+
SymfonySetList::SYMFONY_60,
73+
SymfonySetList::SYMFONY_61,
74+
SymfonySetList::SYMFONY_62,
75+
SymfonySetList::SYMFONY_CODE_QUALITY,
76+
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
77+
]);
78+
79+
$rectorConfig->rules([
80+
ClassPropertyAssignToConstructorPromotionRector::class,
81+
ParamTypeFromStrictTypedPropertyRector::class,
82+
TypedPropertyFromStrictConstructorRector::class,
83+
TypedPropertyFromStrictGetterMethodReturnTypeRector::class,
84+
LongArrayToShortArrayRector::class,
85+
TypedPropertyFromAssignsRector::class,
86+
ReturnTypeFromStrictTypedPropertyRector::class,
87+
ParamTypeFromStrictTypedPropertyRector::class,
88+
RemoveUselessParamTagRector::class,
89+
]);
90+
};
91+
```
92+
93+
### Security
94+
config/packages/security.yaml
95+
```yaml
96+
# oud
97+
encoders:
98+
App\Entity\User\User:
99+
algorithm: auto
100+
101+
# nieuw
102+
password_hashers:
103+
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
104+
```
105+
106+
### Config
107+
108+
config/packages/sentry.yaml
109+
```yaml
110+
when@prod:
111+
sentry:
112+
dsn: '%env(SENTRY_DSN)%'
113+
options:
114+
integrations:
115+
- 'Sentry\Integration\IgnoreErrorsIntegration'
116+
117+
services:
118+
Sentry\Integration\IgnoreErrorsIntegration:
119+
arguments:
120+
$options:
121+
ignore_exceptions:
122+
- 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'
123+
- 'Symfony\Component\Security\Core\Exception\AccessDeniedException'
124+
125+
```

0 commit comments

Comments
 (0)