Skip to content

Commit be070b7

Browse files
Fix metadata loading of form_details (#418)
* Fix metadata loading ofform_details * Update issues * Update compsoer.json * Fix lint * Apply suggestions from code review * Apply suggestions from code review
1 parent a93bf17 commit be070b7

File tree

9 files changed

+31
-19
lines changed

9 files changed

+31
-19
lines changed

.github/workflows/test-application.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,22 @@ jobs:
5050
database: mysql
5151
dependency-versions: 'highest'
5252
tools: 'composer:v2'
53-
composer-stability: 'dev'
5453
env:
5554
SYMFONY_DEPRECATIONS_HELPER: weak
5655
DATABASE_URL: mysql://root:root@127.0.0.1/sulu_form_test?serverVersion=8.0
5756
DATABASE_CHARSET: utf8mb4
5857
DATABASE_COLLATE: utf8mb4_unicode_ci
5958

59+
- php-version: '8.4'
60+
database: postgres
61+
dependency-versions: 'highest'
62+
tools: 'composer:v2'
63+
env:
64+
SYMFONY_DEPRECATIONS_HELPER: weak
65+
DATABASE_URL: postgres://postgres:postgres@127.0.0.1/sulu_form_test?serverVersion=14
66+
DATABASE_CHARSET: UTF8
67+
DATABASE_COLLATE:
68+
6069
- php-version: '8.5'
6170
database: mysql
6271
dependency-versions: 'highest'
@@ -118,7 +127,7 @@ jobs:
118127
env: ${{ matrix.env }}
119128

120129
- name: Execute test cases
121-
run: time composer test -- --config phpunit.xml.dist
130+
run: time composer test
122131
env: ${{ matrix.env }}
123132

124133
lint:

.php-cs-fixer.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
'single_line_throw' => false,
3333
'single_line_comment_spacing' => false,
3434
'trailing_comma_in_multiline' => false,
35+
'phpdoc_to_comment' => [
36+
'ignored_tags' => ['todo', 'var', 'see'],
37+
],
3538
])
3639
->setFinder($finder);
3740

Command/FormGeneratorCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private function loadTestForm(): ?Form
259259
->where($queryBuilder->expr()->eq('translation.title', ':title'))
260260
->setParameter('title', 'Test Form');
261261

262-
/* @var Form */
262+
/** @var Form */
263263
return $queryBuilder->getQuery()->getSingleResult();
264264
} catch (NoResultException $e) {
265265
return null;

Event/CacheInvalidationListener.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111

1212
namespace Sulu\Bundle\FormBundle\Event;
1313

14-
use Doctrine\ORM\Event\LifecycleEventArgs;
1514
use Doctrine\ORM\Event\PostUpdateEventArgs;
1615
use Doctrine\ORM\Event\PreRemoveEventArgs;
1716
use Sulu\Bundle\FormBundle\Entity\Form;
1817
use Sulu\Bundle\FormBundle\Entity\FormTranslation;
1918
use Sulu\Bundle\HttpCacheBundle\Cache\CacheManagerInterface;
2019

2120
/**
22-
* Invalidate references when form is persisted.
21+
* @internal no backwards compatibility promise is given for this class it can be removed at any time
2322
*/
2423
class CacheInvalidationListener
2524
{
@@ -33,12 +32,12 @@ public function __construct(?CacheManagerInterface $cacheManager)
3332
$this->cacheManager = $cacheManager;
3433
}
3534

36-
public function postUpdate(PostUpdateEventArgs|LifecycleEventArgs $eventArgs): void
35+
public function postUpdate(PostUpdateEventArgs $eventArgs): void
3736
{
3837
$this->invalidateEntity($eventArgs->getObject());
3938
}
4039

41-
public function preRemove(PreRemoveEventArgs|LifecycleEventArgs $eventArgs): void
40+
public function preRemove(PreRemoveEventArgs $eventArgs): void
4241
{
4342
$this->invalidateEntity($eventArgs->getObject());
4443
}

Metadata/DynamicFormMetadataLoader.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
use Symfony\Contracts\Translation\TranslatorInterface;
2727
use Webmozart\Assert\Assert;
2828

29+
/**
30+
* @internal no backwards compatibility promise is given for this class it can be removed at any time
31+
*/
2932
class DynamicFormMetadataLoader implements FormMetadataLoaderInterface, CacheWarmerInterface
3033
{
3134
/**
@@ -90,6 +93,10 @@ public function warmUp($cacheDir, ?string $buildDir = null): array
9093

9194
public function getMetadata(string $key, string $locale, array $metadataOptions = []): ?MetadataInterface
9295
{
96+
if ('form_details' !== $key) {
97+
return null;
98+
}
99+
93100
$configCache = $this->getConfigCache($key);
94101

95102
if (!\file_exists($configCache->getPath()) || !$configCache->isFresh()) {

Repository/FormRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function loadById(int $id, ?string $locale = null): ?Form
3434
$query = $queryBuilder->getQuery();
3535

3636
try {
37-
/* @var Form */
37+
/** @var Form */
3838
return $query->getSingleResult();
3939
} catch (NoResultException $e) {
4040
return null;

Resources/config/services.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
<argument>%kernel.debug%</argument>
186186
<tag name="sulu.context" context="admin"/>
187187
<tag name="kernel.cache_warmer" />
188-
<tag name="sulu_admin.form_metadata_loader"/>
188+
<tag name="sulu_admin.form_metadata_loader" priority="256"/>
189189
</service>
190190

191191
<!-- Dynamic Controller -->

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
],
1919
"require": {
2020
"php": "^8.2",
21-
"doctrine/collections": "^2.0",
21+
"doctrine/collections": "^1.6 || ^2.0",
2222
"doctrine/orm": "^2.17.3 || ^3.3",
23-
"doctrine/persistence": "^3.0",
24-
"sulu/sulu": "^3.0",
23+
"doctrine/persistence": "^3.1 || ^4.0",
24+
"sulu/sulu": "^3.0.4 || 3.0.x-dev",
2525
"symfony/config": "^6.4 || ^7.1",
2626
"symfony/console": "^6.4 || ^7.1",
2727
"symfony/dependency-injection": "^6.4 || ^7.1",
@@ -121,8 +121,7 @@
121121
"Tests/Application/bin/websiteconsole lint:container --env prod"
122122
],
123123
"lint-doctrine": [
124-
"Tests/Application/bin/adminconsole doctrine:schema:validate --skip-sync",
125-
"Tests/Application/bin/adminconsole doctrine:ensure-production-settings --env prod"
124+
"Tests/Application/bin/adminconsole doctrine:schema:validate --skip-sync"
126125
]
127126
},
128127
"config": {

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,6 @@ parameters:
315315
count: 1
316316
path: Dynamic/Types/AttachmentType.php
317317

318-
-
319-
message: "#^Parameter \\#1 \\$constraints of class Symfony\\\\Component\\\\Validator\\\\Constraints\\\\All constructor expects array\\<Symfony\\\\Component\\\\Validator\\\\Constraint\\>\\|Symfony\\\\Component\\\\Validator\\\\Constraint\\|null, array\\<string, array\\<Symfony\\\\Component\\\\Validator\\\\Constraint\\>\\> given\\.$#"
320-
count: 1
321-
path: Dynamic/Types/AttachmentType.php
322-
323318
-
324319
message: "#^Cannot call method getDefaultValue\\(\\) on Sulu\\\\Bundle\\\\FormBundle\\\\Entity\\\\FormFieldTranslation\\|null\\.$#"
325320
count: 1

0 commit comments

Comments
 (0)