mirror of
https://github.com/flarum/core.git
synced 2025-10-18 18:26:07 +02:00
Deprecate AssertPermissionTrait (#2044)
This commit is contained in:
committed by
GitHub
parent
2b3dec2be1
commit
eaac78650f
@@ -12,13 +12,11 @@ namespace Flarum\Post\Command;
|
||||
use Flarum\Foundation\DispatchEventsTrait;
|
||||
use Flarum\Post\Event\Deleting;
|
||||
use Flarum\Post\PostRepository;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class DeletePostHandler
|
||||
{
|
||||
use DispatchEventsTrait;
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var \Flarum\Post\PostRepository
|
||||
@@ -46,7 +44,7 @@ class DeletePostHandler
|
||||
|
||||
$post = $this->posts->findOrFail($command->postId, $actor);
|
||||
|
||||
$this->assertCan($actor, 'delete', $post);
|
||||
$actor->assertCan('delete', $post);
|
||||
|
||||
$this->events->dispatch(
|
||||
new Deleting($post, $actor, $command->data)
|
||||
|
@@ -14,14 +14,12 @@ use Flarum\Post\CommentPost;
|
||||
use Flarum\Post\Event\Saving;
|
||||
use Flarum\Post\PostRepository;
|
||||
use Flarum\Post\PostValidator;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class EditPostHandler
|
||||
{
|
||||
use DispatchEventsTrait;
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var \Flarum\Post\PostRepository
|
||||
@@ -61,13 +59,13 @@ class EditPostHandler
|
||||
$attributes = Arr::get($data, 'attributes', []);
|
||||
|
||||
if (isset($attributes['content'])) {
|
||||
$this->assertCan($actor, 'edit', $post);
|
||||
$actor->assertCan('edit', $post);
|
||||
|
||||
$post->revise($attributes['content'], $actor);
|
||||
}
|
||||
|
||||
if (isset($attributes['isHidden'])) {
|
||||
$this->assertCan($actor, 'hide', $post);
|
||||
$actor->assertCan('hide', $post);
|
||||
|
||||
if ($attributes['isHidden']) {
|
||||
$post->hide($actor);
|
||||
|
@@ -16,14 +16,12 @@ use Flarum\Notification\NotificationSyncer;
|
||||
use Flarum\Post\CommentPost;
|
||||
use Flarum\Post\Event\Saving;
|
||||
use Flarum\Post\PostValidator;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class PostReplyHandler
|
||||
{
|
||||
use DispatchEventsTrait;
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var DiscussionRepository
|
||||
@@ -77,7 +75,7 @@ class PostReplyHandler
|
||||
// If this is the first post in the discussion, it's technically not a
|
||||
// "reply", so we won't check for that permission.
|
||||
if ($discussion->post_number_index > 0) {
|
||||
$this->assertCan($actor, 'reply', $discussion);
|
||||
$actor->assertCan('reply', $discussion);
|
||||
}
|
||||
|
||||
// Create a new Post entity, persist it, and dispatch domain events.
|
||||
|
Reference in New Issue
Block a user