2 namespace Location\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * A country, in such a small file, imagine that.
11 * @ORM\Table(name="lib_country", uniqueConstraints={@ORM\UniqueConstraint(name="unique_country", columns={"name"})})
17 * Can archive records.
21 * Pull Synchronization Strategy for this table.
23 const PULL_SYNCH_STRATEGY = 'Build';
25 * Push Synchronization Strategy for this table.
27 const PUSH_SYNCH_STRATEGY = 'Build';
32 * @ORM\Column(type="integer");
33 * @ORM\GeneratedValue(strategy="AUTO")
38 * @ORM\Column(type="string", length=50, unique=true)
43 * @ORM\Column(type="string", length=2, nullable=true, name="country_code_iso")
48 * @ORM\Column(type="string", length=2, nullable=true, name="country_code_fips")
53 * @ORM\Column(type="smallint", nullable=true, name="dialing_code")
55 protected $dailingCode;
58 * @ORM\Column(type="boolean");
60 protected $archived = false;
63 * @ORM\OneToMany(targetEntity="Region", mappedBy="country", fetch="EXTRA_LAZY")
69 * Initialize collections.
71 public function __construct()
73 $this->regions = new \Doctrine\Common\Collections\ArrayCollection();
77 * Add a new Region to this Country.
78 * @param Region $region
79 * @return \Location\Entity\Country
81 public function addRegion(Region $region)
83 $this->regions[] = $region;
88 * Magic getter to expose protected properties.
89 * @param string $property
92 public function __get($property)
94 return $this->$property;
98 * Magic setter to save protected properties.
99 * @param string $property
100 * @param mixed $value
102 public function __set($property, $value)
104 $this->$property = $value;
108 * Convert the object to an array.
109 * @param array $expand
110 * @param array $intersect
113 public function toArray(array $expand = array(), array $intersect = array())
115 $includeAll = empty($intersect);
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;
131 * Convert the object to an array for synchronization.
134 public function toSynchArray()
138 'name' => $this->name
143 * Populate from an array.
146 public function fromArray($data = array())
149 && $this->id = $data['id'];
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'];