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