mirror of
https://github.com/flarum/core.git
synced 2025-10-15 00:44:40 +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:
@@ -16,6 +16,8 @@ use Flarum\Discussion\Discussion;
|
||||
use Flarum\Discussion\DiscussionRepository;
|
||||
use Flarum\Post\PostRepository;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Tobscure\JsonApi\Document;
|
||||
|
||||
@@ -73,7 +75,7 @@ class ShowDiscussionController extends AbstractShowController
|
||||
*/
|
||||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
$discussionId = array_get($request->getQueryParams(), 'id');
|
||||
$discussionId = Arr::get($request->getQueryParams(), 'id');
|
||||
$actor = $request->getAttribute('actor');
|
||||
$include = $this->extractInclude($request);
|
||||
|
||||
@@ -86,7 +88,7 @@ class ShowDiscussionController extends AbstractShowController
|
||||
}
|
||||
|
||||
$discussion->load(array_filter($include, function ($relationship) {
|
||||
return ! starts_with($relationship, 'posts');
|
||||
return ! Str::startsWith($relationship, 'posts');
|
||||
}));
|
||||
|
||||
return $discussion;
|
||||
@@ -150,7 +152,7 @@ class ShowDiscussionController extends AbstractShowController
|
||||
$queryParams = $request->getQueryParams();
|
||||
$actor = $request->getAttribute('actor');
|
||||
|
||||
if (($near = array_get($queryParams, 'page.near')) > 1) {
|
||||
if (($near = Arr::get($queryParams, 'page.near')) > 1) {
|
||||
$offset = $this->posts->getIndexForNumber($discussion->id, $near, $actor);
|
||||
$offset = max(0, $offset - $limit / 2);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user