1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Environment; |
4 | | | |
5 | | | use Doctrine\ORM\Mapping\Column; |
6 | | | use Doctrine\ORM\Mapping\Entity; |
7 | | | use Doctrine\ORM\Mapping\GeneratedValue; |
8 | | | use Doctrine\ORM\Mapping\Id; |
9 | | | use Doctrine\ORM\Mapping\Table; |
10 | | | use JsonSerializable; |
11 | | | use Phem\Core\Object; |
12 | | | |
13 | | | /** |
14 | | | * @author kubapet |
15 | | | * @Entity |
16 | | | * @Table(name="admin_event_args") |
17 | | | */ |
18 | | | class MessageArgs extends Object implements JsonSerializable |
19 | | | { |
20 | | | |
21 | | | /** |
22 | | | * @Id |
23 | | | * @GeneratedValue |
24 | | | * @Column |
25 | | | * (type="integer") |
26 | | | */ |
27 | | | private $id; |
28 | | | |
29 | | | /** |
30 | | | * @ManyToOne(targetEntity="Message",cascade={"persist"}) |
31 | | | * @JoinColumn(name="message", referencedColumnName="id") |
32 | | | */ |
33 | | | private $message; |
34 | | | |
35 | | | /** |
36 | | | * @var String Description |
37 | | | * @Column |
38 | | | * (type="string") |
39 | | | */ |
40 | | | private $actionUrl; |
41 | | | |
42 | | | /* |
43 | | | * append |
44 | | | * prepend |
45 | | | * replace |
46 | | | */ |
47 | | | |
48 | | | /** @Column(type="string") */ |
49 | | | private $actionType; |
50 | | | |
51 | | | /** @Column(type="string") */ |
52 | | | private $actionTarget; |
53 | | | |
54 | | | public function getId() |
55 | | | { |
56 | | | return $this->id; |
57 | | | } |
58 | | | |
59 | | | public function setId($id) |
60 | | | { |
61 | | | $this->id = $id; |
62 | | | } |
63 | | | |
64 | | | public function getMessage() |
65 | | | { |
66 | | | return $this->message; |
67 | | | } |
68 | | | |
69 | | | public function setMessage($message) |
70 | | | { |
71 | | | $this->message = $message; |
72 | | | } |
73 | | | |
74 | | | public function getActionUrl() |
75 | | | { |
76 | | | return $this->actionUrl; |
77 | | | } |
78 | | | |
79 | | | public function setActionUrl($actionUrl) |
80 | | | { |
81 | | | $this->actionUrl = $actionUrl; |
82 | | | } |
83 | | | |
84 | | | public function getActionType() |
85 | | | { |
86 | | | return $this->actionType; |
87 | | | } |
88 | | | |
89 | | | public function setActionType($actionType) |
90 | | | { |
91 | | | $this->actionType = $actionType; |
92 | | | } |
93 | | | |
94 | | | public function getActionTarget() |
95 | | | { |
96 | | | return $this->actionTarget; |
97 | | | } |
98 | | | |
99 | | | public function setActionTarget($actionTarget) |
100 | | | { |
101 | | | $this->actionTarget = $actionTarget; |
102 | | | } |
103 | | | |
104 | | | public function jsonSerialize() |
105 | | | { |
106 | | | |
107 | | | $getters = get_class_methods($this); |
108 | | | $result = array(); |
109 | | | |
110 | | | foreach ($getters as $getter) |
111 | | | { |
112 | | | if (strpos($getter, "get") === 0) |
113 | | | { |
114 | | | $propName = preg_replace('/get/', '', $getter, 1); |
115 | | | $propName{0} = strtolower($propName{0}); |
116 | | | if ($propName == "message") |
117 | | | $result[$propName] = $this->$getter()->getId(); |
118 | | | else |
119 | | | $result[$propName] = $this->$getter(); |
120 | | | } |
121 | | | } |
122 | | | |
123 | | | return $result; |
124 | | | } |
125 | | | |
126 | | | } |