Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
BaseView
n/a
0 / 0
n/a
0 / 0
4
n/a
0 / 0
 __construct
n/a
0 / 0
n/a
0 / 0
1
 render
n/a
0 / 0
n/a
0 / 0
1
 getId
n/a
0 / 0
n/a
0 / 0
1
 isRequired
n/a
0 / 0
n/a
0 / 0
1
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   Modules\Media
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace Modules\Media\Theme\Backend\Components\InlinePreview;
16
17use phpOMS\Localization\L11nManager;
18use phpOMS\Message\RequestAbstract;
19use phpOMS\Message\ResponseAbstract;
20use phpOMS\Views\View;
21
22/**
23 * Component view.
24 *
25 * @package Modules\Media
26 * @license OMS License 2.0
27 * @link    https://jingga.app
28 * @since   1.0.0
29 * @codeCoverageIgnore
30 */
31class BaseView extends View
32{
33    /**
34     * Form id
35     *
36     * @var string
37     * @since 1.0.0
38     */
39    public string $id = '';
40
41    /**
42     * Form id
43     *
44     * @var string
45     * @since 1.0.0
46     */
47    protected string $form = '';
48
49    /**
50     * Virtual path of the media file
51     *
52     * @var string
53     * @since 1.0.0
54     */
55    protected string $virtualPath = '';
56
57    /**
58     * Name of the image preview
59     *
60     * @var string
61     * @since 1.0.0
62     */
63    protected string $name = '';
64
65    /**
66     * Is required?
67     *
68     * @var bool
69     * @since 1.0.0
70     */
71    public bool $isRequired = false;
72
73    /**
74     * {@inheritdoc}
75     */
76    public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
77    {
78        parent::__construct($l11n, $request, $response);
79        $this->setTemplate('/Modules/Media/Theme/Backend/Components/InlinePreview/inline-preview');
80    }
81
82    /**
83     * {@inheritdoc}
84     */
85    public function render(mixed ...$data) : string
86    {
87        /** @var array{0:string, 1:string, 2:string, 3?:string, 4?:bool} $data */
88        $this->form        = $data[0];
89        $this->id          = $data[1];
90        $this->name        = $data[2];
91        $this->virtualPath = $data[3] ?? '/';
92        $this->isRequired  = $data[4] ?? false;
93
94        return parent::render();
95    }
96
97    /**
98     * Get selector id
99     *
100     * @return string
101     *
102     * @since 1.0.0
103     */
104    public function getId() : string
105    {
106        return $this->id;
107    }
108
109    /**
110     * Is required?
111     *
112     * @return bool
113     *
114     * @since 1.0.0
115     */
116    public function isRequired() : bool
117    {
118        return $this->isRequired;
119    }
120}