mirror of
https://github.com/flarum/core.git
synced 2025-10-11 15:04:25 +02:00
Refactor translation and validation
We now use Symfony's Translation component. Yay! We get more powerful pluralisation and better a fallback mechanism. Will want to implement the caching mechanism at some point too. The API is replicated in JavaScript, which could definitely use some testing. Validators have been refactored so that they are decoupled from models completely (i.e. they simply validate arrays of user input). Language packs should include Laravel's validation messages. ref #267
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Flarum\Core\Command;
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Core\AuthToken;
|
||||
use Flarum\Core\Validator\UserValidator;
|
||||
use Flarum\Event\UserWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Flarum\Settings\SettingsRepository;
|
||||
@@ -29,14 +30,21 @@ class RegisterUserHandler
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var UserValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param SettingsRepository $settings
|
||||
* @param UserValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, SettingsRepository $settings)
|
||||
public function __construct(Dispatcher $events, SettingsRepository $settings, UserValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->settings = $settings;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,6 +96,8 @@ class RegisterUserHandler
|
||||
new UserWillBeSaved($user, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid(array_merge($user->getAttributes(), compact('password')));
|
||||
|
||||
$user->save();
|
||||
|
||||
if (isset($token)) {
|
||||
|
Reference in New Issue
Block a user