Completed
Push — master ( 0e3d33...33a693 )
by greg
08:28 queued 04:16
created

PostVotePostElement::populate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use Doctrine\ORM\Mapping as ORM;
5
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
6
use Doctrine\ORM\Mapping\PrePersist;
7
use Doctrine\ORM\Mapping\PreUpdate;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use Gedmo\Translatable\Translatable;
10
use Zend\InputFilter\InputFilter;
11
use Zend\InputFilter\InputFilterAwareInterface;
12
use Zend\InputFilter\InputFilterInterface;
13
14
/**
15
 * @ORM\Entity @HasLifecycleCallbacks
16
 * @ORM\Table(name="game_postvote_post_element")
17
 * @Gedmo\TranslationEntity(class="PlaygroundGame\Entity\PostVotePostElementTranslation")
18
 */
19
class PostVotePostElement implements InputFilterAwareInterface, Translatable, \JsonSerializable
20
{
21
    /**
22
     * @Gedmo\Locale
23
     * Used locale to override Translation listener`s locale
24
     * this is not a mapped field of entity metadata, just a simple property
25
     */
26
    protected $locale;
27
28
    protected $inputFilter;
29
30
    /**
31
     * @ORM\Id
32
     * @ORM\Column(type="integer");
33
     * @ORM\GeneratedValue(strategy="AUTO")
34
     */
35
    protected $id;
36
37
    /**
38
     * @ORM\ManyToOne(targetEntity="PostVotePost", inversedBy="postElements")
39
     * @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE")
40
     *
41
     **/
42
    protected $post;
43
44
    /**
45
     * @ORM\Column(type="string", nullable=true)
46
     */
47
    protected $name;
48
49
    /**
50
     * @Gedmo\Translatable
51
     * @ORM\Column(type="text", nullable=true)
52
     */
53
    protected $value;
54
55
    /**
56
     * @Gedmo\Translatable
57
     * @ORM\Column(type="text", nullable=true)
58
     */
59
    protected $label;
60
61
    /**
62
     * @ORM\Column(type="string", nullable=true)
63
     */
64
    protected $position;
65
66
    /**
67
     * @ORM\Column(name="created_at", type="datetime")
68
     */
69
    protected $createdAt;
70
71
    /**
72
     * @ORM\Column(name="updated_at", type="datetime")
73
     */
74
    protected $updatedAt;
75
76
    public function __construct()
77
    {
78
    }
79
80
    /** @PrePersist */
81
    public function createChrono()
82
    {
83
        $this->createdAt = new \DateTime("now");
84
        $this->updatedAt = new \DateTime("now");
85
    }
86
87
    /** @PreUpdate */
88
    public function updateChrono()
89
    {
90
        $this->updatedAt = new \DateTime("now");
91
    }
92
93
    /**
94
     * @return the unknown_type
95
     */
96
    public function getId()
97
    {
98
        return $this->id;
99
    }
100
101
    /**
102
     * @param unknown_type $id
103
     */
104
    public function setId($id)
105
    {
106
        $this->id = $id;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return the unknown_type
113
     */
114
    public function getPost()
115
    {
116
        return $this->post;
117
    }
118
119
    /**
120
     * @param unknown_type $post
121
     */
122
    public function setPost($post)
123
    {
124
        $this->post = $post;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @return the unknown_type
131
     */
132
    public function getValue()
133
    {
134
        return $this->value;
135
    }
136
137
    /**
138
     * @param unknown_type $label
139
     */
140
    public function setLabel($label)
141
    {
142
        $this->label = $label;
143
144
        return $this;
145
    }
146
147
    /**
148
     * @return the unknown_type
149
     */
150
    public function getLabel()
151
    {
152
        return $this->label;
153
    }
154
155
    /**
156
     * @param unknown_type $value
157
     */
158
    public function setValue($value)
159
    {
160
        $this->value = $value;
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return the unknown_type
167
     */
168
    public function getName()
169
    {
170
        return $this->name;
171
    }
172
173
    /**
174
     * @param unknown_type $name
175
     */
176
    public function setName($name)
177
    {
178
        $this->name = $name;
179
180
        return $this;
181
    }
182
183
    /**
184
     * @return the unknown_type
185
     */
186
    public function getPosition()
187
    {
188
        return $this->position;
189
    }
190
191
    /**
192
     * @param unknown_type $position
193
     */
194
    public function setPosition($position)
195
    {
196
        $this->position = $position;
197
198
        return $this;
199
    }
200
201
    /**
202
     * @return the unknown_type
203
     */
204
    public function getCreatedAt()
205
    {
206
        return $this->createdAt;
207
    }
208
209
    /**
210
     * @param unknown_type $createdAt
211
     */
212
    public function setCreatedAt($createdAt)
213
    {
214
        $this->createdAt = $createdAt;
215
216
        return $this;
217
    }
218
219
    /**
220
     * @return the unknown_type
221
     */
222
    public function getUpdatedAt()
223
    {
224
        return $this->updatedAt;
225
    }
226
227
    /**
228
     * @param unknown_type $updatedAt
229
     */
230
    public function setUpdatedAt($updatedAt)
231
    {
232
        $this->updatedAt = $updatedAt;
233
234
        return $this;
235
    }
236
237
    /**
238
     * Convert the object to an array.
239
     *
240
     * @return array
241
     */
242
    public function getArrayCopy()
243
    {
244
        $obj_vars = get_object_vars($this);
245
        // if called from getArrayCopy of PostVotePost,
246
        // keeping the post object in each element produce an infinite loop...
247
        if (isset($obj_vars['post'])) {
248
            $obj_vars['post'] = null;
249
        }
250
251
        return $obj_vars;
252
    }
253
254
    /**
255
     * Convert the object to json.
256
     *
257
     * @return array
258
     */
259
    public function jsonSerialize()
260
    {
261
        return $this->getArrayCopy();
262
    }
263
264
    /**
265
     * Populate from an array.
266
     *
267
     * @param array $data
268
     */
269
    public function populate($data = array())
270
    {
271
    }
272
273
    public function setInputFilter(InputFilterInterface $inputFilter)
274
    {
275
        throw new \Exception("Not used");
276
    }
277
278
    public function getInputFilter()
279
    {
280
        if (!$this->inputFilter) {
281
            $inputFilter = new InputFilter();
282
283
            $this->inputFilter = $inputFilter;
284
        }
285
286
        return $this->inputFilter;
287
    }
288
289
    public function setTranslatableLocale($locale)
290
    {
291
        $this->locale = $locale;
292
    }
293
}
294