From c290bed3549f550bbe683739119f34270e6b45da Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 20 Jul 2016 09:35:46 +0200 Subject: [PATCH] Created VisitLocation entity --- module/Core/src/Entity/Visit.php | 25 +++ module/Core/src/Entity/VisitLocation.php | 267 +++++++++++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 module/Core/src/Entity/VisitLocation.php diff --git a/module/Core/src/Entity/Visit.php b/module/Core/src/Entity/Visit.php index 04cfbe68..0775804c 100644 --- a/module/Core/src/Entity/Visit.php +++ b/module/Core/src/Entity/Visit.php @@ -40,6 +40,12 @@ class Visit extends AbstractEntity implements \JsonSerializable * @ORM\JoinColumn(name="short_url_id", referencedColumnName="id") */ protected $shortUrl; + /** + * @var VisitLocation + * @ORM\ManyToOne(targetEntity=VisitLocation::class) + * @ORM\JoinColumn(name="visit_location_id", referencedColumnName="id", nullable=true) + */ + protected $visitLocation; public function __construct() { @@ -136,6 +142,24 @@ class Visit extends AbstractEntity implements \JsonSerializable return $this; } + /** + * @return VisitLocation + */ + public function getVisitLocation() + { + return $this->visitLocation; + } + + /** + * @param VisitLocation $visitLocation + * @return $this + */ + public function setVisitLocation($visitLocation) + { + $this->visitLocation = $visitLocation; + return $this; + } + /** * Specify data which should be serialized to JSON * @link http://php.net/manual/en/jsonserializable.jsonserialize.php @@ -150,6 +174,7 @@ class Visit extends AbstractEntity implements \JsonSerializable 'date' => isset($this->date) ? $this->date->format(\DateTime::ISO8601) : null, 'remoteAddr' => $this->remoteAddr, 'userAgent' => $this->userAgent, + 'visitLocation' => $this->visitLocation, ]; } } diff --git a/module/Core/src/Entity/VisitLocation.php b/module/Core/src/Entity/VisitLocation.php new file mode 100644 index 00000000..0ca3685c --- /dev/null +++ b/module/Core/src/Entity/VisitLocation.php @@ -0,0 +1,267 @@ +countryCode; + } + + /** + * @param string $countryCode + * @return $this + */ + public function setCountryCode($countryCode) + { + $this->countryCode = $countryCode; + return $this; + } + + /** + * @return string + */ + public function getCountryName() + { + return $this->countryName; + } + + /** + * @param string $countryName + * @return $this + */ + public function setCountryName($countryName) + { + $this->countryName = $countryName; + return $this; + } + + /** + * @return string + */ + public function getRegionName() + { + return $this->regionName; + } + + /** + * @param string $regionName + * @return $this + */ + public function setRegionName($regionName) + { + $this->regionName = $regionName; + return $this; + } + + /** + * @return string + */ + public function getCityName() + { + return $this->cityName; + } + + /** + * @param string $cityName + * @return $this + */ + public function setCityName($cityName) + { + $this->cityName = $cityName; + return $this; + } + + /** + * @return string + */ + public function getLatitude() + { + return $this->latitude; + } + + /** + * @param string $latitude + * @return $this + */ + public function setLatitude($latitude) + { + $this->latitude = $latitude; + return $this; + } + + /** + * @return string + */ + public function getLongitude() + { + return $this->longitude; + } + + /** + * @param string $longitude + * @return $this + */ + public function setLongitude($longitude) + { + $this->longitude = $longitude; + return $this; + } + + /** + * @return string + */ + public function getAreaCode() + { + return $this->areaCode; + } + + /** + * @param string $areaCode + * @return $this + */ + public function setAreaCode($areaCode) + { + $this->areaCode = $areaCode; + return $this; + } + + /** + * @return string + */ + public function getTimezone() + { + return $this->timezone; + } + + /** + * @param string $timezone + * @return $this + */ + public function setTimezone($timezone) + { + $this->timezone = $timezone; + return $this; + } + + /** + * Exchange internal values from provided array + * + * @param array $array + * @return void + */ + public function exchangeArray(array $array) + { + if (array_key_exists('countryCode', $array)) { + $this->setCountryCode($array['countryCode']); + } + if (array_key_exists('countryName', $array)) { + $this->setCountryName($array['countryName']); + } + if (array_key_exists('regionName', $array)) { + $this->setRegionName($array['regionName']); + } + if (array_key_exists('cityName', $array)) { + $this->setCityName($array['cityName']); + } + if (array_key_exists('latitude', $array)) { + $this->setLatitude($array['latitude']); + } + if (array_key_exists('longitude', $array)) { + $this->setLongitude($array['longitude']); + } + if (array_key_exists('areaCode', $array)) { + $this->setAreaCode($array['areaCode']); + } + if (array_key_exists('timezone', $array)) { + $this->setTimezone($array['timezone']); + } + } + + /** + * Return an array representation of the object + * + * @return array + */ + public function getArrayCopy() + { + return [ + 'countryCode' => $this->countryCode, + 'countryName' => $this->countryName, + 'regionName' => $this->regionName, + 'cityName' => $this->cityName, + 'latitude' => $this->latitude, + 'longitude' => $this->longitude, + 'areaCode' => $this->areaCode, + 'timezone' => $this->timezone, + ]; + } + + /** + * Specify data which should be serialized to JSON + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php + * @return mixed data which can be serialized by json_encode, + * which is a value of any type other than a resource. + * @since 5.4.0 + */ + public function jsonSerialize() + { + return $this->getArrayCopy(); + } +}