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