-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of event subscribers that resolve services too early
Refs flarum/core#1578.
- Loading branch information
1 parent
16a441c
commit 7ac73b8
Showing
8 changed files
with
117 additions
and
144 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
41 changes: 41 additions & 0 deletions
41
src/Listener/DeleteNotificationWhenPostIsHiddenOrDeleted.php
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,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* (c) Toby Zerner <toby.zerner@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Subscriptions\Listener; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Deleted; | ||
use Flarum\Post\Event\Hidden; | ||
use Flarum\Subscriptions\Notification\NewPostBlueprint; | ||
|
||
class DeleteNotificationWhenPostIsHiddenOrDeleted | ||
{ | ||
/** | ||
* @var NotificationSyncer | ||
*/ | ||
protected $notifications; | ||
|
||
/** | ||
* @param NotificationSyncer $notifications | ||
*/ | ||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
/** | ||
* @param Hidden|Deleted $event | ||
*/ | ||
public function handle($event) | ||
{ | ||
$this->notifications->delete(new NewPostBlueprint($event->post)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* (c) Toby Zerner <toby.zerner@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Subscriptions\Listener; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored; | ||
use Flarum\Subscriptions\Notification\NewPostBlueprint; | ||
|
||
class RestoreNotificationWhenPostIsRestored | ||
{ | ||
/** | ||
* @var NotificationSyncer | ||
*/ | ||
protected $notifications; | ||
|
||
/** | ||
* @param NotificationSyncer $notifications | ||
*/ | ||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(Restored $event) | ||
{ | ||
$this->notifications->restore(new NewPostBlueprint($event->post)); | ||
} | ||
} |
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