Massively simplify TagPolicy

This commit is contained in:
Alexander Skvortsov 2021-05-11 22:16:55 -04:00
parent 3b3cbdc82f
commit fd48af2032

View File

@ -16,20 +16,10 @@ use Flarum\User\User;
class TagPolicy extends AbstractPolicy
{
/**
* @param User $actor
* @param Tag $tag
* @return bool|null
*/
public function addToDiscussion(User $actor, Tag $tag)
{
static $disallowedTags;
if (! isset($disallowedTags[$actor->id])) {
$disallowedTags[$actor->id] = Tag::getIdsWhereCannot($actor, 'discussion.startWithoutApproval');
}
if (in_array($tag->id, $disallowedTags)) {
return $this->deny();
}
return $actor->can('discussion.startWithoutApproval', $tag);
}
}