towns = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Add a new Region to this Country. * @param Town $town * @return \Location\Entity\Region */ public function addTown(Town $town) { $this->towns[] = $town; return $this; } /** * Magic getter to expose protected properties. * @param string $property * @return mixed */ public function __get($property) { return $this->$property; } /** * Magic setter to save protected properties. * @param string $property * @param mixed $value */ public function __set($property, $value) { $this->$property = $value; } /** * Convert the object to an array. * @param array $expand * @param array $intersect * @return array */ public function toArray(array $expand = array(), array $intersect = array()) { $includeAll = empty($intersect); $data = array(); ($includeAll || isset($intersect['id'])) && $data['id'] = $this->id; ($includeAll || isset($intersect['country'])) && in_array('country', $expand) && $data['country'] = $this->country->toArray($expand, $intersect); ($includeAll || isset($intersect['name'])) && $data['name'] = $this->name; ($includeAll || isset($intersect['isoCode'])) && $data['isoCode'] = $this->isoCode; ($includeAll || isset($intersect['fipsCode'])) && $data['fipsCode'] = $this->fipsCode; return $data; } /** * Convert the object to an array for synchronization. * @return array */ public function toSynchArray() { return array( 'id' => $this->id, 'country' => $this->country->id, 'name' => $this->name ); } /** * Populate from an array. * @param array $data */ public function fromArray($data = array()) { isset($data['id']) && $this->id = $data['id']; isset($data['country']) && $this->country = $data['country']; isset($data['name']) && $this->name = $data['name']; isset($data['isoCode']) && $this->isoCode = $data['isoCode']; isset($data['fipsCode']) && $this->fipsCode = $data['fipsCode']; } }