mirror of
https://github.com/flarum/core.git
synced 2025-10-26 21:21:28 +01: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:
@@ -19,6 +19,7 @@ use Flarum\User\User;
|
||||
use Flarum\User\UserRepository;
|
||||
use Flarum\User\UserValidator;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class EditUserHandler
|
||||
@@ -64,8 +65,8 @@ class EditUserHandler
|
||||
$canEdit = $actor->can('edit', $user);
|
||||
$isSelf = $actor->id === $user->id;
|
||||
|
||||
$attributes = array_get($data, 'attributes', []);
|
||||
$relationships = array_get($data, 'relationships', []);
|
||||
$attributes = Arr::get($data, 'attributes', []);
|
||||
$relationships = Arr::get($data, 'relationships', []);
|
||||
$validate = [];
|
||||
|
||||
if (isset($attributes['username'])) {
|
||||
@@ -115,7 +116,7 @@ class EditUserHandler
|
||||
|
||||
$newGroupIds = [];
|
||||
foreach ($relationships['groups']['data'] as $group) {
|
||||
if ($id = array_get($group, 'id')) {
|
||||
if ($id = Arr::get($group, 'id')) {
|
||||
$newGroupIds[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ use Flarum\User\RegistrationToken;
|
||||
use Flarum\User\User;
|
||||
use Flarum\User\UserValidator;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Intervention\Image\ImageManager;
|
||||
|
||||
@@ -75,19 +77,19 @@ class RegisterUserHandler
|
||||
$this->assertAdmin($actor);
|
||||
}
|
||||
|
||||
$password = array_get($data, 'attributes.password');
|
||||
$password = Arr::get($data, 'attributes.password');
|
||||
|
||||
// If a valid authentication token was provided as an attribute,
|
||||
// then we won't require the user to choose a password.
|
||||
if (isset($data['attributes']['token'])) {
|
||||
$token = RegistrationToken::validOrFail($data['attributes']['token']);
|
||||
|
||||
$password = $password ?: str_random(20);
|
||||
$password = $password ?: Str::random(20);
|
||||
}
|
||||
|
||||
$user = User::register(
|
||||
array_get($data, 'attributes.username'),
|
||||
array_get($data, 'attributes.email'),
|
||||
Arr::get($data, 'attributes.username'),
|
||||
Arr::get($data, 'attributes.email'),
|
||||
$password
|
||||
);
|
||||
|
||||
@@ -95,7 +97,7 @@ class RegisterUserHandler
|
||||
$this->applyToken($user, $token);
|
||||
}
|
||||
|
||||
if ($actor->isAdmin() && array_get($data, 'attributes.isEmailConfirmed')) {
|
||||
if ($actor->isAdmin() && Arr::get($data, 'attributes.isEmailConfirmed')) {
|
||||
$user->activate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user