initial commit
[namibia] / module / Auction / src / Auction / Entity / Reply.php
1 <?php
2 namespace Auction\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A reply concerning an item on question..
10  *
11  * @ORM\Entity
12  * @ORM\HasLifecycleCallbacks
13  * @ORM\Table(name="auction_reply")
14  */
15 class Reply
16 {
17
18         /**
19          * Can archive records.
20          */
21         const ARCHIVE = true;
22         /**
23          * Pull Synchronization Strategy for this table.
24          */
25         const PULL_SYNCH_STRATEGY = false;
26         /**
27          * Push Synchronization Strategy for this table.
28          */
29         const PUSH_SYNCH_STRATEGY = false;
30
31
32
33         /* ------------------------------------ Identification ------------------------------------ */
34         /**
35          * @ORM\Id
36          * @ORM\Column(type="integer");
37          * @ORM\GeneratedValue(strategy="AUTO")
38          */
39         protected $id;
40
41
42         /* ------------------------------------ Ownership ------------------------------------ */
43         /**
44          * @ORM\ManyToOne(targetEntity="Question")
45          * @ORM\JoinColumn(nullable=false, name="auction_question_id")
46          **/
47         protected $question;
48
49         /**
50          * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
51          * @ORM\JoinColumn(nullable=false, name="profile_id")
52          **/
53         protected $profile;
54
55
56         /* ------------------------------------ Reply ------------------------------------ */
57         /**
58          * @ORM\Column(type="text")
59          */
60         protected $reply = '';
61
62
63         /* ------------------------------------ Tracking ------------------------------------ */
64
65         /**
66          * @ORM\Column(type="boolean");
67          */
68         protected $archived = false;
69
70
71
72         /**
73          * Magic getter to expose protected properties.
74          *
75          * @param string $property
76          * @return mixed
77          */
78         public function __get($property)
79         {
80                 return $this->$property;
81         }
82
83         /**
84          * Magic setter to save protected properties.
85          *
86          * @param string $property
87          * @param mixed $value
88          */
89         public function __set($property, $value)
90         {
91                 $this->$property = $value;
92         }
93
94         /**
95          * @ORM\PrePersist
96          */
97         public function setCreateTime()
98         {
99                 is_null($this->profile)
100                         && $this->profile = \Utility\Registry::resolveProfileContext($this->profile);
101         }
102
103         /**
104          * Convert the object to an array.
105          * @param array $expand
106          * @param array $intersect
107          * @param boolean $showIdentifiers
108          * @param integer $expandAll
109          * @return array
110          */
111         public function toArray(
112                         array $expand = array(), array $intersect = array(),
113                         $showIdentifiers = false, $expandAll = 0
114                         )
115         {
116                 $intersect = array_flip($intersect);
117                 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
118                 $includeAll = empty($intersect);
119                 $data = array();
120                 ($includeAll || isset($intersect['id']))
121                         && $data['id'] = $this->id;
122                 ($includeAll || isset($intersect['profile']))
123                         && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers)
124                                                                         && !is_null($this->profile)
125                                 ? (!$showIdentifiers ? $this->profile->toArray(
126                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
127                                                 ) : $this->profile->id)
128                                 : null;
129                 ($includeAll || isset($intersect['reply']))
130                         && $data['reply'] = $this->reply;
131                 return $data;
132         }
133
134         /**
135          * Populate from an array.
136          * @param array $data
137          */
138         public function fromArray($data = array())
139         {
140                 isset($data['id'])
141                         && $this->id = $data['id'];
142                 isset($data['question'])
143                         && $this->question = $data['question'];
144                 isset($data['profile'])
145                         && $this->profile = $data['profile'];
146                 isset($data['reply'])
147                         && $this->reply = $data['reply'];
148         }
149
150
151
152 }
153