-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,653 additions
and
864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Mgilet\NotificationBundle\Annotation; | ||
|
||
|
||
use Doctrine\Common\Annotations\Annotation; | ||
|
||
/** | ||
* Class Notifiable | ||
* @package Mgilet\NotificationBundle\Annotation | ||
* | ||
* @Annotation | ||
* @Annotation\Target("CLASS") | ||
*/ | ||
class Notifiable | ||
{ | ||
/** | ||
* @Required() | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param mixed $name | ||
* | ||
* @return Notifiable | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?php | ||
|
||
namespace Mgilet\NotificationBundle\Entity; | ||
|
||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | ||
|
||
/** | ||
* Class NotifiableEntity | ||
* @package Mgilet\NotificationBundle\Entity | ||
* | ||
* @ORM\Table(name="notifiable") | ||
* @ORM\Entity(repositoryClass="Mgilet\NotificationBundle\Entity\Repository\NotifiableRepository") | ||
* @UniqueEntity(fields={"identifier", "class"}) | ||
*/ | ||
class NotifiableEntity | ||
{ | ||
/** | ||
* @var string $id | ||
* | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
* @ORM\Id | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var string $identifier | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
protected $identifier; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
protected $class; | ||
|
||
/** | ||
* @var NotifiableNotification[]|ArrayCollection | ||
* @ORM\OneToMany(targetEntity="Mgilet\NotificationBundle\Entity\NotifiableNotification", mappedBy="notifiableEntity",cascade={"persist"}) | ||
*/ | ||
protected $notifiableNotifications; | ||
|
||
/** | ||
* AbstractNotifiableEntity constructor. | ||
* | ||
* @param $identifier | ||
* @param $class | ||
*/ | ||
public function __construct($identifier, $class) | ||
{ | ||
$this->identifier = $identifier; | ||
$this->class = $class; | ||
$this->notifiableNotifications = new ArrayCollection(); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return $this->identifier; | ||
} | ||
|
||
/** | ||
* @param string $identifier | ||
* | ||
* @return NotifiableEntity | ||
*/ | ||
public function setIdentifier($identifier) | ||
{ | ||
$this->identifier = $identifier; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getClass() | ||
{ | ||
return $this->class; | ||
} | ||
|
||
/** | ||
* @param string $class | ||
* | ||
* @return NotifiableEntity | ||
*/ | ||
public function setClass($class) | ||
{ | ||
$this->class = $class; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return ArrayCollection|NotifiableNotification[] | ||
*/ | ||
public function getNotifiableNotifications() | ||
{ | ||
return $this->notifiableNotifications; | ||
} | ||
|
||
/** | ||
* @param NotifiableNotification $notifiableNotification | ||
* | ||
* @return $this | ||
*/ | ||
public function addNotifiableNotification(NotifiableNotification $notifiableNotification) | ||
{ | ||
if (!$this->notifiableNotifications->contains($notifiableNotification)) { | ||
$this->notifiableNotifications[] = $notifiableNotification; | ||
$notifiableNotification->setNotifiableEntity($this); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param NotifiableNotification $notifiableNotification | ||
* | ||
* @return $this | ||
*/ | ||
public function removeNotifiableNotification(NotifiableNotification $notifiableNotification) | ||
{ | ||
if ($this->notifiableNotifications->contains($notifiableNotification)) { | ||
$this->notifiableNotifications->removeElement($notifiableNotification); | ||
$notifiableNotification->setNotifiableEntity(null); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.