mirror of
https://github.com/flarum/core.git
synced 2025-10-13 07:54: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\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Validator\GroupValidator;
|
||||
use Flarum\Event\GroupWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
@@ -23,11 +24,18 @@ class CreateGroupHandler
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @var GroupValidator
|
||||
*/
|
||||
public function __construct(Dispatcher $events)
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param GroupValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, GroupValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +61,8 @@ class CreateGroupHandler
|
||||
new GroupWillBeSaved($group, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($group->getAttributes());
|
||||
|
||||
$group->save();
|
||||
|
||||
$this->dispatchEventsFor($group, $actor);
|
||||
|
Reference in New Issue
Block a user