Skip to content

Commit 70d1af8

Browse files
committed
fix: CS
1 parent e24c72b commit 70d1af8

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed

eZ/Publish/Core/Persistence/Legacy/Content/Mapper.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
*/
5959
class Mapper
6060
{
61-
const EMPTY_FIELD_ID = -1;
61+
public const EMPTY_FIELD_ID = -1;
6262

6363
/**
6464
* FieldValue converter registry.
@@ -80,7 +80,7 @@ class Mapper
8080
private $contentTypeHandler;
8181

8282
/**
83-
* @var EventDispatcherInterface
83+
* @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface
8484
*/
8585
private $eventDispatcher;
8686

@@ -329,10 +329,9 @@ private function buildContentObjects(
329329
);
330330

331331
$field = $event->getField();
332-
if ($field !== null) {
332+
if ($field !== null) {
333333
$content->fields[] = $field;
334334
}
335-
336335
}
337336
}
338337

eZ/Publish/Core/Persistence/Legacy/Tests/Content/MapperTest.php

+41-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use eZ\Publish\SPI\Persistence\Content\Relation as SPIRelation;
2323
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct;
2424
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
25+
use Symfony\Component\EventDispatcher\EventDispatcher;
26+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
2527

2628
/**
2729
* Test case for Mapper.
@@ -149,7 +151,12 @@ public function testConvertToStorageValue()
149151
$field->type = 'some-type';
150152
$field->value = new FieldValue();
151153

152-
$mapper = new Mapper($reg, $this->getLanguageHandler(), $this->getContentTypeHandler());
154+
$mapper = new Mapper(
155+
$reg,
156+
$this->getLanguageHandler(),
157+
$this->getContentTypeHandler(),
158+
$this->getEventDispatcher(),
159+
);
153160
$res = $mapper->convertToStorageValue($field);
154161

155162
$this->assertInstanceOf(
@@ -183,7 +190,12 @@ public function testExtractContentFromRows()
183190
'ezkeyword',
184191
], count($rowsFixture) - 1);
185192

186-
$mapper = new Mapper($reg, $this->getLanguageHandler(), $contentTypeHandlerMock);
193+
$mapper = new Mapper(
194+
$reg,
195+
$this->getLanguageHandler(),
196+
$contentTypeHandlerMock,
197+
$this->getEventDispatcher()
198+
);
187199
$result = $mapper->extractContentFromRows($rowsFixture, $nameRowsFixture);
188200

189201
$expected = [$this->getContentExtractReference()];
@@ -217,7 +229,12 @@ public function testExtractContentFromRowsWithNewFieldDefinitions(): void
217229
'eznumber',
218230
], count($rowsFixture));
219231

220-
$mapper = new Mapper($reg, $this->getLanguageHandler(), $contentTypeHandlerMock);
232+
$mapper = new Mapper(
233+
$reg,
234+
$this->getLanguageHandler(),
235+
$contentTypeHandlerMock,
236+
$this->getEventDispatcher()
237+
);
221238
$result = $mapper->extractContentFromRows($rowsFixture, $nameRowsFixture);
222239

223240
$expectedContent = $this->getContentExtractReference();
@@ -260,7 +277,12 @@ static function (Content\Type\FieldDefinition $fieldDefinition): bool {
260277
'ezkeyword',
261278
], count($rowsFixture) - 2);
262279

263-
$mapper = new Mapper($reg, $this->getLanguageHandler(), $contentTypeHandlerMock);
280+
$mapper = new Mapper(
281+
$reg,
282+
$this->getLanguageHandler(),
283+
$contentTypeHandlerMock,
284+
$this->getEventDispatcher()
285+
);
264286
$result = $mapper->extractContentFromRows($rowsFixture, $nameRowsFixture);
265287

266288
$expectedContent = $this->getContentExtractReference();
@@ -296,7 +318,12 @@ public function testExtractContentFromRowsMultipleVersions()
296318
$contentTypeHandlerMock = $this->getContentTypeHandler();
297319
$contentTypeHandlerMock->method('load')->willReturn($contentType);
298320

299-
$mapper = new Mapper($reg, $this->getLanguageHandler(), $contentTypeHandlerMock);
321+
$mapper = new Mapper(
322+
$reg,
323+
$this->getLanguageHandler(),
324+
$contentTypeHandlerMock,
325+
$this->getEventDispatcher()
326+
);
300327
$result = $mapper->extractContentFromRows($rowsFixture, $nameRowsFixture);
301328

302329
$this->assertCount(
@@ -477,7 +504,8 @@ public function testExtractContentInfoFromRow(array $fixtures, $prefix)
477504
$mapper = new Mapper(
478505
$this->getValueConverterRegistryMock(),
479506
$this->getLanguageHandler(),
480-
$this->getContentTypeHandler()
507+
$this->getContentTypeHandler(),
508+
$this->getEventDispatcher()
481509
);
482510
self::assertEquals($contentInfoReference, $mapper->extractContentInfoFromRow($fixtures, $prefix));
483511
}
@@ -638,7 +666,8 @@ protected function getMapper($valueConverter = null)
638666
return new Mapper(
639667
$this->getValueConverterRegistryMock(),
640668
$this->getLanguageHandler(),
641-
$this->getContentTypeHandler()
669+
$this->getContentTypeHandler(),
670+
$this->getEventDispatcher()
642671
);
643672
}
644673

@@ -676,6 +705,11 @@ protected function getRelationCreateStructFixture()
676705
return $struct;
677706
}
678707

708+
protected function getEventDispatcher(): EventDispatcherInterface
709+
{
710+
return new EventDispatcher();
711+
}
712+
679713
/**
680714
* Returns a language handler mock.
681715
*

src/contracts/Event/Mapper/ResolveMissingFieldEvent.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

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+
*/
37
namespace Ibexa\Contracts\Core\Event\Mapper;
48

59
use eZ\Publish\SPI\Persistence\Content;
@@ -9,10 +13,10 @@
913

1014
final class ResolveMissingFieldEvent extends Event
1115
{
12-
/** @var Content */
16+
/** @var \eZ\Publish\SPI\Persistence\Content */
1317
private $content;
1418

15-
/** @var FieldDefinition */
19+
/** @var \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition */
1620
private $fieldDefinition;
1721

1822
/** @var string */
@@ -21,7 +25,7 @@ final class ResolveMissingFieldEvent extends Event
2125
/** @var array */
2226
private $context;
2327

24-
/** @var Field|null */
28+
/** @var \eZ\Publish\SPI\Persistence\Content\Field|null */
2529
private $field;
2630

2731
public function __construct(
@@ -66,4 +70,4 @@ public function getField(): ?Field
6670
{
6771
return $this->field;
6872
}
69-
}
73+
}

src/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriber.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
final class ResolveVirtualFieldSubscriber implements EventSubscriberInterface
2525
{
26-
/** @var ConverterRegistry */
26+
/** @var \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry */
2727
private $converterRegistry;
2828

29-
/** @var StorageRegistry */
29+
/** @var \eZ\Publish\Core\Persistence\Legacy\Content\StorageRegistry */
3030
private $storageRegistry;
3131

32-
/** @var ContentGateway */
32+
/** @var \eZ\Publish\Core\Persistence\Legacy\Content\Gateway */
3333
private $contentGateway;
3434

3535
public function __construct(
@@ -48,7 +48,7 @@ public static function getSubscribedEvents(): array
4848
ResolveMissingFieldEvent::class => [
4949
['persistExternalStorageField', -100],
5050
['resolveVirtualField', 0],
51-
]
51+
],
5252
];
5353
}
5454

@@ -108,7 +108,7 @@ public function persistExternalStorageField(ResolveMissingFieldEvent $event): vo
108108
}
109109

110110
/**
111-
* @throws NotFound
111+
* @throws \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Exception\NotFound
112112
*/
113113
private function createEmptyField(
114114
VersionInfo $versionInfo,
@@ -126,7 +126,7 @@ private function createEmptyField(
126126
}
127127

128128
/**
129-
* @throws NotFound
129+
* @throws \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Exception\NotFound
130130
*/
131131
private function getDefaultValue(FieldDefinition $fieldDefinition): FieldValue
132132
{
@@ -151,4 +151,4 @@ private function getDefaultStorageValue(): StorageFieldValue
151151

152152
return $storageValue;
153153
}
154-
}
154+
}

0 commit comments

Comments
 (0)