initial commit
[namibia] / module / Config / src / Config / Entity / RegionalManager.php
1 <?php
2
3 namespace Config\Entity;
4
5 use Doctrine\ORM\Mapping as ORM;
6
7 /**
8  * A Regional Manager.
9  *
10  * @ORM\Entity
11  * @ORM\HasLifecycleCallbacks
12  * @ORM\Table(name="regional_manager", uniqueConstraints={@ORM\UniqueConstraint(name="unique_email", columns={"email"})})
13  */
14 class RegionalManager
15 {
16
17   /**
18    * Can archive records.
19    */
20   const ARCHIVE = true;
21
22   /**
23    * Pull Synchronization Strategy for this table.
24    */
25   const PULL_SYNCH_STRATEGY = false;
26
27   /**
28    * Push Synchronization Strategy for this table.
29    */
30   const PUSH_SYNCH_STRATEGY = false;
31
32   /**
33    * Post update action must be called after existing entity is flushed to database.
34    */
35   const HAVE_POST_UPDATE = true;
36
37   /**
38    * @ORM\Id
39    * @ORM\Column(type="integer");
40    * @ORM\GeneratedValue(strategy="AUTO")
41    */
42   protected $id;
43   
44   /**
45          * @ORM\ManyToOne(targetEntity="\Company\Entity\Group")
46          * @ORM\JoinColumn(name="company_group_id")
47          **/
48         protected $group;
49
50   /**
51    * @ORM\Column(type="string", length=255, unique=true)
52    */
53   protected $email;
54
55   /**
56    * @ORM\Column(type="string", length=100, name="first_name")
57    */
58   protected $firstName;
59
60   /**
61    * @ORM\Column(type="string", length=100, name="family_name")
62    */
63   protected $familyName;
64
65   /**
66    * @ORM\Column(type="string", length=20)
67    */
68   protected $mobile;
69
70   /**
71    * @ORM\Column(type="datetime");
72    */
73   protected $created;
74
75   /**
76    * @ORM\Column(type="datetime", nullable=true);
77    */
78   protected $updated;
79
80   /**
81    * @ORM\Column(type="boolean");
82    */
83   protected $archived = false;
84
85   /**
86    * Initialize collections.
87    */
88   public function __construct()
89   {
90     
91   }
92
93   public function getId()
94   {
95     return $this->id;
96   }
97
98   /**
99    * Magic getter to expose protected properties.
100    *
101    * @param string $property
102    * @return mixed
103    */
104   public function __get($property)
105   {
106     return $this->$property;
107   }
108
109   /**
110    * Magic setter to save protected properties.
111    * @param string $property
112    * @param mixed $value
113    */
114   public function __set($property, $value)
115   {
116     $this->$property = $value;
117   }
118
119   /**
120    * @ORM\PrePersist
121    */
122   public function setCreateTime()
123   {
124     $this->created = new \DateTime("now");
125   }
126
127   /**
128    * @ORM\PreUpdate
129    */
130   public function setUpdateTime()
131   {
132     $this->updated = new \DateTime("now");
133   }
134
135   public function postUpdate()
136   {
137     
138   }
139
140   /**
141    * Convert the object to an array.
142    * @param array $expand
143    * @param array $intersect
144    * @param boolean $showIdentifiers
145    * @param integer $expandAll
146    * @return array
147    */
148   public function toArray(
149   array $expand = array(), array $intersect = array(), $showIdentifiers = false,
150     $expandAll = 0
151   )
152   {
153     $dateTimeFormat = \Utility\Registry::getConfigParam('DateTimeFormat');
154     $includeAll = empty($intersect);
155     $data = array();
156     ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id;
157     ($includeAll || isset($intersect['group']))
158                         && $data['group'] = (in_array('group', $expand) || $expandAll || $showIdentifiers)
159                                                                         && !is_null($this->group)
160                                 ? (!$showIdentifiers || in_array('group', $expand) ? $this->group->toArray(
161                                                 $expand, $intersect, $showIdentifiers, ($expandAll - 1)
162                                                 ) : $this->group->id)
163                                 : null;
164     ($includeAll || isset($intersect['email'])) && $data['email'] = $this->email;
165     ($includeAll || isset($intersect['firstName'])) && $data['firstName'] = $this->firstName;
166     ($includeAll || isset($intersect['familyName'])) && $data['familyName'] = $this->familyName;
167     ($includeAll || isset($intersect['fullName'])) && $data['fullName'] = $this->firstName . ' ' . $this->familyName;
168     ($includeAll || isset($intersect['mobile'])) && $data['mobile'] = $this->mobile;
169     ($includeAll || isset($intersect['created'])) && $data['created'] = !is_null($this->created) ? $this->created->format($dateTimeFormat) : null;
170     ($includeAll || isset($intersect['updated'])) && $data['updated'] = !is_null($this->updated) ? $this->updated->format($dateTimeFormat) : null;
171     return $data;
172   }
173
174   /**
175    * Populate from an array.
176    * @param array $data
177    */
178   public function fromArray($data = array())
179   {
180     isset($data['id']) && $this->id = $data['id'];
181     isset($data['group']) && $this->group = $data['group'];
182     isset($data['email']) && $this->email = $data['email'];
183     isset($data['firstName']) && $this->firstName = $data['firstName'];
184     isset($data['familyName']) && $this->familyName = $data['familyName'];
185     isset($data['mobile']) && $this->mobile = $data['mobile'];
186   }
187
188 }