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_basket")
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 /* ------------------------------------ Tracking ------------------------------------ */
64 * @ORM\Column(type="datetime");
69 * @ORM\Column(type="datetime", nullable=true);
74 * @ORM\Column(type="boolean");
76 protected $archived = false;
81 * Magic getter to expose protected properties.
83 * @param string $property
86 public function __get($property)
88 return $this->$property;
92 * Magic setter to save protected properties.
94 * @param string $property
97 public function __set($property, $value)
99 $this->$property = $value;
105 public function setCreateTime()
107 $authData = \Utility\Registry::getAuthData();
108 $em = \Utility\Registry::getEntityManager();
111 is_null($this->company)
112 && $this->company = $em->getReference('\Company\Entity\Company',$authData['company']['id']);
113 is_null($this->profile)
114 && $this->profile = $em->getReference('\User\Entity\Profile',$authData['id']);
115 $this->created = new \DateTime("now");
121 public function setUpdateTime()
123 $this->updated = new \DateTime("now");
127 * Convert the object to an array.
128 * @param array $expand
129 * @param array $intersect
130 * @param boolean $showIdentifiers
131 * @param integer $expandAll
134 public function toArray(
135 array $expand = array(), array $intersect = array(),
136 $showIdentifiers = false, $expandAll = 0
139 $intersect = array_flip($intersect);
140 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
141 $includeAll = empty($intersect);
143 ($includeAll || isset($intersect['id']))
144 && $data['id'] = $this->id;
145 ($includeAll || isset($intersect['auction']))
146 && $data['auction'] = (in_array('auction', $expand) || $expandAll || $showIdentifiers)
147 && !is_null($this->auction)
148 ? (!$showIdentifiers ? $this->auction->toArray(
149 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
150 ) : $this->auction->id)
152 ($includeAll || isset($intersect['company']))
153 && $data['company'] = (in_array('company', $expand) || $expandAll || $showIdentifiers)
154 && !is_null($this->company)
155 ? (!$showIdentifiers ? $this->company->toArray(
156 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
157 ) : $this->company->id)
159 ($includeAll || isset($intersect['profile']))
160 && $data['profile'] = (in_array('profile', $expand) || $expandAll || $showIdentifiers)
161 && !is_null($this->profile)
162 ? (!$showIdentifiers ? $this->profile->toArray(
163 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
164 ) : $this->profile->id)
166 ($includeAll || isset($intersect['created']))
167 && $data['created'] = !is_null($this->created)
168 ? $this->created->format($dateTimeFormat)
170 ($includeAll || isset($intersect['updated']))
171 && $data['updated'] = !is_null($this->updated)
172 ? $this->updated->format($dateTimeFormat)
174 ($includeAll || isset($intersect['archived']))
175 && $data['archived'] = $this->archived;
180 * Populate from an array.
183 public function fromArray($data = array())
186 && $this->id = $data['id'];
187 isset($data['auction'])
188 && $this->auction = $data['auction'];
189 isset($data['company'])
190 && $this->company = $data['company'];
191 isset($data['profile'])
192 && $this->profile = $data['profile'];
193 isset($data['archived'])
194 && $this->archived = $data['archived'];