From 56af6f0db3c1707e3621535bbc591f8bd606d3fd Mon Sep 17 00:00:00 2001
From: Alexey Skobkin <x@skobkin.ru>
Date: Mon, 23 Mar 2015 18:39:00 +0300
Subject: [PATCH] SubscriptionEvent entity added.

---
 .../Entity/SubscriptionEvent.php              | 158 ++++++++++++++++++
 .../Bundle/PointToolsBundle/Entity/User.php   |  81 +++++++++
 2 files changed, 239 insertions(+)
 create mode 100644 src/Skobkin/Bundle/PointToolsBundle/Entity/SubscriptionEvent.php

diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/SubscriptionEvent.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/SubscriptionEvent.php
new file mode 100644
index 0000000..d72433a
--- /dev/null
+++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/SubscriptionEvent.php
@@ -0,0 +1,158 @@
+<?php
+
+namespace Skobkin\Bundle\PointToolsBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * SubscriptionEvent
+ *
+ * @ORM\Table(name="subscriptions_events")
+ * @ORM\Entity
+ */
+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;
+    
+    /**
+     * @var User Blog subscriber
+     * 
+     * @ORM\ManyToOne(targetEntity="User", inversedBy="newSubscriptionEvents")
+     * @ORM\JoinColumn(name="subscriber_id", nullable=false)
+     */
+    private $subscriber;
+    
+    /**
+     * @var User Blog author
+     * 
+     * @ORM\ManyToOne(targetEntity="User", inversedBy="newSubscriberEvents")
+     * @ORM\JoinColumn(name="author_id", nullable=false)
+     */
+    private $author;
+    
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="date", type="datetime", nullable=false)
+     */
+    private $dateTime;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="action", type="string", length=12, nullable=false)
+     */
+    private $action;
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set dateTime
+     *
+     * @param \DateTime $dateTime
+     * @return SubscriptionEvent
+     */
+    public function setDateTime($dateTime)
+    {
+        $this->dateTime = $dateTime;
+
+        return $this;
+    }
+
+    /**
+     * Get dateTime
+     *
+     * @return \DateTime 
+     */
+    public function getDateTime()
+    {
+        return $this->dateTime;
+    }
+
+    /**
+     * 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;
+    }
+}
diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/User.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/User.php
index d4edc04..6f9ffb8 100644
--- a/src/Skobkin/Bundle/PointToolsBundle/Entity/User.php
+++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/User.php
@@ -44,12 +44,27 @@ class User
      * @ORM\OneToMany(targetEntity="Subscription", mappedBy="subscriber")
      */
     private $subscriptions;
+    
+    /**
+     * @var ArrayCollection
+     * 
+     * @ORM\OneToMany(targetEntity="SubscriptionEvent", mappedBy="subscriber")
+     */
+    private $newSubscriptionEvents;
+    
+    /**
+     * @var ArrayCollection
+     * @ORM\OneToMany(targetEntity="SubscriptionEvent", mappedBy="author")
+     */
+    private $newSubscriberEvents;
 
 
     public function __construct()
     {
         $this->subscribers = new ArrayCollection();
         $this->subscriptions = new ArrayCollection();
+        $this->newSubscriberEvents = new ArrayCollection();
+        $this->newSubscriptionEvents = new ArrayCollection();
     }
 
     /**
@@ -150,4 +165,70 @@ class User
     {
         return $this->subscriptions;
     }
+
+    /**
+     * Add newSubscriptionEvents
+     *
+     * @param SubscriptionEvent $newSubscriptionEvents
+     * @return User
+     */
+    public function addNewSubscriptionEvent(SubscriptionEvent $newSubscriptionEvents)
+    {
+        $this->newSubscriptionEvents[] = $newSubscriptionEvents;
+
+        return $this;
+    }
+
+    /**
+     * Remove newSubscriptionEvents
+     *
+     * @param SubscriptionEvent $newSubscriptionEvents
+     */
+    public function removeNewSubscriptionEvent(SubscriptionEvent $newSubscriptionEvents)
+    {
+        $this->newSubscriptionEvents->removeElement($newSubscriptionEvents);
+    }
+
+    /**
+     * Get newSubscriptionEvents
+     *
+     * @return ArrayCollection
+     */
+    public function getNewSubscriptionEvents()
+    {
+        return $this->newSubscriptionEvents;
+    }
+
+    /**
+     * Add newSubscriberEvents
+     *
+     * @param SubscriptionEvent $newSubscriberEvents
+     * @return User
+     */
+    public function addNewSubscriberEvent(SubscriptionEvent $newSubscriberEvents)
+    {
+        $this->newSubscriberEvents[] = $newSubscriberEvents;
+
+        return $this;
+    }
+
+    /**
+     * Remove newSubscriberEvents
+     *
+     * @param SubscriptionEvent $newSubscriberEvents
+     */
+    public function removeNewSubscriberEvent(SubscriptionEvent $newSubscriberEvents)
+    {
+        $this->newSubscriberEvents->removeElement($newSubscriberEvents);
+    }
+
+    /**
+     * Get newSubscriberEvents
+     *
+     * @return ArrayCollection 
+     */
+    public function getNewSubscriberEvents()
+    {
+        return $this->newSubscriberEvents;
+    }
 }