1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 23:47:32 +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:
Toby Zerner
2015-10-15 22:30:45 +10:30
parent a23180f279
commit c08b62af80
32 changed files with 578 additions and 4096 deletions

View File

@@ -11,6 +11,7 @@
namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Validator\PostValidator;
use Flarum\Event\PostWillBeSaved;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Core\Post\CommentPost;
@@ -33,19 +34,27 @@ class PostReplyHandler
*/
protected $notifications;
/**
* @var PostValidator
*/
protected $validator;
/**
* @param Dispatcher $events
* @param DiscussionRepository $discussions
* @param NotificationSyncer $notifications
* @param PostValidator $validator
*/
public function __construct(
Dispatcher $events,
DiscussionRepository $discussions,
NotificationSyncer $notifications
NotificationSyncer $notifications,
PostValidator $validator
) {
$this->events = $events;
$this->discussions = $discussions;
$this->notifications = $notifications;
$this->validator = $validator;
}
/**
@@ -79,6 +88,8 @@ class PostReplyHandler
new PostWillBeSaved($post, $actor, $command->data)
);
$this->validator->assertValid($post->getAttributes());
$post->save();
$this->notifications->onePerUser(function () use ($post, $actor) {