1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Zikula package. |
7
|
|
|
* |
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Zikula\ExtensionsModule\Entity; |
15
|
|
|
|
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
17
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
18
|
|
|
use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Extension var registry. |
22
|
|
|
* |
23
|
|
|
* @ORM\Entity(repositoryClass="Zikula\ExtensionsModule\Entity\Repository\ExtensionVarRepository") |
24
|
|
|
* @ORM\Table(name="module_vars") |
25
|
|
|
*/ |
26
|
|
|
class ExtensionVarEntity extends EntityAccess |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @ORM\Id |
30
|
|
|
* @ORM\GeneratedValue |
31
|
|
|
* @ORM\Column(type="integer") |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
private $id; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @ORM\Column(type="string", length=64) |
38
|
|
|
* @Assert\Length(min="1", max="64") |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $modname; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @ORM\Column(type="string", length=64) |
45
|
|
|
* @Assert\Length(min="1", max="64") |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
private $name; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @ORM\Column(type="text", length=512) |
52
|
|
|
* @Assert\Length(min="1", max="512") |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
private $value; |
56
|
|
|
|
57
|
|
|
public function getId(): ?int |
58
|
|
|
{ |
59
|
|
|
return $this->id; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function setId(int $id): self |
63
|
|
|
{ |
64
|
|
|
$this->id = $id; |
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getModname(): string |
70
|
|
|
{ |
71
|
|
|
return $this->modname; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function setModname(string $modname): self |
75
|
|
|
{ |
76
|
|
|
$this->modname = $modname; |
77
|
|
|
|
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function getName(): string |
82
|
|
|
{ |
83
|
|
|
return $this->name; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function setName(string $name): self |
87
|
|
|
{ |
88
|
|
|
$this->name = $name; |
89
|
|
|
|
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getValue() |
94
|
|
|
{ |
95
|
|
|
// temporarily suppress E_NOTICE to avoid using @unserialize |
96
|
|
|
$errorReporting = error_reporting(error_reporting() ^ E_NOTICE); |
97
|
|
|
|
98
|
|
|
try { |
99
|
|
|
$result = unserialize($this->value); |
100
|
|
|
} catch (\ErrorException $exception) { |
101
|
|
|
$result = null; |
102
|
|
|
// Warning: Class __PHP_Incomplete_Class has no unserializer |
103
|
|
|
// may happen during CLI upgrades for example |
104
|
|
|
// see also https://github.com/symfony/symfony/issues/20654 |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
error_reporting($errorReporting); |
108
|
|
|
|
109
|
|
|
return $result; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function setValue($value): self |
113
|
|
|
{ |
114
|
|
|
$this->value = serialize($value); |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|