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 ( e2ddad...a5d5b8 )
by Mario
02:08
created

FieldRenderingRuntime::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Templating\Twig\Extensions;
6
7
use eZ\Publish\Core\MVC\ConfigResolverInterface;
8
use Netgen\InformationCollection\API\Value\Attribute;
9
use Netgen\InformationCollection\API\Value\Collection;
10
use Twig\Environment;
11
use Twig\TemplateWrapper;
12
13
class FieldRenderingRuntime
14
{
15
    public const FIELD_VIEW_SUFFIX = '_field';
16
17
    /**
18
     * @var \Twig\Environment
19
     */
20
    protected $environment;
21
22
    /**
23
     * @var \eZ\Publish\Core\MVC\ConfigResolverInterface
24
     */
25
    protected $configResolver;
26
27
    public function __construct(Environment $environment, ConfigResolverInterface $configResolver)
28
    {
29
        $this->environment = $environment;
30
        $this->configResolver = $configResolver;
31
    }
32
33
    public function renderField(Collection $collection, Attribute $attribute): string
34
    {
35
        $template = $this->getTemplate();
36
        $blockName = $this->getRenderFieldBlockName($attribute);
37
38
        if (!$template->hasBlock($blockName)) {
39
            return $template->renderBlock($this->getDefaultRenderFieldBlockName(), ['collection' => $collection, 'attribute' => $attribute]);
40
        }
41
42
        return $template->renderBlock($blockName, ['collection' => $collection, 'attribute' => $attribute]);
43
    }
44
45
    protected function getRenderFieldBlockName(Attribute $attribute): string
46
    {
47
        $fieldTypeIdentifier = $attribute->getFieldDefinition()->fieldTypeIdentifier;
48
49
        return $fieldTypeIdentifier . self::FIELD_VIEW_SUFFIX;
50
    }
51
52
    protected function getDefaultRenderFieldBlockName(): string
53
    {
54
        return 'default' . self::FIELD_VIEW_SUFFIX;
55
    }
56
57
    protected function getTemplate(): TemplateWrapper
58
    {
59
        return $this->environment->load('@NetgenInformationCollection/admin/content_fields.html.twig');
60
    }
61
}
62