Flarum\Core\Command\DeletePostHandler::handle PHP Method

handle() public method

public handle ( DeletePost $command ) : Post
$command DeletePost
return Flarum\Core\Post
    public function handle(DeletePost $command)
    {
        $actor = $command->actor;
        $post = $this->posts->findOrFail($command->postId, $actor);
        $this->assertCan($actor, 'delete', $post);
        $this->events->fire(new PostWillBeDeleted($post, $actor, $command->data));
        $post->delete();
        $this->dispatchEventsFor($post, $actor);
        return $post;
    }
DeletePostHandler