2 namespace Auction\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * A price guide club member.
12 * @ORM\HasLifecycleCallbacks
13 * @ORM\Table(name="auction_bid")
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", cascade={"all"})
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="AutoBid")
63 * @ORM\JoinColumn(nullable=true, name="auction_autobid_id")
68 /* ------------------------------------ Bid ------------------------------------ */
70 * @ORM\Column(type="decimal", scale=2, precision=11, nullable=false, options={"unsigned"=true});
72 protected $amount = 0.0;
75 /* ------------------------------------ Tracking ------------------------------------ */
77 * @ORM\Column(type="string", length=25, nullable=true, name="status");
79 protected $status = 'Active';
82 * @ORM\Column(type="datetime");
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");
128 * Convert the object to an array.
129 * @param array $expand
130 * @param array $intersect
131 * @param boolean $showIdentifiers
132 * @param integer $expandAll
135 public function toArray(
136 array $expand = array(), array $intersect = array(),
137 $showIdentifiers = false, $expandAll = 0
140 $intersect = array_flip($intersect);
141 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
142 $includeAll = empty($intersect);
144 ($includeAll || isset($intersect['id']))
145 && $data['id'] = $this->id;
146 ($includeAll || isset($intersect['auction']))
147 && $data['auction'] = (in_array('auction', $expand) || $expandAll || $showIdentifiers)
148 && !is_null($this->auction)
149 ? (!$showIdentifiers ? $this->auction->toArray(
150 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
151 ) : $this->auction->id)
153 ($includeAll || isset($intersect['company']))
154 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
155 && !is_null($this->company)
156 ? (!$showIdentifiers ? $this->company->toArray(
157 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
158 ) : $this->company->id)
160 ($includeAll || isset($intersect['profile']))
161 && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers)
162 && !is_null($this->profile)
163 ? (!$showIdentifiers ? $this->profile->toArray(
164 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
165 ) : $this->profile->id)
167 ($includeAll || isset($intersect['autoBid']))
168 && $data['autoBid'] = (in_array('autoBid', $expand) || $expandAll || $showIdentifiers)
169 && !is_null($this->autoBid)
170 ? (!$showIdentifiers ? $this->autoBid->toArray(
171 array(), array(), true, false
172 /* $expand, $intersect, $showIdentifiers, ($expandAll - 1) */
173 ) : $this->autoBid->id)
175 ($includeAll || isset($intersect['amount']))
176 && $data['amount'] = $this->amount;
177 ($includeAll || isset($intersect['status']))
178 && $data['status'] = $this->status;
179 ($includeAll || isset($intersect['created']))
180 && $data['created'] = !is_null($this->created)
181 ? $this->created->format($dateTimeFormat)
187 * Populate from an array.
190 public function fromArray($data = array())
193 && $this->id = $data['id'];
194 isset($data['auction'])
195 && $this->auction = $data['auction'];
196 isset($data['company'])
197 && $this->company = $data['company'];
198 isset($data['profile'])
199 && $this->profile = $data['profile'];
200 isset($data['autoBid'])
201 && $this->autoBid = $data['autoBid'];
202 isset($data['amount'])
203 && $this->amount = $data['amount'];
204 isset($data['status'])
205 && $this->status = $data['status'];