Completed
Push — master ( 58523e...56a418 )
by greg
37:25 queued 34:17
created

PostVoteVote::setPostComment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
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 Zend\InputFilter\InputFilter;
9
use Zend\InputFilter\InputFilterAwareInterface;
10
use Zend\InputFilter\InputFilterInterface;
11
12
/**
13
 * @ORM\Entity @HasLifecycleCallbacks
14
 * @ORM\Table(name="game_postvote_vote")
15
 */
16
class PostVoteVote implements InputFilterAwareInterface, \JsonSerializable
17
{
18
    protected $inputFilter;
19
20
    /**
21
     * @ORM\Id
22
     * @ORM\Column(type="integer");
23
     * @ORM\GeneratedValue(strategy="AUTO")
24
     */
25
    protected $id;
26
27
    /**
28
     * @ORM\ManyToOne(targetEntity="PostVotePost", inversedBy="votes")
29
     * @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE")
30
     **/
31
    protected $post;
32
33
    /**
34
     * @ORM\ManyToOne(targetEntity="PostVote")
35
     **/
36
    protected $postvote;
37
38
    /**
39
     * @ORM\ManyToOne(targetEntity="PostVoteComment", inversedBy="votes")
40
     * @ORM\JoinColumn(name="comment_id", referencedColumnName="id", onDelete="CASCADE")
41
     **/
42
    protected $postComment;
43
44
    /**
45
     * @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User")
46
     * @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", onDelete="CASCADE")
47
     */
48
    protected $user;
49
50
    /**
51
     * @ORM\Column(type="text", nullable=true)
52
     */
53
    protected $ip;
54
55
    /**
56
     * @ORM\Column(type="text", nullable=true)
57
     */
58
    protected $message;
59
60
    /**
61
     * @ORM\Column(type="string", nullable=true)
62
     */
63
    protected $note;
64
65
    /**
66
     * @ORM\Column(name="created_at", type="datetime")
67
     */
68
    protected $createdAt;
69
70
    /**
71
     * @ORM\Column(name="updated_at", type="datetime")
72
     */
73
    protected $updatedAt;
74
75
    /** @PrePersist */
76
    public function createChrono()
77
    {
78
        $this->createdAt = new \DateTime("now");
79
        $this->updatedAt = new \DateTime("now");
80
    }
81
82
    /** @PreUpdate */
83
    public function updateChrono()
84
    {
85
        $this->updatedAt = new \DateTime("now");
86
    }
87
88
    /**
89
     * @return the unknown_type
90
     */
91
    public function getId()
92
    {
93
        return $this->id;
94
    }
95
96
    /**
97
     * @param unknown_type $id
98
     */
99
    public function setId($id)
100
    {
101
        $this->id = $id;
102
103
        return $this;
104
    }
105
106
    /**
107
     * @return string unknown_type
108
     */
109
    public function getIp()
110
    {
111
        return $this->ip;
112
    }
113
114
    /**
115
     * @param string $ip
116
     */
117
    public function setIp($ip)
118
    {
119
        $this->ip = $ip;
120
121
        return $this;
122
    }
123
124
    /**
125
     * @return the unknown_type
126
     */
127
    public function getUser()
128
    {
129
        return $this->user;
130
    }
131
132
    /**
133
     * @param unknown_type $user
134
     */
135
    public function setUser($user)
136
    {
137
        $this->user = $user;
138
139
        return $this;
140
    }
141
142
    /**
143
     * @return the unknown_type
144
     */
145
    public function getPost()
146
    {
147
        return $this->post;
148
    }
149
150
    /**
151
     * @param unknown_type $post
152
     */
153
    public function setPost($post, $isAVoteForPost=false)
154
    {
155
        // echo get_class($post);
156
        // echo $post->getId();
157
        // die('---');
158
        // Check that there is no drawback using the cascading update from PostVoteEntry
159
        if ($isAVoteForPost) {
160
            $post->addVote($this);
161
        }
162
163
        $this->post = $post;
164
165
        return $this;
166
    }
167
168
    /**
169
     * @return the unknown_type
170
     */
171
    public function getPostComment()
172
    {
173
        return $this->postComment;
174
    }
175
176
    /**
177
     * @param unknown_type $postComment
178
     */
179
    public function setPostComment($postComment)
180
    {
181
        // Check that there is no drawback using the cascading update from PostVoteEntry
182
        $postComment->addVote($this);
183
        $this->postComment = $postComment;
184
185
        return $this;
186
    }
187
188
    /**
189
     * @return the unknown_type
190
     */
191
    public function getPostvote()
192
    {
193
        return $this->postvote;
194
    }
195
196
    /**
197
     * @param unknown_type $postvote
198
     */
199
    public function setPostvote($postvote)
200
    {
201
        $this->postvote = $postvote;
202
203
        return $this;
204
    }
205
206
    /**
207
    * @return the unknown_type
208
    */
209
    public function getMessage()
210
    {
211
        return $this->message;
212
    }
213
214
    /**
215
     * @param unknown_type $message
216
     */
217
    public function setMessage($message)
218
    {
219
        $this->message = $message;
220
221
        return $this;
222
    }
223
224
    /**
225
    * @return the unknown_type
226
    */
227
    public function getNote()
228
    {
229
        return $this->note;
230
    }
231
232
    /**
233
     * @param unknown_type $note
234
     */
235
    public function setNote($note)
236
    {
237
        $this->note = $note;
238
239
        return $this;
240
    }
241
242
    /**
243
     * @return the unknown_type
244
     */
245
    public function getCreatedAt()
246
    {
247
        return $this->createdAt;
248
    }
249
250
    /**
251
     * @param unknown_type $createdAt
252
     */
253
    public function setCreatedAt($createdAt)
254
    {
255
        $this->createdAt = $createdAt;
256
257
        return $this;
258
    }
259
260
    /**
261
     * @return the unknown_type
262
     */
263
    public function getUpdatedAt()
264
    {
265
        return $this->updatedAt;
266
    }
267
268
    /**
269
     * @param unknown_type $updatedAt
270
     */
271
    public function setUpdatedAt($updatedAt)
272
    {
273
        $this->updatedAt = $updatedAt;
274
275
        return $this;
276
    }
277
278
    /**
279
     * Convert the object to an array.
280
     *
281
     * @return array
282
     */
283
    public function getArrayCopy()
284
    {
285
        $obj_vars = get_object_vars($this);
286
287
        return $obj_vars;
288
    }
289
    
290
    /**
291
     * Convert the object to json.
292
     *
293
     * @return array
294
     */
295
    public function jsonSerialize()
296
    {
297
        return $this->getArrayCopy();
298
    }
299
300
    /**
301
     * Populate from an array.
302
     *
303
     * @param array $data
304
     */
305
    public function populate($data = array())
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
306
    {
307
    }
308
309
    public function setInputFilter(InputFilterInterface $inputFilter)
310
    {
311
        throw new \Exception("Not used");
312
    }
313
314
    public function getInputFilter()
315
    {
316
        if (!$this->inputFilter) {
317
            $inputFilter = new InputFilter();
318
319
            $this->inputFilter = $inputFilter;
320
        }
321
322
        return $this->inputFilter;
323
    }
324
}
325