mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +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:
@@ -14,6 +14,7 @@ use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Repository\GroupRepository;
|
||||
use Flarum\Core\Validator\GroupValidator;
|
||||
use Flarum\Event\GroupWillBeSaved;
|
||||
use Flarum\Core\Support\DispatchEventsTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
@@ -28,14 +29,21 @@ class EditGroupHandler
|
||||
*/
|
||||
protected $groups;
|
||||
|
||||
/**
|
||||
* @var GroupValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param GroupRepository $groups
|
||||
* @param GroupValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, GroupRepository $groups)
|
||||
public function __construct(Dispatcher $events, GroupRepository $groups, GroupValidator $validator)
|
||||
{
|
||||
$this->events = $events;
|
||||
$this->groups = $groups;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +78,8 @@ class EditGroupHandler
|
||||
new GroupWillBeSaved($group, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($group->getDirty());
|
||||
|
||||
$group->save();
|
||||
|
||||
$this->dispatchEventsFor($group, $actor);
|
||||
|
Reference in New Issue
Block a user