1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Netgen\InformationCollection\Form\Builder; |
4
|
|
|
|
5
|
|
|
use eZ\Publish\API\Repository\ContentService; |
6
|
|
|
use eZ\Publish\API\Repository\ContentTypeService; |
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
8
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location; |
9
|
|
|
use Netgen\InformationCollection\Integration\RepositoryForms\InformationCollectionMapper; |
10
|
|
|
use Netgen\InformationCollection\Integration\RepositoryForms\InformationCollectionType; |
11
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
12
|
|
|
use Symfony\Component\Form\FormFactoryInterface; |
13
|
|
|
use Symfony\Component\Form\FormInterface; |
14
|
|
|
use Symfony\Component\Routing\RouterInterface; |
15
|
|
|
use Netgen\InformationCollection\API\Form\DynamicFormBuilderInterface; |
16
|
|
|
|
17
|
|
|
class FormBuilder implements DynamicFormBuilderInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var FormFactoryInterface |
21
|
|
|
*/ |
22
|
|
|
protected $formFactory; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
protected $useCsrf; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var ContentTypeService |
31
|
|
|
*/ |
32
|
|
|
protected $contentTypeService; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var RouterInterface |
36
|
|
|
*/ |
37
|
|
|
protected $router; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* FormBuilder constructor. |
41
|
|
|
* |
42
|
|
|
* @param FormFactoryInterface $formFactory |
43
|
|
|
* @param ContentTypeService $contentTypeService |
44
|
|
|
* @param RouterInterface $router |
|
|
|
|
45
|
|
|
* @param bool $useCsrf |
|
|
|
|
46
|
|
|
*/ |
47
|
|
|
public function __construct(FormFactoryInterface $formFactory, ContentTypeService $contentTypeService) |
48
|
|
|
{ |
49
|
|
|
$this->formFactory = $formFactory; |
50
|
|
|
$this->contentTypeService = $contentTypeService; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function createFormWithAjax(Content $content): FormBuilderInterface |
54
|
|
|
{ |
55
|
|
|
throw new \RuntimeException('This method is not implemented.'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function createForm(Content $content): FormInterface |
59
|
|
|
{ |
60
|
|
|
$contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); |
61
|
|
|
|
62
|
|
|
$informationCollectionMapper = new InformationCollectionMapper(); |
63
|
|
|
|
64
|
|
|
$data = $informationCollectionMapper->mapToFormData($content, [ |
65
|
|
|
'languageCode' => $content->contentInfo->mainLanguageCode, |
66
|
|
|
'contentType' => $contentType, |
67
|
|
|
]); |
68
|
|
|
|
69
|
|
|
$builder = $this->formFactory->create(InformationCollectionType::class, $data, [ |
70
|
|
|
'languageCode' => $content->contentInfo->mainLanguageCode, |
71
|
|
|
'mainLanguageCode' => $content->contentInfo->mainLanguageCode, |
72
|
|
|
]); |
73
|
|
|
|
74
|
|
|
return $builder; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.