1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Netgen\InformationCollection\Integration\RepositoryForms; |
6
|
|
|
|
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
8
|
|
|
use eZ\Publish\API\Repository\Values\ContentType\ContentType; |
9
|
|
|
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; |
10
|
|
|
use eZ\Publish\API\Repository\Values\ValueObject; |
11
|
|
|
use Netgen\InformationCollection\API\Value\InformationCollectionStruct; |
12
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
13
|
|
|
use EzSystems\EzPlatformContentForms\Data\Mapper\FormDataMapperInterface; |
14
|
|
|
use EzSystems\EzPlatformContentForms\Data\Content\FieldData; |
15
|
|
|
|
16
|
|
|
final class InformationCollectionMapper |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Maps a ValueObject from eZ content repository to a data usable as underlying form data (e.g. create/update struct). |
20
|
|
|
* |
21
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Content $contentDraft |
|
|
|
|
22
|
|
|
* @param array $params |
|
|
|
|
23
|
|
|
* |
24
|
|
|
* @return InformationCollectionStruct |
25
|
|
|
*/ |
26
|
|
|
public function mapToFormData(Content $content, ContentType $contentType) |
27
|
|
|
{ |
28
|
|
|
$fields = $content->getFieldsByLanguage($content->contentInfo->mainLanguageCode); |
29
|
|
|
|
30
|
|
|
$informationCollectionFields = []; |
31
|
|
|
|
32
|
|
|
/** @var FieldDefinition $fieldDef */ |
33
|
|
|
foreach ($contentType->fieldDefinitions as $fieldDef) { |
34
|
|
|
if ($fieldDef->isInfoCollector) { |
35
|
|
|
$field = $fields[$fieldDef->identifier]; |
36
|
|
|
|
37
|
|
|
$fieldData = new FieldData( |
38
|
|
|
[ |
39
|
|
|
'fieldDefinition' => $fieldDef, |
40
|
|
|
'field' => $field, |
41
|
|
|
] |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
$informationCollectionFields[] = $fieldData; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return new InformationCollectionStruct( |
49
|
|
|
$content, |
50
|
|
|
$contentType, |
51
|
|
|
$informationCollectionFields |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.