mirror of
https://github.com/flarum/framework.git
synced 2025-02-23 16:14:10 +08:00
Add TagWillBeSaved event
This commit is contained in:
parent
4773b3005d
commit
deee3c02da
@ -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();
|
||||
|
45
extensions/tags/src/Event/TagWillBeSaved.php
Normal file
45
extensions/tags/src/Event/TagWillBeSaved.php
Normal 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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user