initial commit
[namibia] / module / Valuation / src / Valuation / Entity / ValuationTimeSlots.php
1 <?php
2 namespace Valuation\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A valuation.
10  *
11  * @ORM\Entity
12  * @ORM\HasLifecycleCallbacks
13  * @ORM\Table(name="valuation_time_slots")
14  */
15 class ValuationTimeSlots
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 = 'Build';
26         /**
27          * Push Synchronization Strategy for this table.
28          */
29         const PUSH_SYNCH_STRATEGY = 'Update';
30         /**
31          * Post insert action must be called after new entity is flushed to database.
32          */
33         const HAVE_POST_INSERT = true;
34         /**
35          * Handle as a job queue for mobile devices.
36          */
37         const JOB_QUEUE = true;
38
39         /* ------------------------------------ Identification ------------------------------------ */
40         /**
41          * @ORM\Id
42          * @ORM\Column(type="integer");
43          * @ORM\GeneratedValue(strategy="AUTO")
44          */
45     protected $id;
46
47         /**
48          * @ORM\Column(type="string", length=20, nullable=false, name="time_slot");
49          */
50     protected $timeSlot;
51
52     /**
53      * @ORM\Column(type="string", length=20, nullable=false, name="time_slot_display_name");
54      */
55     protected $timeSlotDisplayName;
56
57         /**
58          * @ORM\Column(type="datetime");
59          */
60     protected $created;
61
62         /**
63          * @ORM\Column(type="datetime", nullable=true);
64          */
65     protected $updated;
66
67         /**
68          * @ORM\Column(type="boolean");
69          */
70     protected $archived = false;
71
72
73     /**
74      * @ORM\OneToMany(targetEntity="ValuationAppointments", mappedBy="timeSlot", cascade={"all"}, fetch="EXTRA_LAZY")
75      **/
76     protected $appointmentTimeSlot;
77
78     /**
79      * Magic getter to expose protected properties.
80      *
81      * @param string $property
82      * @return mixed
83      */
84     public function __get($property)
85     {
86         return $this->$property;
87     }
88
89     /**
90      * Magic setter to save protected properties.
91      *
92      * @param string $property
93      * @param mixed $value
94      */
95     public function __set($property, $value)
96     {
97         $this->$property = $value;
98     }
99
100         /**
101          * @ORM\PrePersist
102          */
103         public function setCreateTime()
104         {
105                 $this->created = new \DateTime("now");
106         }
107
108         /**
109          * @ORM\PreUpdate
110          */
111         public function setUpdateTime()
112         {
113                 $this->updated = new \DateTime("now");
114         }
115
116         /**
117          * Convert the object to an array.
118          * @param array $expand
119          * @param array $intersect
120          * @param boolean $showIdentifiers
121          * @param integer $expandAll
122          * @return array
123          */
124         public function toArray(
125                         array $expand = array(), array $intersect = array(),
126                         $showIdentifiers = false, $expandAll = 0
127                         )
128         {
129                 $intersect = array_flip($intersect);
130                 $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
131                 $includeAll = empty($intersect);
132                 $data = array();
133                 ($includeAll || isset($intersect['id']))
134                         && $data['id'] = $this->id;
135                 ($includeAll || isset($intersect['timeSlot']))
136                         && $data['timeSlot'] = $this->timeSlot;
137         ($includeAll || isset($intersect['timeSlotDisplayName']))
138         && $data['timeSlotDisplayName'] = $this->timeSlotDisplayName;
139
140         ($includeAll || isset($intersect['created']))
141         && $data['created'] = !is_null($this->created)
142             ? $this->created->format($dateTimeFormat)
143             : null;
144         ($includeAll || isset($intersect['updated']))
145         && $data['updated'] = !is_null($this->updated)
146             ? $this->updated->format($dateTimeFormat)
147             : null;
148         ($includeAll || isset($intersect['archived']))
149         && $data['archived'] = $this->archived;
150         return $data;
151         }
152
153
154
155         /**
156          * Populate from an array.
157          * @param array $data
158          */
159         public function fromArray($data = array())
160         {
161                 isset($data['id'])
162                         && $this->id = $data['id'];
163                 isset($data['timeSlot'])
164                         && $this->timeSlot = $data['timeSlot'];
165                 isset($data['timeSlotDisplayName'])
166                         && $this->timeSlotDisplayName = $data['timeSlotDisplayName'];
167         }
168
169
170
171 }
172