mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Update to use new extenders
This commit is contained in:
parent
e17b088c20
commit
70cbe1d186
|
@ -13,12 +13,11 @@ use Flarum\Approval\Access;
|
|||
use Flarum\Approval\Event\PostWasApproved;
|
||||
use Flarum\Approval\Listener;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Event\GetModelIsPrivate;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Post\CommentPost;
|
||||
use Flarum\Post\Event\Saving;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Tags\Tag;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
return [
|
||||
(new Extend\Frontend('forum'))
|
||||
|
@ -64,7 +63,9 @@ return [
|
|||
(new Extend\ModelVisibility(Discussion::class))
|
||||
->scope(Access\ScopePrivateDiscussionVisibility::class, 'viewPrivate'),
|
||||
|
||||
function (Dispatcher $events) {
|
||||
$events->listen(GetModelIsPrivate::class, [Listener\UnapproveNewContent::class, 'markUnapprovedContentAsPrivate']);
|
||||
},
|
||||
(new Extend\ModelPrivate(Discussion::class))
|
||||
->checker([Listener\UnapproveNewContent::class, 'markUnapprovedContentAsPrivate']),
|
||||
|
||||
(new Extend\ModelPrivate(CommentPost::class))
|
||||
->checker([Listener\UnapproveNewContent::class, 'markUnapprovedContentAsPrivate']),
|
||||
];
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
namespace Flarum\Approval\Listener;
|
||||
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Event\GetModelIsPrivate;
|
||||
use Flarum\Flags\Flag;
|
||||
use Flarum\Post\CommentPost;
|
||||
use Flarum\Post\Event\Saving;
|
||||
use Flarum\Post\Post;
|
||||
|
||||
class UnapproveNewContent
|
||||
{
|
||||
|
@ -55,15 +54,13 @@ class UnapproveNewContent
|
|||
}
|
||||
|
||||
/**
|
||||
* @param GetModelIsPrivate $event
|
||||
* @param Discussion|CommentPost $instance
|
||||
* @return bool|null
|
||||
*/
|
||||
public static function markUnapprovedContentAsPrivate(GetModelIsPrivate $event)
|
||||
public static function markUnapprovedContentAsPrivate($instance)
|
||||
{
|
||||
if ($event->model instanceof Post || $event->model instanceof Discussion) {
|
||||
if (! $event->model->is_approved) {
|
||||
return true;
|
||||
}
|
||||
if (! $instance->is_approved) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user