text changes to registration mail content
[namibia] / module / Auction / src / Auction / Entity / Basket.php
1 <?php
2 namespace Auction\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A price guide club member.
10  *
11  * @ORM\Entity
12  * @ORM\HasLifecycleCallbacks
13  * @ORM\Table(name="auction_basket")
14  */
15 class Basket
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="Auction")
45          * @ORM\JoinColumn(nullable=false, name="auction_id")
46          **/
47         protected $auction;
48
49         /**
50          * @ORM\ManyToOne(targetEntity="\Company\Entity\Company")
51          * @ORM\JoinColumn(nullable=false, name="company_id")
52          **/
53         protected $company;
54
55         /**
56          * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
57          * @ORM\JoinColumn(nullable=false, name="profile_id")
58          **/
59         protected $profile;
60
61
62         /* ------------------------------------ Tracking ------------------------------------ */
63         /**
64          * @ORM\Column(type="datetime");
65          */
66         protected $created;
67
68         /**
69          * @ORM\Column(type="datetime", nullable=true);
70          */
71         protected $updated;
72
73         /**
74          * @ORM\Column(type="boolean");
75          */
76         protected $archived = false;
77
78
79
80         /**
81          * Magic getter to expose protected properties.
82          *
83          * @param string $property
84          * @return mixed
85          */
86         public function __get($property)
87         {
88                 return $this->$property;
89         }
90
91         /**
92          * Magic setter to save protected properties.
93          *
94          * @param string $property
95          * @param mixed $value
96          */
97         public function __set($property, $value)
98         {
99                 $this->$property = $value;
100         }
101
102         /**
103          * @ORM\PrePersist
104          */
105         public function setCreateTime()
106         {
107         $authData = \Utility\Registry::getAuthData();
108         $em = \Utility\Registry::getEntityManager();
109
110
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");
116         }
117
118         /**
119          * @ORM\PreUpdate
120          */
121         public function setUpdateTime()
122         {
123                 $this->updated = new \DateTime("now");
124         }
125
126         /**
127          * Convert the object to an array.
128          * @param array $expand
129          * @param array $intersect
130          * @param boolean $showIdentifiers
131          * @param integer $expandAll
132          * @return array
133          */
134         public function toArray(
135                         array $expand = array(), array $intersect = array(),
136                         $showIdentifiers = false, $expandAll = 0
137                         )
138         {
139                 $intersect = array_flip($intersect);
140                 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
141                 $includeAll = empty($intersect);
142                 $data = array();
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)
151                                 : null;
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)
158                                 : null;
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)
165                                 : null;
166                 ($includeAll || isset($intersect['created']))
167                         && $data['created'] = !is_null($this->created)
168                                 ? $this->created->format($dateTimeFormat)
169                                 : null;
170                 ($includeAll || isset($intersect['updated']))
171                         && $data['updated'] = !is_null($this->updated)
172                                 ? $this->updated->format($dateTimeFormat)
173                                 : null;
174                 ($includeAll || isset($intersect['archived']))
175                         && $data['archived'] = $this->archived;
176                 return $data;
177         }
178
179         /**
180          * Populate from an array.
181          * @param array $data
182          */
183         public function fromArray($data = array())
184         {
185                 isset($data['id'])
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'];
195         }
196
197
198
199 }
200