Skip to content

Commit 25100f0

Browse files
committed
Merged branch '1.3' of ezsystems/ezplatform-kernel into 4.6
2 parents b2f9e93 + 98b7b50 commit 25100f0

File tree

27 files changed

+1177
-379
lines changed

27 files changed

+1177
-379
lines changed

phpstan-baseline.neon

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -14985,11 +14985,6 @@ parameters:
1498514985
count: 1
1498614986
path: src/lib/Persistence/Legacy/Content/FieldHandler.php
1498714987

14988-
-
14989-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\FieldHandler\\:\\:createExistingFieldsInNewVersion\\(\\) has no return type specified\\.$#"
14990-
count: 1
14991-
path: src/lib/Persistence/Legacy/Content/FieldHandler.php
14992-
1499314988
-
1499414989
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\FieldHandler\\:\\:createNewField\\(\\) has no return type specified\\.$#"
1499514990
count: 1
@@ -16840,26 +16835,6 @@ parameters:
1684016835
count: 2
1684116836
path: src/lib/Persistence/Legacy/Content/Location/Trash/Handler.php
1684216837

16843-
-
16844-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentFromRows\\(\\) has parameter \\$nameRows with no value type specified in iterable type array\\.$#"
16845-
count: 1
16846-
path: src/lib/Persistence/Legacy/Content/Mapper.php
16847-
16848-
-
16849-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentFromRows\\(\\) has parameter \\$prefix with no type specified\\.$#"
16850-
count: 1
16851-
path: src/lib/Persistence/Legacy/Content/Mapper.php
16852-
16853-
-
16854-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentFromRows\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
16855-
count: 1
16856-
path: src/lib/Persistence/Legacy/Content/Mapper.php
16857-
16858-
-
16859-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentInfoFromRow\\(\\) has parameter \\$row with no value type specified in iterable type array\\.$#"
16860-
count: 1
16861-
path: src/lib/Persistence/Legacy/Content/Mapper.php
16862-
1686316838
-
1686416839
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractContentInfoFromRows\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
1686516840
count: 1
@@ -16900,16 +16875,6 @@ parameters:
1690016875
count: 1
1690116876
path: src/lib/Persistence/Legacy/Content/Mapper.php
1690216877

16903-
-
16904-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractVersionInfoListFromRows\\(\\) has parameter \\$nameRows with no value type specified in iterable type array\\.$#"
16905-
count: 1
16906-
path: src/lib/Persistence/Legacy/Content/Mapper.php
16907-
16908-
-
16909-
message: "#^Method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\Mapper\\:\\:extractVersionInfoListFromRows\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
16910-
count: 1
16911-
path: src/lib/Persistence/Legacy/Content/Mapper.php
16912-
1691316878
-
1691416879
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\Field\\:\\:\\$id \\(int\\) does not accept null\\.$#"
1691516880
count: 1
@@ -18740,11 +18705,6 @@ parameters:
1874018705
count: 1
1874118706
path: src/lib/Persistence/Legacy/Setting/Gateway/ExceptionConversion.php
1874218707

18743-
-
18744-
message: "#^Cannot call method fetch\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#"
18745-
count: 1
18746-
path: src/lib/Persistence/Legacy/SharedGateway/DatabasePlatform/SqliteGateway.php
18747-
1874818708
-
1874918709
message: "#^Argument of an invalid type array\\<Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\SharedGateway\\\\Gateway\\>\\|iterable supplied for foreach, only iterables are supported\\.$#"
1875018710
count: 1
@@ -29182,7 +29142,7 @@ parameters:
2918229142

2918329143
-
2918429144
message: "#^Parameter \\#2 \\$fieldDefinition of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\ContentTypeService\\:\\:removeFieldDefinition\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null given\\.$#"
29185-
count: 7
29145+
count: 6
2918629146
path: tests/integration/Core/Repository/ContentTypeServiceTest.php
2918729147

2918829148
-
@@ -48816,7 +48776,7 @@ parameters:
4881648776
path: tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSystemTwigIntegrationTestCase.php
4881748777

4881848778
-
48819-
message: "#^Anonymous function should return string but returns string\\|false\\.$#"
48779+
message: "#^Anonymous function should return non\\-empty\\-string but returns non\\-empty\\-string\\|false\\.$#"
4882048780
count: 1
4882148781
path: tests/lib/MVC/Symfony/Templating/Twig/Extension/RoutingExtensionTest.php
4882248782

@@ -53005,71 +52965,6 @@ parameters:
5300552965
count: 1
5300652966
path: tests/lib/Persistence/Legacy/Content/Section/SectionHandlerTest.php
5300752967

53008-
-
53009-
message: "#^Call to an undefined method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldStorage\\:\\:expects\\(\\)\\.$#"
53010-
count: 6
53011-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53012-
53013-
-
53014-
message: "#^Call to an undefined method Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageRegistry\\:\\:expects\\(\\)\\.$#"
53015-
count: 4
53016-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53017-
53018-
-
53019-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:getContextMock\\(\\) return type has no value type specified in iterable type array\\.$#"
53020-
count: 1
53021-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53022-
53023-
-
53024-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:getVersionInfoMock\\(\\) has no return type specified\\.$#"
53025-
count: 1
53026-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53027-
53028-
-
53029-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testDeleteFieldData\\(\\) has no return type specified\\.$#"
53030-
count: 1
53031-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53032-
53033-
-
53034-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testGetFieldDataAvailable\\(\\) has no return type specified\\.$#"
53035-
count: 1
53036-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53037-
53038-
-
53039-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testGetFieldDataNotAvailable\\(\\) has no return type specified\\.$#"
53040-
count: 1
53041-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53042-
53043-
-
53044-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:testStoreFieldData\\(\\) has no return type specified\\.$#"
53045-
count: 1
53046-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53047-
53048-
-
53049-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$storageHandler \\(Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandler\\) in isset\\(\\) is not nullable\\.$#"
53050-
count: 1
53051-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53052-
53053-
-
53054-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$storageMock \\(Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldStorage\\) in isset\\(\\) is not nullable\\.$#"
53055-
count: 1
53056-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53057-
53058-
-
53059-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$storageRegistryMock \\(Ibexa\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageRegistry\\) in isset\\(\\) is not nullable\\.$#"
53060-
count: 1
53061-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53062-
53063-
-
53064-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$versionInfoMock \\(Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfo\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Persistence\\\\Content\\\\VersionInfo&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
53065-
count: 1
53066-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53067-
53068-
-
53069-
message: "#^Property Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageHandlerTest\\:\\:\\$versionInfoMock \\(Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfo\\) in isset\\(\\) is not nullable\\.$#"
53070-
count: 1
53071-
path: tests/lib/Persistence/Legacy/Content/StorageHandlerTest.php
53072-
5307352968
-
5307452969
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Persistence\\\\Legacy\\\\Content\\\\StorageRegistryTest\\:\\:testGetNotFound\\(\\) has no return type specified\\.$#"
5307552970
count: 1
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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\Core\Event\Mapper;
10+
11+
use Ibexa\Contracts\Core\Persistence\Content;
12+
use Ibexa\Contracts\Core\Persistence\Content\Field;
13+
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition;
14+
use Symfony\Contracts\EventDispatcher\Event;
15+
16+
final class ResolveMissingFieldEvent extends Event
17+
{
18+
private Content $content;
19+
20+
private FieldDefinition $fieldDefinition;
21+
22+
private string $languageCode;
23+
24+
/** @var array<mixed> */
25+
private array $context;
26+
27+
private ?Field $field;
28+
29+
/**
30+
* @param array<mixed> $context
31+
*/
32+
public function __construct(
33+
Content $content,
34+
FieldDefinition $fieldDefinition,
35+
string $languageCode,
36+
array $context = []
37+
) {
38+
$this->content = $content;
39+
$this->fieldDefinition = $fieldDefinition;
40+
$this->languageCode = $languageCode;
41+
$this->context = $context;
42+
$this->field = null;
43+
}
44+
45+
public function getContent(): Content
46+
{
47+
return $this->content;
48+
}
49+
50+
public function getFieldDefinition(): FieldDefinition
51+
{
52+
return $this->fieldDefinition;
53+
}
54+
55+
public function getLanguageCode(): string
56+
{
57+
return $this->languageCode;
58+
}
59+
60+
/**
61+
* @return array<mixed>
62+
*/
63+
public function getContext(): array
64+
{
65+
return $this->context;
66+
}
67+
68+
public function setField(?Field $field): void
69+
{
70+
$this->field = $field;
71+
}
72+
73+
public function getField(): ?Field
74+
{
75+
return $this->field;
76+
}
77+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\Core\FieldType;
10+
11+
use Ibexa\Contracts\Core\Persistence\Content\Field;
12+
use Ibexa\Contracts\Core\Persistence\Content\VersionInfo;
13+
14+
interface DefaultDataFieldStorage extends FieldStorage
15+
{
16+
/**
17+
* Populates <code>$field</code> value property with default data based on the external data.
18+
*
19+
* <code>$field->value</code> is a {@see \Ibexa\Contracts\Core\Persistence\Content\FieldValue} object.
20+
* This value holds the data as a {@see \Ibexa\Core\FieldType\Value} based object, according to
21+
* the field type (e.g. for <code>TextLine</code>, it will be a {@see \Ibexa\Core\FieldType\TextLine\Value} object).
22+
*/
23+
public function getDefaultFieldData(VersionInfo $versionInfo, Field $field): void;
24+
}

src/contracts/Repository/Values/Content/Field.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class Field extends ValueObject
2424
/**
2525
* The field id.
2626
*
27-
* @todo may be not needed
27+
* Value of `null` indicates the field is virtual
28+
* and is not persisted (yet).
2829
*
2930
* @var mixed
3031
*/
@@ -58,7 +59,7 @@ class Field extends ValueObject
5859
*/
5960
protected $fieldTypeIdentifier;
6061

61-
public function getId(): int
62+
public function getId(): ?int
6263
{
6364
return $this->id;
6465
}
@@ -85,6 +86,14 @@ public function getFieldTypeIdentifier(): string
8586
{
8687
return $this->fieldTypeIdentifier;
8788
}
89+
90+
/**
91+
* @phpstan-assert-if-true !null $this->getId()
92+
*/
93+
public function isVirtual(): bool
94+
{
95+
return null === $this->id;
96+
}
8897
}
8998

9099
class_alias(Field::class, 'eZ\Publish\API\Repository\Values\Content\Field');

src/lib/Persistence/Legacy/Content/FieldHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,13 @@ protected function getEmptyField(FieldDefinition $fieldDefinition, $languageCode
148148
*
149149
* @param \Ibexa\Contracts\Core\Persistence\Content $content
150150
*/
151-
public function createExistingFieldsInNewVersion(Content $content)
151+
public function createExistingFieldsInNewVersion(Content $content): void
152152
{
153153
foreach ($content->fields as $field) {
154+
if ($field->id === null) {
155+
// Virtual field with default value, skip creating field as it has no id
156+
continue;
157+
}
154158
$this->createExistingFieldInNewVersion($field, $content);
155159
}
156160
}

0 commit comments

Comments
 (0)