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

ExportAll::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
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\Service\Exporter;
8
use Netgen\InformationCollection\API\Value\Export\Export as ExportValue;
9
use Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry;
10
use eZ\Publish\API\Repository\ContentService;
11
12
final class ExportAll extends AbstractController
13
{
14
    /**
15
     * @var \eZ\Publish\API\Repository\ContentService
16
     */
17
    protected $contentService;
18
19
    /**
20
     * @var \Netgen\InformationCollection\API\Service\Exporter
21
     */
22
    protected $exporter;
23
24
    /**
25
     * @var \Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry
26
     */
27
    protected $formatterRegistry;
28
29
    public function __construct(
30
        ContentService $contentService,
31
        Exporter $exporter,
32
        ExportResponseFormatterRegistry $formatterRegistry
33
    )
34
    {
35
        $this->contentService = $contentService;
36
        $this->exporter = $exporter;
37
        $this->formatterRegistry = $formatterRegistry;
38
    }
39
40
    /**
41
     * Handles comeplete data export in available formats
42
     *
43
     * @param int $contentId
44
     * @param string $exportIdentifier
45
     *
46
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
47
     */
48
    public function __invoke($contentId, $exportIdentifier)
49
    {
50
        $attribute = new Attribute('infocollector', 'export');
51
        $this->denyAccessUnlessGranted($attribute);
52
53
        $formatter = $this->formatterRegistry->getExportResponseFormatter($exportIdentifier);
54
55
        $content = $this->contentService->loadContent($contentId);
56
        $export = $this->getExportByContent($content);
57
58
        return $formatter->format($export, $content);
59
    }
60
61
    /**
62
     * @param \eZ\Publish\API\Repository\Values\Content\Content $content
63
     *
64
     * @return \Netgen\Bundle\InformationCollectionBundle\API\Value\Export\Export
65
     */
66
    protected function getExportByContent(Content $content): ExportValue
67
    {
68
        $exportCriteria = new ExportCriteria(
69
            [
70
                'content' => $content,
71
            ]
72
        );
73
74
        return $this->exporter->export($exportCriteria);
75
    }
76
}
77