1
0
mirror of https://github.com/flarum/core.git synced 2025-07-29 12:40: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:
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

@@ -13,6 +13,7 @@ namespace Flarum\Frontend;
use Flarum\Frontend\Compiler\Source\SourceCollector;
use Flarum\Locale\LocaleManager;
use Illuminate\Support\Arr;
class AddTranslations
{
@@ -56,7 +57,7 @@ class AddTranslations
{
$translations = $this->locales->getTranslator()->getCatalogue($locale)->all('messages');
return array_only(
return Arr::only(
$translations,
array_filter(array_keys($translations), $this->filter)
);

View File

@@ -14,6 +14,7 @@ namespace Flarum\Frontend\Compiler;
use Flarum\Frontend\Compiler\Source\SourceCollector;
use Flarum\Frontend\Compiler\Source\SourceInterface;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Support\Arr;
class RevisionCompiler implements CompilerInterface
{
@@ -202,7 +203,7 @@ class RevisionCompiler implements CompilerInterface
if ($this->assetsDir->has(static::REV_MANIFEST)) {
$manifest = json_decode($this->assetsDir->read(static::REV_MANIFEST), true);
return array_get($manifest, $this->filename);
return Arr::get($manifest, $this->filename);
}
return null;

View File

@@ -12,6 +12,7 @@
namespace Flarum\Frontend\Content;
use Flarum\Frontend\Document;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;
class Meta
@@ -28,8 +29,8 @@ class Meta
$meta = [
'viewport' => 'width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1',
'description' => array_get($forumApiDocument, 'data.attributes.description'),
'theme-color' => array_get($forumApiDocument, 'data.attributes.themePrimaryColor')
'description' => Arr::get($forumApiDocument, 'data.attributes.description'),
'theme-color' => Arr::get($forumApiDocument, 'data.attributes.themePrimaryColor')
];
return $meta;
@@ -39,7 +40,7 @@ class Meta
{
$head = [];
if ($faviconUrl = array_get($document->getForumApiDocument(), 'data.attributes.faviconUrl')) {
if ($faviconUrl = Arr::get($document->getForumApiDocument(), 'data.attributes.faviconUrl')) {
$head['favicon'] = '<link rel="shortcut icon" href="'.e($faviconUrl).'">';
}

View File

@@ -14,6 +14,7 @@ namespace Flarum\Frontend;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
/**
* A view which renders a HTML skeleton for Flarum's frontend app.
@@ -147,7 +148,7 @@ class Document implements Renderable
*/
public function render(): string
{
$this->view->share('forum', array_get($this->forumApiDocument, 'data.attributes'));
$this->view->share('forum', Arr::get($this->forumApiDocument, 'data.attributes'));
return $this->makeView()->render();
}
@@ -174,7 +175,7 @@ class Document implements Renderable
*/
protected function makeTitle(): string
{
return ($this->title ? $this->title.' - ' : '').array_get($this->forumApiDocument, 'data.attributes.title');
return ($this->title ? $this->title.' - ' : '').Arr::get($this->forumApiDocument, 'data.attributes.title');
}
/**