Add TagWillBeSaved event

This commit is contained in:
Toby Zerner 2016-11-28 11:48:28 +10:30
parent 4773b3005d
commit deee3c02da
2 changed files with 48 additions and 0 deletions

View File

@ -14,6 +14,7 @@ namespace Flarum\Tags\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Tags\TagRepository;
use Flarum\Tags\TagValidator;
use Flarum\Tags\Event\TagWillBeSaved;
class EditTagHandler
{
@ -79,6 +80,8 @@ class EditTagHandler
$tag->is_restricted = (bool) $attributes['isRestricted'];
}
event(new TagWillBeSaved($tag, $actor, $data));
$this->validator->assertValid($tag->getDirty());
$tag->save();

View File

@ -0,0 +1,45 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Tags\Event;
use Flarum\Tags\Tag;
use Flarum\Core\User;
class TagWillBeSaved
{
/**
* @var Tag
*/
public $tag;
/**
* @var User
*/
public $actor;
/**
* @var array
*/
public $data;
/**
* @param Discussion $discussion
* @param User $actor
* @param \Flarum\Tags\Tag[] $tag
*/
public function __construct(Tag $tag, User $actor, array $data)
{
$this->tag = $tag;
$this->actor = $actor;
$this->data = $data;
}
}