Skip to content

Commit 2086166

Browse files
committed
Merge remote-tracking branch 'origin/4.6'
# Conflicts: # phpstan-baseline.neon # src/lib/Content/View/Filter/ContentEditViewFilter.php
2 parents 1bd075e + 9db0626 commit 2086166

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

phpstan-baseline.neon

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,12 @@ parameters:
210210
count: 1
211211
path: src/lib/FieldType/DataTransformer/AbstractBinaryBaseTransformer.php
212212

213-
-
214-
message: '#^Method Ibexa\\ContentForms\\FieldType\\DataTransformer\\BinaryFileValueTransformer\:\:transform\(\) return type has no value type specified in iterable type array\.$#'
215-
identifier: missingType.iterableValue
216-
count: 1
217-
path: src/lib/FieldType/DataTransformer/BinaryFileValueTransformer.php
218-
219213
-
220214
message: '#^Method Ibexa\\ContentForms\\FieldType\\DataTransformer\\ImageAssetValueTransformer\:\:reverseTransform\(\) has parameter \$value with no value type specified in iterable type array\.$#'
221215
identifier: missingType.iterableValue
222216
count: 1
223217
path: src/lib/FieldType/DataTransformer/ImageAssetValueTransformer.php
224218

225-
-
226-
message: '#^Method Ibexa\\ContentForms\\FieldType\\DataTransformer\\MediaValueTransformer\:\:transform\(\) return type has no value type specified in iterable type array\.$#'
227-
identifier: missingType.iterableValue
228-
count: 1
229-
path: src/lib/FieldType/DataTransformer/MediaValueTransformer.php
230-
231219
-
232220
message: '#^Method Ibexa\\ContentForms\\FieldType\\FieldTypeFormMapperDispatcherInterface\:\:map\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#'
233221
identifier: missingType.generics
@@ -361,8 +349,8 @@ parameters:
361349
path: src/lib/Form/Processor/User/UserUpdateFormProcessor.php
362350

363351
-
364-
message: '#^Method Ibexa\\ContentForms\\Form\\Transformer\\RelationTransformer\:\:transform\(\) return type has no value type specified in iterable type array\.$#'
365-
identifier: missingType.iterableValue
352+
message: '#^Method Ibexa\\ContentForms\\Form\\Transformer\\RelationTransformer\:\:transform\(\) should return array\{location\: int\|null, location_type\: string\} but returns array\{location\: int\<min, \-2\>\|int\<0, max\>\|null, location_type\: \-1\|0\|1\}\.$#'
353+
identifier: return.type
366354
count: 1
367355
path: src/lib/Form/Transformer/RelationTransformer.php
368356

@@ -630,12 +618,6 @@ parameters:
630618
count: 1
631619
path: src/lib/Form/Type/User/UserUpdateType.php
632620

633-
-
634-
message: '#^Method Ibexa\\ContentForms\\Validator\\Constraints\\Password\:\:getTargets\(\) return type has no value type specified in iterable type array\.$#'
635-
identifier: missingType.iterableValue
636-
count: 1
637-
path: src/lib/Validator/Constraints/Password.php
638-
639621
-
640622
message: '#^Access to an undefined property Ibexa\\Contracts\\Core\\Repository\\Values\\Translation\:\:\$message\.$#'
641623
identifier: property.notFound
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Contracts\ContentForms\Event;
10+
11+
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
12+
use Symfony\Contracts\EventDispatcher\Event;
13+
14+
final class AutosaveEnabled extends Event
15+
{
16+
private VersionInfo $versionInfo;
17+
18+
private bool $autosaveEnabled = true;
19+
20+
public function __construct(VersionInfo $versionInfo)
21+
{
22+
$this->versionInfo = $versionInfo;
23+
}
24+
25+
public function getVersionInfo(): VersionInfo
26+
{
27+
return $this->versionInfo;
28+
}
29+
30+
public function isAutosaveEnabled(): bool
31+
{
32+
return $this->autosaveEnabled;
33+
}
34+
35+
public function enableAutosave(): void
36+
{
37+
$this->autosaveEnabled = true;
38+
}
39+
40+
public function disableAutosave(): void
41+
{
42+
$this->autosaveEnabled = false;
43+
}
44+
}

src/lib/Content/View/Filter/ContentEditViewFilter.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Ibexa\ContentForms\Data\Content\ContentUpdateData;
1212
use Ibexa\ContentForms\Data\Mapper\ContentUpdateMapper;
1313
use Ibexa\ContentForms\Form\Type\Content\ContentEditType;
14+
use Ibexa\Contracts\ContentForms\Event\AutosaveEnabled;
1415
use Ibexa\Contracts\Core\Repository\ContentService;
1516
use Ibexa\Contracts\Core\Repository\ContentTypeService;
1617
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
@@ -24,6 +25,7 @@
2425
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2526
use Symfony\Component\Form\FormFactoryInterface;
2627
use Symfony\Component\Form\FormInterface;
28+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
2729

2830
final readonly class ContentEditViewFilter implements EventSubscriberInterface
2931
{
@@ -32,7 +34,8 @@ public function __construct(
3234
private LocationService $locationService,
3335
private ContentTypeService $contentTypeService,
3436
private FormFactoryInterface $formFactory,
35-
private UserLanguagePreferenceProviderInterface $languagePreferenceProvider
37+
private UserLanguagePreferenceProviderInterface $languagePreferenceProvider,
38+
private EventDispatcherInterface $eventDispatcher
3639
) {
3740
}
3841

@@ -86,11 +89,13 @@ public function handleContentEditForm(FilterViewBuilderParametersEvent $event):
8689
$currentFields
8790
);
8891

92+
$autosaveEnabled = $this->eventDispatcher->dispatch(new AutosaveEnabled($contentDraft->getVersionInfo()))->isAutosaveEnabled();
8993
$form = $this->resolveContentEditForm(
9094
$contentUpdate,
9195
$languageCode,
9296
$contentDraft,
93-
$location ?? null
97+
$location ?? null,
98+
$autosaveEnabled
9499
);
95100

96101
$event->getParameters()->add([
@@ -124,7 +129,8 @@ private function resolveContentEditForm(
124129
ContentUpdateData $contentUpdate,
125130
string $languageCode,
126131
Content $content,
127-
?Location $location = null
132+
?Location $location = null,
133+
bool $autosaveEnabled = true
128134
): FormInterface {
129135
return $this->formFactory->create(
130136
ContentEditType::class,
@@ -137,6 +143,7 @@ private function resolveContentEditForm(
137143
'contentUpdateStruct' => $contentUpdate,
138144
'struct' => $contentUpdate,
139145
'drafts_enabled' => true,
146+
'autosave_enabled' => $autosaveEnabled,
140147
]
141148
);
142149
}

0 commit comments

Comments
 (0)