Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Laravel 6, finally! #2243

Merged
merged 5 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
"dflydev/fig-cookies": "^2.0.1",
"doctrine/dbal": "^2.7",
"franzl/whoops-middleware": "^0.4.0",
"illuminate/bus": "5.8.*",
"illuminate/cache": "5.8.*",
"illuminate/config": "5.8.*",
"illuminate/container": "5.8.*",
"illuminate/contracts": "5.8.*",
"illuminate/database": "5.8.*",
"illuminate/events": "5.8.*",
"illuminate/filesystem": "5.8.*",
"illuminate/hashing": "5.8.*",
"illuminate/mail": "5.8.*",
"illuminate/queue": "5.8.*",
"illuminate/session": "5.8.*",
"illuminate/support": "5.8.*",
"illuminate/validation": "5.8.*",
"illuminate/view": "5.8.*",
"illuminate/bus": "^6.0",
"illuminate/cache": "^6.0",
"illuminate/config": "^6.0",
"illuminate/container": "^6.0",
"illuminate/contracts": "^6.0",
"illuminate/database": "^6.0",
"illuminate/events": "^6.0",
"illuminate/filesystem": "^6.0",
"illuminate/hashing": "^6.0",
"illuminate/mail": "^6.0",
"illuminate/queue": "^6.0",
"illuminate/session": "^6.0",
"illuminate/support": "^6.0",
"illuminate/validation": "^6.0",
"illuminate/view": "^6.0",
"intervention/image": "^2.5.0",
"laminas/laminas-diactoros": "^1.8.4",
"laminas/laminas-httphandlerrunner": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Extension/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private function getExtenders(): array
$extenders = [$extenders];
}

return array_flatten($extenders);
return Arr::flatten($extenders);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Forum/Content/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
use Flarum\Http\UrlGenerator;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\User;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;
use Symfony\Component\Translation\TranslatorInterface;

class Index
{
Expand All @@ -42,14 +42,19 @@ class Index
*/
protected $url;

/**
* @var TranslatorInterface
*/
protected $translator;

/**
* @param Client $api
* @param Factory $view
* @param SettingsRepositoryInterface $settings
* @param UrlGenerator $url
* @param Translator $translator
* @param TranslatorInterface $translator
*/
public function __construct(Client $api, Factory $view, SettingsRepositoryInterface $settings, UrlGenerator $url, Translator $translator)
public function __construct(Client $api, Factory $view, SettingsRepositoryInterface $settings, UrlGenerator $url, TranslatorInterface $translator)
{
$this->api = $api;
$this->view = $view;
Expand Down
3 changes: 2 additions & 1 deletion src/Foundation/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Flarum\Foundation;

use Illuminate\Support\Arr;
use RuntimeException;

class Site
Expand Down Expand Up @@ -62,6 +63,6 @@ private static function loadExtenders($basePath): array
return [];
}

return array_flatten($extenders);
return Arr::flatten($extenders);
}
}
3 changes: 2 additions & 1 deletion src/Frontend/Content/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Flarum\Frontend\Compiler\CompilerInterface;
use Flarum\Frontend\Document;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;

class Assets
Expand Down Expand Up @@ -48,7 +49,7 @@ public function __invoke(Document $document, Request $request)
];

if ($this->app->inDebugMode()) {
$this->commit(array_flatten($compilers));
$this->commit(Arr::flatten($compilers));
}

$document->js = array_merge($document->js, $this->getUrls($compilers['js']));
Expand Down
10 changes: 10 additions & 0 deletions src/Locale/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ class Translator extends BaseTranslator implements TranslatorContract
{
const REFERENCE_REGEX = '/^=>\s*([a-z0-9_\-\.]+)$/i';

public function get($key, array $replace = [], $locale = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this the other way around, and have the logic in Laravel's new methods, and have the old methods reference the new ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "old" ones come from the Symfony base implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I bring this up is that if we eventually want to comply with the laravel contract, we might as well move the logic to laravel's methods. If we want to eventually drop the laravel translation contract, this is fine though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what you mean, sorry. trans() and transChoice() are implemented in Symfony's translator, and we don't overwrite these. And since we're mostly/only using Symfony's interface throughout the app, I'd rather keep their implementation as well. These two methods are only needed as a bridge to be able to use this Symfony-based translator in Laravel's validation component.

{
return $this->trans($key, $replace, null, $locale);
}

public function choice($key, $number, array $replace = [], $locale = null)
{
return $this->transChoice($key, $number, $replace, nil, $locale);
}

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 4 additions & 4 deletions src/User/AccountActivationMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Event\Registered;
use Illuminate\Contracts\Queue\Queue;
use Illuminate\Contracts\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;

class AccountActivationMailer
{
Expand All @@ -34,17 +34,17 @@ class AccountActivationMailer
protected $url;

/**
* @var Translator
* @var TranslatorInterface
*/
protected $translator;

/**
* @param \Flarum\Settings\SettingsRepositoryInterface $settings
* @param Queue $queue
* @param UrlGenerator $url
* @param Translator $translator
* @param TranslatorInterface $translator
*/
public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, Translator $translator)
public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, TranslatorInterface $translator)
{
$this->settings = $settings;
$this->queue = $queue;
Expand Down
8 changes: 4 additions & 4 deletions src/User/Command/RequestPasswordResetHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
use Flarum\User\PasswordToken;
use Flarum\User\UserRepository;
use Illuminate\Contracts\Queue\Queue;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\Translation\TranslatorInterface;

class RequestPasswordResetHandler
{
Expand All @@ -43,7 +43,7 @@ class RequestPasswordResetHandler
protected $url;

/**
* @var Translator
* @var TranslatorInterface
*/
protected $translator;

Expand All @@ -57,15 +57,15 @@ class RequestPasswordResetHandler
* @param SettingsRepositoryInterface $settings
* @param Queue $queue
* @param UrlGenerator $url
* @param Translator $translator
* @param TranslatorInterface $translator
* @param Factory $validatorFactory
*/
public function __construct(
UserRepository $users,
SettingsRepositoryInterface $settings,
Queue $queue,
UrlGenerator $url,
Translator $translator,
TranslatorInterface $translator,
Factory $validatorFactory
) {
$this->users = $users;
Expand Down
6 changes: 3 additions & 3 deletions src/User/EmailConfirmationMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Event\EmailChangeRequested;
use Illuminate\Contracts\Queue\Queue;
use Illuminate\Contracts\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;

class EmailConfirmationMailer
{
Expand All @@ -34,11 +34,11 @@ class EmailConfirmationMailer
protected $url;

/**
* @var Translator
* @var TranslatorInterface
*/
protected $translator;

public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, Translator $translator)
public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, TranslatorInterface $translator)
{
$this->settings = $settings;
$this->queue = $queue;
Expand Down
9 changes: 4 additions & 5 deletions views/frontend/admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
<div id="header-navigation" class="Header-navigation"></div>
<div class="container">
<h1 class="Header-title">
<a href="{{ array_get($forum, 'baseUrl') }}">
<?php $title = array_get($forum, 'title'); ?>
@if ($logo = array_get($forum, 'logoUrl'))
<img src="{{ $logo }}" alt="{{ $title }}" class="Header-logo">
<a href="{{ $forum['baseUrl'] }}">
@if ($forum['logoUrl'])
<img src="{{ $forum['logoUrl'] }}" alt="{{ $forum['title'] }}" class="Header-logo">
@else
{{ $title }}
{{ $forum['title'] }}
@endif
</a>
</h1>
Expand Down
12 changes: 6 additions & 6 deletions views/frontend/forum.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{!! array_get($forum, 'headerHtml') !!}
{!! $forum['headerHtml'] !!}

<div id="app" class="App">

Expand All @@ -10,11 +10,11 @@
<div id="header-navigation" class="Header-navigation"></div>
<div class="container">
<h1 class="Header-title">
<a href="{{ array_get($forum, 'baseUrl') }}" id="home-link">
@if ($logo = array_get($forum, 'logoUrl'))
<img src="{{ $logo }}" alt="{{ array_get($forum, 'title') }}" class="Header-logo">
<a href="{{ $forum['baseUrl'] }}" id="home-link">
@if ($forum['logoUrl'])
<img src="{{ $forum['logoUrl'] }}" alt="{{ $forum['title'] }}" class="Header-logo">
@else
{{ array_get($forum, 'title') }}
{{ $forum['title'] }}
@endif
</a>
</h1>
Expand All @@ -39,4 +39,4 @@

</div>

{!! array_get($forum, 'footerHtml') !!}
{!! $forum['footerHtml'] !!}