|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Netgen\InformationCollection; |
|
4
|
|
|
|
|
5
|
|
|
use eZ\Publish\API\Repository\ContentTypeService; |
|
6
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
|
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location; |
|
8
|
|
|
use Netgen\InformationCollection\API\Events; |
|
9
|
|
|
use Netgen\InformationCollection\API\Value\Event\InformationCollected; |
|
10
|
|
|
use Netgen\InformationCollection\API\Value\InformationCollectionStruct; |
|
11
|
|
|
use Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionMapper; |
|
12
|
|
|
use Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionType; |
|
13
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
14
|
|
|
use Symfony\Component\Form\FormFactoryInterface; |
|
15
|
|
|
use Symfony\Component\Form\FormInterface; |
|
16
|
|
|
|
|
17
|
|
|
final class Handler |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \Symfony\Component\Form\FormFactoryInterface |
|
21
|
|
|
*/ |
|
22
|
|
|
private $formFactory; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \eZ\Publish\API\Repository\ContentTypeService |
|
26
|
|
|
*/ |
|
27
|
|
|
private $contentTypeService; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface |
|
31
|
|
|
*/ |
|
32
|
|
|
private $eventDispatcher; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct(FormFactoryInterface $formFactory, ContentTypeService $contentTypeService, EventDispatcherInterface $eventDispatcher) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->formFactory = $formFactory; |
|
37
|
|
|
$this->contentTypeService = $contentTypeService; |
|
38
|
|
|
$this->eventDispatcher = $eventDispatcher; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getForm(Content $content, Location $location): FormInterface |
|
42
|
|
|
{ |
|
43
|
|
|
$contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); |
|
44
|
|
|
|
|
45
|
|
|
$informationCollectionMapper = new InformationCollectionMapper(); |
|
46
|
|
|
|
|
47
|
|
|
$data = $informationCollectionMapper->mapToFormData($content, $location, $contentType); |
|
48
|
|
|
|
|
49
|
|
|
return $this->formFactory->create(InformationCollectionType::class, $data, [ |
|
50
|
|
|
'languageCode' => $content->contentInfo->mainLanguageCode, |
|
51
|
|
|
'mainLanguageCode' => $content->contentInfo->mainLanguageCode, |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function handle(InformationCollectionStruct $struct, array $options): void |
|
56
|
|
|
{ |
|
57
|
|
|
$event = new InformationCollected($struct, $options); |
|
58
|
|
|
|
|
59
|
|
|
$this->eventDispatcher->dispatch($event, Events::INFORMATION_COLLECTED); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: