Created VisitsTracker service to track visits to shortcodes

This commit is contained in:
Alejandro Celaya
2016-04-30 19:18:42 +02:00
parent b2615d0de6
commit 4ae08c02ec
4 changed files with 127 additions and 71 deletions

View File

@@ -15,7 +15,7 @@ class Visit extends AbstractEntity
{
/**
* @var string
* @ORM\Column(type="string", length=256)
* @ORM\Column(type="string", length=256, nullable=true)
*/
protected $referer;
/**
@@ -25,19 +25,14 @@ class Visit extends AbstractEntity
protected $date;
/**
* @var string
* @ORM\Column(type="string", length=256)
* @ORM\Column(type="string", length=256, name="remote_addr", nullable=true)
*/
protected $country;
protected $remoteAddr;
/**
* @var string
* @ORM\Column(type="string", length=256)
* @ORM\Column(type="string", length=256, name="user_agent", nullable=true)
*/
protected $platform;
/**
* @var string
* @ORM\Column(type="string", length=256)
*/
protected $browser;
protected $userAgent;
/**
* @var ShortUrl
* @ORM\ManyToOne(targetEntity=ShortUrl::class)
@@ -45,6 +40,11 @@ class Visit extends AbstractEntity
*/
protected $shortUrl;
public function __construct()
{
$this->date = new \DateTime();
}
/**
* @return string
*/
@@ -81,60 +81,6 @@ class Visit extends AbstractEntity
return $this;
}
/**
* @return string
*/
public function getCountry()
{
return $this->country;
}
/**
* @param string $country
* @return $this
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* @return string
*/
public function getPlatform()
{
return $this->platform;
}
/**
* @param string $platform
* @return $this
*/
public function setPlatform($platform)
{
$this->platform = $platform;
return $this;
}
/**
* @return string
*/
public function getBrowser()
{
return $this->browser;
}
/**
* @param string $browser
* @return $this
*/
public function setBrowser($browser)
{
$this->browser = $browser;
return $this;
}
/**
* @return ShortUrl
*/
@@ -152,4 +98,40 @@ class Visit extends AbstractEntity
$this->shortUrl = $shortUrl;
return $this;
}
/**
* @return string
*/
public function getRemoteAddr()
{
return $this->remoteAddr;
}
/**
* @param string $remoteAddr
* @return $this
*/
public function setRemoteAddr($remoteAddr)
{
$this->remoteAddr = $remoteAddr;
return $this;
}
/**
* @return string
*/
public function getUserAgent()
{
return $this->userAgent;
}
/**
* @param string $userAgent
* @return $this
*/
public function setUserAgent($userAgent)
{
$this->userAgent = $userAgent;
return $this;
}
}