point-tools/src/Skobkin/Bundle/PointToolsBundle/Entity/SubscriptionEvent.php

175 lines
3.2 KiB
PHP
Raw Normal View History

2015-03-23 15:39:00 +00:00
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SubscriptionEvent
*
2015-10-01 18:45:16 +00:00
* @ORM\Table(name="subscriptions.log", schema="subscriptions", indexes={
2015-05-28 17:36:52 +00:00
* @ORM\Index(name="author_idx", columns={"author_id"}),
* @ORM\Index(name="subscriber_idx", columns={"subscriber_id"}),
* @ORM\Index(name="date_idx", columns={"date"})
* })
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository")
* @ORM\HasLifecycleCallbacks
2015-03-23 15:39:00 +00:00
*/
class SubscriptionEvent
{
const ACTION_SUBSCRIBE = 'subscribe';
const ACTION_UNSUBSCRIBE = 'unsubscribe';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
2015-05-28 17:36:52 +00:00
2015-03-23 15:39:00 +00:00
/**
* @var User Blog author
2015-05-28 17:36:52 +00:00
*
2015-03-23 15:39:00 +00:00
* @ORM\ManyToOne(targetEntity="User", inversedBy="newSubscriberEvents")
* @ORM\JoinColumn(name="author_id", nullable=false)
*/
private $author;
2015-05-28 17:36:52 +00:00
/**
* @var User Blog subscriber
*
* @ORM\ManyToOne(targetEntity="User", inversedBy="newSubscriptionEvents")
* @ORM\JoinColumn(name="subscriber_id", nullable=false)
*/
private $subscriber;
2015-03-23 15:39:00 +00:00
/**
* @var \DateTime
*
* @ORM\Column(name="date", type="datetime", nullable=false)
*/
2015-05-28 17:36:52 +00:00
private $date;
2015-03-23 15:39:00 +00:00
/**
* @var string
*
* @ORM\Column(name="action", type="string", length=12, nullable=false)
*/
private $action;
/**
* @ORM\PrePersist
*/
public function onCreate()
{
if (!$this->date) {
$this->date = new \DateTime();
}
}
2015-03-23 15:39:00 +00:00
/**
* Get id
*
2015-05-28 17:36:52 +00:00
* @return integer
2015-03-23 15:39:00 +00:00
*/
public function getId()
{
return $this->id;
}
/**
2015-05-28 17:36:52 +00:00
* Set date
2015-03-23 15:39:00 +00:00
*
2015-05-28 17:36:52 +00:00
* @param \DateTime $date
2015-03-23 15:39:00 +00:00
* @return SubscriptionEvent
*/
2015-05-28 17:36:52 +00:00
public function setDate($date)
2015-03-23 15:39:00 +00:00
{
2015-05-28 17:36:52 +00:00
$this->date = $date;
2015-03-23 15:39:00 +00:00
return $this;
}
/**
2015-05-28 17:36:52 +00:00
* Get date
2015-03-23 15:39:00 +00:00
*
* @return \DateTime
*/
2015-05-28 17:36:52 +00:00
public function getDate()
2015-03-23 15:39:00 +00:00
{
2015-05-28 17:36:52 +00:00
return $this->date;
2015-03-23 15:39:00 +00:00
}
/**
* Set subscriber
*
* @param User $subscriber
* @return SubscriptionEvent
*/
public function setSubscriber(User $subscriber)
{
$this->subscriber = $subscriber;
return $this;
}
/**
* Get subscriber
*
* @return User
*/
public function getSubscriber()
{
return $this->subscriber;
}
/**
* Set author
*
* @param User $author
* @return SubscriptionEvent
*/
public function setAuthor(User $author)
{
$this->author = $author;
return $this;
}
/**
* Get author
*
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* Set action
*
* @param string $action
* @return SubscriptionEvent
*/
public function setAction($action)
{
$this->action = $action;
return $this;
}
/**
* Get action
*
* @return string
*/
public function getAction()
{
return $this->action;
}
}