Completed
Push — master ( e95261...40aeb3 )
by greg
04:30 queued 01:59
created

PostVoteView::updateChrono()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
7
use Doctrine\ORM\Mapping\PrePersist;
8
use Doctrine\ORM\Mapping\PreUpdate;
9
use Zend\InputFilter\InputFilter;
10
use Zend\InputFilter\InputFilterAwareInterface;
11
use Zend\InputFilter\InputFilterInterface;
12
13
/**
14
 * @ORM\Entity @HasLifecycleCallbacks
15
 * @ORM\Table(name="game_postvote_view")
16
 */
17
class PostVoteView implements InputFilterAwareInterface, \JsonSerializable
18
{
19
    protected $inputFilter;
20
21
    /**
22
     * @ORM\Id
23
     * @ORM\Column(type="integer");
24
     * @ORM\GeneratedValue(strategy="AUTO")
25
     */
26
    protected $id;
27
28
    /**
29
     * @ORM\ManyToOne(targetEntity="PostVotePost", inversedBy="comments")
30
     * @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE")
31
     **/
32
    protected $post;
33
34
    /**
35
     * @ORM\ManyToOne(targetEntity="PostVote")
36
     **/
37
    protected $postvote;
38
39
    /**
40
     * @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User")
41
     * @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", onDelete="CASCADE")
42
     **/
43
    protected $user;
44
45
    /**
46
     * @ORM\Column(type="text", nullable=true)
47
     */
48
    protected $ip;
49
50
    /**
51
     * @ORM\Column(name="created_at", type="datetime")
52
     */
53
    protected $createdAt;
54
55
    /**
56
     * @ORM\Column(name="updated_at", type="datetime")
57
     */
58
    protected $updatedAt;
59
60
    /** @PrePersist */
61
    public function createChrono()
62
    {
63
        $this->createdAt = new \DateTime("now");
64
        $this->updatedAt = new \DateTime("now");
65
    }
66
67
    /** @PreUpdate */
68
    public function updateChrono()
69
    {
70
        $this->updatedAt = new \DateTime("now");
71
    }
72
73
    /**
74
     * @return the unknown_type
75
     */
76
    public function getId()
77
    {
78
        return $this->id;
79
    }
80
81
    /**
82
     * @param unknown_type $id
83
     */
84
    public function setId($id)
85
    {
86
        $this->id = $id;
87
88
        return $this;
89
    }
90
91
    /**
92
     * @return string unknown_type
93
     */
94
    public function getIp()
95
    {
96
        return $this->ip;
97
    }
98
99
    /**
100
     * @param string $ip
101
     */
102
    public function setIp($ip)
103
    {
104
        $this->ip = $ip;
105
106
        return $this;
107
    }
108
109
    /**
110
     * @return the unknown_type
111
     */
112
    public function getUser()
113
    {
114
        return $this->user;
115
    }
116
117
    /**
118
     * @param unknown_type $user
119
     */
120
    public function setUser($user)
121
    {
122
        $this->user = $user;
123
124
        return $this;
125
    }
126
127
    /**
128
     * @return the unknown_type
129
     */
130
    public function getPost()
131
    {
132
        return $this->post;
133
    }
134
135
    /**
136
     * @param unknown_type $post
137
     */
138
    public function setPost($post)
139
    {
140
        // Check that there is no drawback using the cascading update from PostVoteEntry
141
        $post->addView($this);
142
        $this->post = $post;
143
144
        return $this;
145
    }
146
147
    /**
148
     * @return the unknown_type
149
     */
150
    public function getPostvote()
151
    {
152
        return $this->postvote;
153
    }
154
155
    /**
156
     * @param unknown_type $postvote
157
     */
158
    public function setPostvote($postvote)
159
    {
160
        $this->postvote = $postvote;
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return the unknown_type
167
     */
168
    public function getCreatedAt()
169
    {
170
        return $this->createdAt;
171
    }
172
173
    /**
174
     * @param unknown_type $createdAt
175
     */
176
    public function setCreatedAt($createdAt)
177
    {
178
        $this->createdAt = $createdAt;
179
180
        return $this;
181
    }
182
183
    /**
184
     * @return the unknown_type
185
     */
186
    public function getUpdatedAt()
187
    {
188
        return $this->updatedAt;
189
    }
190
191
    /**
192
     * @param unknown_type $updatedAt
193
     */
194
    public function setUpdatedAt($updatedAt)
195
    {
196
        $this->updatedAt = $updatedAt;
197
198
        return $this;
199
    }
200
201
    /**
202
     * Convert the object to an array.
203
     *
204
     * @return array
205
     */
206
    public function getArrayCopy()
207
    {
208
        $obj_vars = get_object_vars($this);
209
210
        return $obj_vars;
211
    }
212
    
213
    /**
214
     * Convert the object to json.
215
     *
216
     * @return array
217
     */
218
    public function jsonSerialize()
219
    {
220
        return $this->getArrayCopy();
221
    }
222
223
    /**
224
     * Populate from an array.
225
     *
226
     * @param array $data
227
     */
228
    public function populate($data = array())
229
    {
230
    }
231
232
    public function setInputFilter(InputFilterInterface $inputFilter)
233
    {
234
        throw new \Exception("Not used");
235
    }
236
237
    public function getInputFilter()
238
    {
239
        if (!$this->inputFilter) {
240
            $inputFilter = new InputFilter();
241
242
            $this->inputFilter = $inputFilter;
243
        }
244
245
        return $this->inputFilter;
246
    }
247
}
248