2 namespace Auction\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * A question concerning an item on auction..
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="auction_question")
19 * Can archive records.
23 * Pull Synchronization Strategy for this table.
25 const PULL_SYNCH_STRATEGY = false;
27 * Push Synchronization Strategy for this table.
29 const PUSH_SYNCH_STRATEGY = false;
33 /* ------------------------------------ Identification ------------------------------------ */
36 * @ORM\Column(type="integer");
37 * @ORM\GeneratedValue(strategy="AUTO")
42 /* ------------------------------------ Ownership ------------------------------------ */
44 * @ORM\ManyToOne(targetEntity="Auction")
45 * @ORM\JoinColumn(nullable=false, name="auction_id")
50 * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
51 * @ORM\JoinColumn(nullable=false, name="company_id")
56 * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
57 * @ORM\JoinColumn(nullable=false, name="profile_id")
62 * @ORM\ManyToOne(targetEntity="Reply")
63 * @ORM\JoinColumn(nullable=true, name="auction_reply_id")
68 /* ------------------------------------ Question ------------------------------------ */
70 * @ORM\Column(type="text")
72 protected $question = '';
75 /* ------------------------------------ Tracking ------------------------------------ */
77 * @ORM\Column(type="datetime");
82 * @ORM\Column(type="datetime", nullable=true);
87 * @ORM\Column(type="boolean");
89 protected $archived = false;
94 * Magic getter to expose protected properties.
96 * @param string $property
99 public function __get($property)
101 return $this->$property;
105 * Magic setter to save protected properties.
107 * @param string $property
108 * @param mixed $value
110 public function __set($property, $value)
112 $this->$property = $value;
118 public function setCreateTime()
120 is_null($this->company)
121 && $this->company = \Utility\Registry::resolveCompanyContext($this->company);
122 is_null($this->profile)
123 && $this->profile = \Utility\Registry::resolveProfileContext($this->profile);
124 $this->created = new \DateTime("now");
130 public function setUpdateTime()
132 $this->updated = new \DateTime("now");
136 * Convert the object to an array.
137 * @param array $expand
138 * @param array $intersect
139 * @param boolean $showIdentifiers
140 * @param integer $expandAll
143 public function toArray(
144 array $expand = array(), array $intersect = array(),
145 $showIdentifiers = false, $expandAll = 0
148 $intersect = array_flip($intersect);
149 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
150 $includeAll = empty($intersect);
152 ($includeAll || isset($intersect['id']))
153 && $data['id'] = $this->id;
154 ($includeAll || isset($intersect['auction']))
155 && $data['auction'] = (in_array('auction', $expand) || $expandAll || $showIdentifiers)
156 && !is_null($this->auction)
157 ? (!$showIdentifiers ? $this->auction->toArray(
158 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
159 ) : $this->auction->id)
161 ($includeAll || isset($intersect['company']))
162 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
163 && !is_null($this->company)
164 ? (!$showIdentifiers ? $this->company->toArray(
165 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
166 ) : $this->company->id)
168 ($includeAll || isset($intersect['profile']))
169 && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers)
170 && !is_null($this->profile)
171 ? (!$showIdentifiers ? $this->profile->toArray(
172 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
173 ) : $this->profile->id)
175 ($includeAll || isset($intersect['reply']))
176 && $data['reply'] = (in_array('reply', $expand) || $expandAll || $showIdentifiers)
177 && !is_null($this->reply)
178 ? (!$showIdentifiers ? $this->reply->toArray(
179 array(), array(), true, false
180 /* $expand, $intersect, $showIdentifiers, ($expandAll - 1) */
181 ) : $this->reply->id)
183 ($includeAll || isset($intersect['question']))
184 && $data['question'] = $this->question;
185 ($includeAll || isset($intersect['created']))
186 && $data['created'] = !is_null($this->created)
187 ? $this->created->format($dateTimeFormat)
189 ($includeAll || isset($intersect['updated']))
190 && $data['updated'] = !is_null($this->updated)
191 ? $this->updated->format($dateTimeFormat)
197 * Populate from an array.
200 public function fromArray($data = array())
203 && $this->id = $data['id'];
204 isset($data['auction'])
205 && $this->auction = $data['auction'];
206 isset($data['company'])
207 && $this->company = $data['company'];
208 isset($data['profile'])
209 && $this->profile = $data['profile'];
210 isset($data['reply'])
211 && $this->reply = $data['reply'];
212 isset($data['question'])
213 && $this->question = $data['question'];