GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 36acbf )
by Mario
11:02
created

Export::__invoke()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 8.9688
c 0
b 0
f 0
cc 5
nc 3
nop 2
1
<?php
2
3
namespace Netgen\Bundle\InformationCollectionBundle\Controller\Admin\Export;
4
5
use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Netgen\InformationCollection\API\Value\Export\ExportCriteria;
8
use Netgen\InformationCollection\API\Service\Exporter;
9
use Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry;
10
use Symfony\Component\HttpFoundation\Request;
11
use Netgen\InformationCollection\Form\Type\ExportType;
12
use eZ\Publish\API\Repository\ContentService;
13
14
final class Export extends AbstractController
15
{
16
    /**
17
     * @var \eZ\Publish\API\Repository\ContentService
18
     */
19
    protected $contentService;
20
21
    /**
22
     * @var \Netgen\InformationCollection\API\Service\Exporter
23
     */
24
    protected $exporter;
25
26
    /**
27
     * @var \Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry
28
     */
29
    protected $formatterRegistry;
30
31
    public function __construct(
32
        ContentService $contentService,
33
        Exporter $exporter,
34
        ExportResponseFormatterRegistry $formatterRegistry
35
    )
36
    {
37
        $this->contentService = $contentService;
38
        $this->exporter = $exporter;
39
        $this->formatterRegistry = $formatterRegistry;
40
    }
41
42
    public function __invoke($contentId, Request $request)
43
    {
44
        $attribute = new Attribute('infocollector', 'read');
45
        $this->denyAccessUnlessGranted($attribute);
46
47
        $content = $this->contentService->loadContent($contentId);
48
49
        $form = $this->createForm(ExportType::class);
50
        $form->handleRequest($request);
51
52
        if ($form->get('cancel')->isClicked()) {
53
            return $this->redirect($this->generateUrl('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]));
54
        }
55
56
        if ($form->get('export')->isClicked() && $form->isSubmitted() && $form->isValid()) {
57
58
            $exportCriteria = new ExportCriteria(
0 ignored issues
show
Bug introduced by
The call to ExportCriteria::__construct() misses some required arguments starting with $from.
Loading history...
59
                [
0 ignored issues
show
Documentation introduced by
array('content' => $cont...m->getData()['dateTo']) is of type array<string,?,{"content...","from":"?","to":"?"}>, but the function expects a object<eZ\Publish\API\Re...Values\Content\Content>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
                    'content' => $content,
61
                    'from' => $form->getData()['dateFrom'],
62
                    'to' => $form->getData()['dateTo'],
63
                ]
64
            );
65
66
            $export = $this->exporter->export($exportCriteria);
67
68
            $formatter = $this->formatterRegistry->getExportResponseFormatter(
69
                $form->getData()['exportType']
70
            );
71
72
            return $formatter->format($export, $content);
73
        }
74
75
        return $this->render("@NetgenInformationCollection/admin/export_menu.html.twig",
76
            [
77
                'content' => $content,
78
                'form' => $form->createView(),
79
            ]
80
        );
81
    }
82
}
83