text changes to registration mail content
[namibia] / module / Location / src / Location / Entity / Country.php
1 <?php
2 namespace Location\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * A country, in such a small file, imagine that.
10  * @ORM\Entity
11  * @ORM\Table(name="lib_country", uniqueConstraints={@ORM\UniqueConstraint(name="unique_country", columns={"name"})})
12  */
13 class Country
14 {
15
16         /**
17          * Can archive records.
18          */
19         const ARCHIVE = true;
20         /**
21          * Pull Synchronization Strategy for this table.
22          */
23         const PULL_SYNCH_STRATEGY = 'Build';
24         /**
25          * Push Synchronization Strategy for this table.
26          */
27         const PUSH_SYNCH_STRATEGY = 'Build';
28
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", length=50, unique=true)
39          */
40         protected $name;
41
42         /**
43          * @ORM\Column(type="string", length=2, nullable=true, name="country_code_iso")
44          */
45         protected $isoCode;
46
47         /**
48          * @ORM\Column(type="string", length=2, nullable=true, name="country_code_fips")
49          */
50         protected $fipsCode;
51
52         /**
53          * @ORM\Column(type="smallint", nullable=true, name="dialing_code")
54          */
55         protected $dailingCode;
56
57         /**
58          * @ORM\Column(type="boolean");
59          */
60         protected $archived = false;
61
62         /**
63          * @ORM\OneToMany(targetEntity="Region", mappedBy="country", fetch="EXTRA_LAZY")
64          **/
65         private $regions;
66
67
68         /**
69          * Initialize collections.
70          */
71         public function __construct()
72         {
73                 $this->regions = new \Doctrine\Common\Collections\ArrayCollection();
74         }
75
76         /**
77          * Add a new Region to this Country.
78          * @param Region $region
79          * @return \Location\Entity\Country
80          */
81         public function addRegion(Region $region)
82         {
83                 $this->regions[] = $region;
84                 return $this;
85         }
86
87         /**
88          * Magic getter to expose protected properties.
89          * @param string $property
90          * @return mixed
91          */
92         public function __get($property)
93         {
94                 return $this->$property;
95         }
96
97         /**
98          * Magic setter to save protected properties.
99          * @param string $property
100          * @param mixed $value
101          */
102         public function __set($property, $value)
103         {
104                 $this->$property = $value;
105         }
106
107         /**
108          * Convert the object to an array.
109          * @param array $expand
110          * @param array $intersect
111          * @return array
112          */
113         public function toArray(array $expand = array(), array $intersect = array())
114         {
115                 $includeAll = empty($intersect);
116                 $data = array();
117                 ($includeAll || isset($intersect['id']))
118                         && $data['id'] = $this->id;
119                 ($includeAll || isset($intersect['name']))
120                         && $data['name'] = $this->name;
121                 ($includeAll || isset($intersect['isoCode']))
122                         && $data['isoCode'] = $this->isoCode;
123                 ($includeAll || isset($intersect['fipsCode']))
124                         && $data['fipsCode'] = $this->fipsCode;
125                 ($includeAll || isset($intersect['dailingCode']))
126                         && $data['dailingCode'] = $this->dailingCode;
127                 return $data;
128         }
129
130         /**
131          * Convert the object to an array for synchronization.
132          * @return array
133          */
134         public function toSynchArray()
135         {
136                 return array(
137                                 'id'   => $this->id,
138                                 'name' => $this->name
139                 );
140         }
141
142         /**
143          * Populate from an array.
144          * @param array $data
145          */
146         public function fromArray($data = array())
147         {
148                 isset($data['id'])
149                         && $this->id = $data['id'];
150                 isset($data['name'])
151                         && $this->name  = $data['name'];
152                 isset($data['isoCode'])
153                         && $this->isoCode  = $data['isoCode'];
154                 isset($data['fipsCode'])
155                         && $this->fipsCode  = $data['fipsCode'];
156                 isset($data['dailingCode'])
157                         && $this->dailingCode  = $data['dailingCode'];
158         }
159
160 }