mirror of
https://github.com/flarum/core.git
synced 2025-10-27 13:40:24 +01:00
Remove Deprecated Beta14 Code (#2428)
This commit is contained in:
committed by
GitHub
parent
5a763050a6
commit
fe41bc1fdc
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\User;
|
||||
|
||||
use Flarum\User\Exception\NotAuthenticatedException;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
|
||||
/**
|
||||
* @deprecated beta 14, remove beta 15. Please use direct methods of the User class instead. E.g. $actor->assertCan($ability);
|
||||
*/
|
||||
trait AssertPermissionTrait
|
||||
{
|
||||
/**
|
||||
* Ensure the current user is allowed to do something.
|
||||
*
|
||||
* If the condition is not met, an exception will be thrown that signals the
|
||||
* lack of permissions. This is about *authorization*, i.e. retrying such a
|
||||
* request / operation without a change in permissions (or using another
|
||||
* user account) is pointless.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
protected function assertPermission($condition)
|
||||
{
|
||||
if (! $condition) {
|
||||
throw new PermissionDeniedException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the given actor is authenticated.
|
||||
*
|
||||
* This will throw an exception for guest users, signaling that
|
||||
* *authorization* failed. Thus, they could retry the operation after
|
||||
* logging in (or using other means of authentication).
|
||||
*
|
||||
* @param User $actor
|
||||
* @throws NotAuthenticatedException
|
||||
*/
|
||||
protected function assertRegistered(User $actor)
|
||||
{
|
||||
$actor->assertRegistered();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $actor
|
||||
* @param string $ability
|
||||
* @param mixed $arguments
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
protected function assertCan(User $actor, $ability, $arguments = [])
|
||||
{
|
||||
$actor->assertCan($ability, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $actor
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
protected function assertAdmin(User $actor)
|
||||
{
|
||||
$actor->assertCan('administrate');
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\User\Event;
|
||||
|
||||
use Flarum\User\User;
|
||||
|
||||
/**
|
||||
* @deprecated beta 14, remove in beta 15.
|
||||
*/
|
||||
class GetDisplayName
|
||||
{
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ use Flarum\Database\AbstractModel;
|
||||
use Flarum\Database\ScopeVisibilityTrait;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Event\ConfigureUserPreferences;
|
||||
use Flarum\Event\PrepareUserGroups;
|
||||
use Flarum\Foundation\EventGeneratorTrait;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\Group\Permission;
|
||||
@@ -30,7 +29,6 @@ use Flarum\User\Event\CheckingPassword;
|
||||
use Flarum\User\Event\Deleted;
|
||||
use Flarum\User\Event\EmailChanged;
|
||||
use Flarum\User\Event\EmailChangeRequested;
|
||||
use Flarum\User\Event\GetDisplayName;
|
||||
use Flarum\User\Event\PasswordChanged;
|
||||
use Flarum\User\Event\Registered;
|
||||
use Flarum\User\Event\Renamed;
|
||||
@@ -327,8 +325,7 @@ class User extends AbstractModel
|
||||
*/
|
||||
public function getDisplayNameAttribute()
|
||||
{
|
||||
// Event is deprecated in beta 14, remove in beta 15.
|
||||
return static::$dispatcher->until(new GetDisplayName($this)) ?: static::$displayNameDriver->displayName($this);
|
||||
return static::$displayNameDriver->displayName($this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -722,9 +719,6 @@ class User extends AbstractModel
|
||||
$groupIds = array_merge($groupIds, [Group::MEMBER_ID], $this->groups->pluck('id')->all());
|
||||
}
|
||||
|
||||
/** @deprecated in beta 14, remove in beta 15 */
|
||||
event(new PrepareUserGroups($this, $groupIds));
|
||||
|
||||
foreach (static::$groupProcessors as $processor) {
|
||||
$groupIds = $processor($this, $groupIds);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user