Implemented rest endpoint to return shortcode visits

This commit is contained in:
Alejandro Celaya
2016-06-12 21:51:06 +02:00
parent ab8ccd7df1
commit 305df3a95b
8 changed files with 158 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Entity
* @ORM\Table(name="visits")
*/
class Visit extends AbstractEntity
class Visit extends AbstractEntity implements \JsonSerializable
{
/**
* @var string
@@ -134,4 +134,21 @@ class Visit extends AbstractEntity
$this->userAgent = $userAgent;
return $this;
}
/**
* 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 <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
public function jsonSerialize()
{
return [
'referer' => $this->referer,
'date' => isset($this->date) ? $this->date->format(\DateTime::ISO8601) : null,
'remoteAddr' => $this->remoteAddr,
'userAgent' => $this->userAgent,
];
}
}