1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms; |
6
|
|
|
|
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
8
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location; |
9
|
|
|
use eZ\Publish\API\Repository\Values\ContentType\ContentType; |
10
|
|
|
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; |
11
|
|
|
use eZ\Publish\API\Repository\Values\ValueObject; |
12
|
|
|
use Netgen\InformationCollection\API\Value\InformationCollectionStruct; |
13
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
14
|
|
|
use EzSystems\EzPlatformContentForms\Data\Mapper\FormDataMapperInterface; |
15
|
|
|
use EzSystems\EzPlatformContentForms\Data\Content\FieldData; |
16
|
|
|
|
17
|
|
|
final class InformationCollectionMapper |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Maps a ValueObject from eZ content repository to a data usable as underlying form data (e.g. create/update struct). |
21
|
|
|
* |
22
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Content $contentDraft |
|
|
|
|
23
|
|
|
* @param array $params |
|
|
|
|
24
|
|
|
* |
25
|
|
|
* @return InformationCollectionStruct |
26
|
|
|
*/ |
27
|
|
|
public function mapToFormData(Content $content, Location $location, ContentType $contentType) |
28
|
|
|
{ |
29
|
|
|
$fields = $content->getFieldsByLanguage($content->contentInfo->mainLanguageCode); |
30
|
|
|
|
31
|
|
|
$informationCollectionFields = []; |
32
|
|
|
|
33
|
|
|
/** @var FieldDefinition $fieldDef */ |
34
|
|
|
foreach ($contentType->fieldDefinitions as $fieldDef) { |
35
|
|
|
if ($fieldDef->isInfoCollector) { |
36
|
|
|
$field = $fields[$fieldDef->identifier]; |
37
|
|
|
|
38
|
|
|
$fieldData = new FieldData( |
39
|
|
|
[ |
40
|
|
|
'fieldDefinition' => $fieldDef, |
41
|
|
|
'field' => $field, |
42
|
|
|
] |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$informationCollectionFields[] = $fieldData; |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return new InformationCollectionStruct( |
50
|
|
|
$content, |
51
|
|
|
$location, |
52
|
|
|
$contentType, |
53
|
|
|
$informationCollectionFields |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
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.