forked from FriendsOfSymfony/FOSMessageBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add events when messages are sent, read or deleted
- Loading branch information
Showing
9 changed files
with
205 additions
and
4 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
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,34 @@ | ||
<?php | ||
|
||
namespace Ornicar\MessageBundle\Event; | ||
|
||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Ornicar\MessageBundle\Model\MessageInterface; | ||
use Ornicar\MessageBundle\Model\ThreadInterface; | ||
|
||
class MessageEvent extends ThreadEvent | ||
{ | ||
/** | ||
* The message | ||
* @var MessageInterface | ||
*/ | ||
private $message; | ||
|
||
public function __construct(MessageInterface $message) | ||
{ | ||
parent::__construct($message->getThread()); | ||
|
||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* Returns the message | ||
* | ||
* @return MessageInterface | ||
*/ | ||
public function getMessage() | ||
{ | ||
return $this->message; | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
|
||
namespace Ornicar\MessageBundle\Event; | ||
|
||
/** | ||
* Declares all events thrown in the MessageBundle | ||
*/ | ||
final class OrnicarMessageEvents | ||
{ | ||
/** | ||
* The POST_SEND event occurs after a message has been sent | ||
* The event is an instance of Ornicar\MessageBundle\Event\MessageEvent | ||
* | ||
* @var string | ||
*/ | ||
const POST_SEND = 'ornicar_message.post_send'; | ||
|
||
/** | ||
* The POST_DELETE event occurs after a thread has been marked as deleted | ||
* The event is an instance of Ornicar\MessageBundle\Event\ThreadEvent | ||
* | ||
* @var string | ||
*/ | ||
const POST_DELETE = 'ornicar_message.post_delete'; | ||
|
||
/** | ||
* The POST_UNDELETE event occurs after a thread has been marked as undeleted | ||
* The event is an instance of Ornicar\MessageBundle\Event\ThreadEvent | ||
* | ||
* @var string | ||
*/ | ||
const POST_UNDELETE = 'ornicar_message.post_undelete'; | ||
|
||
/** | ||
* The POST_READ event occurs after a thread has been marked as read | ||
* The event is an instance of Ornicar\MessageBundle\Event\ReadableEvent | ||
* | ||
* @var string | ||
*/ | ||
const POST_READ = 'ornicar_message.post_read'; | ||
|
||
/** | ||
* The POST_UNREAD event occurs after a thread has been unread | ||
* The event is an instance of Ornicar\MessageBundle\Event\ReadableEvent | ||
* | ||
* @var string | ||
*/ | ||
const POST_UNREAD = 'ornicar_message.post_unread'; | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Ornicar\MessageBundle\Event; | ||
|
||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Ornicar\MessageBundle\Model\ReadableInterface; | ||
|
||
class ReadableEvent extends Event | ||
{ | ||
/** | ||
* The readable | ||
* @var ReadableInterface | ||
*/ | ||
private $readable; | ||
|
||
public function __construct(ReadableInterface $readable) | ||
{ | ||
$this->readable = $readable; | ||
} | ||
|
||
/** | ||
* Returns the readable | ||
* | ||
* @return ReadableInterface | ||
*/ | ||
public function getReadable() | ||
{ | ||
return $this->readable; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Ornicar\MessageBundle\Event; | ||
|
||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Ornicar\MessageBundle\Model\ThreadInterface; | ||
|
||
class ThreadEvent extends Event | ||
{ | ||
/** | ||
* The thread | ||
* @var ThreadInterface | ||
*/ | ||
private $thread; | ||
|
||
public function __construct(ThreadInterface $thread) | ||
{ | ||
$this->thread = $thread; | ||
} | ||
|
||
/** | ||
* Returns the thread | ||
* | ||
* @return ThreadInterface | ||
*/ | ||
public function getThread() | ||
{ | ||
return $this->thread; | ||
} | ||
} |
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
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