1
0
mirror of https://github.com/flarum/core.git synced 2025-10-14 00:15:51 +02:00

Use Laravel's class-based Str and Arr helpers

Starting with version 5.9, the global funtions will be deprecated.

* https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers
* https://github.com/laravel/framework/pull/26898
This commit is contained in:
Franz Liedke
2019-07-06 00:49:34 +02:00
parent 307b912019
commit 646bd40bca
78 changed files with 229 additions and 144 deletions

View File

@@ -18,6 +18,7 @@ use Flarum\Post\PostRepository;
use Flarum\Post\PostValidator;
use Flarum\User\AssertPermissionTrait;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Arr;
class EditPostHandler
{
@@ -59,7 +60,7 @@ class EditPostHandler
$post = $this->posts->findOrFail($command->postId, $actor);
if ($post instanceof CommentPost) {
$attributes = array_get($data, 'attributes', []);
$attributes = Arr::get($data, 'attributes', []);
if (isset($attributes['content'])) {
$this->assertCan($actor, 'edit', $post);

View File

@@ -20,6 +20,7 @@ use Flarum\Post\Event\Saving;
use Flarum\Post\PostValidator;
use Flarum\User\AssertPermissionTrait;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Arr;
class PostReplyHandler
{
@@ -86,12 +87,12 @@ class PostReplyHandler
// opportunity to alter the post entity based on data in the command.
$post = CommentPost::reply(
$discussion->id,
array_get($command->data, 'attributes.content'),
Arr::get($command->data, 'attributes.content'),
$actor->id,
$command->ipAddress
);
if ($actor->isAdmin() && ($time = array_get($command->data, 'attributes.createdAt'))) {
if ($actor->isAdmin() && ($time = Arr::get($command->data, 'attributes.createdAt'))) {
$post->created_at = new Carbon($time);
}