mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 17:02:45 +08:00
Extract Flarum\Group namespace
This commit is contained in:
parent
11bf3e34b7
commit
c22219ec20
|
@ -12,7 +12,7 @@
|
|||
namespace Flarum\Admin\Controller;
|
||||
|
||||
use Flarum\Admin\Frontend;
|
||||
use Flarum\Core\Permission;
|
||||
use Flarum\Group\Permission;
|
||||
use Flarum\Settings\Event\Deserializing;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Frontend\AbstractFrontendController;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\Api\Controller;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Tobscure\JsonApi\Document;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Flarum\Api\Controller;
|
||||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Core\Permission;
|
||||
use Flarum\Group\Permission;
|
||||
use Flarum\Http\Controller\ControllerInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response\EmptyResponse;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\Api\Controller;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Tobscure\JsonApi\Document;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\Api\Serializer;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Flarum\Core\Command;
|
|||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\Foundation\DispatchEventsTrait;
|
||||
use Flarum\Core\Validator\GroupValidator;
|
||||
use Flarum\Event\GroupWillBeSaved;
|
||||
use Flarum\Group\GroupValidator;
|
||||
use Flarum\Group\Event\Saving;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class CreateGroupHandler
|
||||
|
@ -25,13 +25,13 @@ class CreateGroupHandler
|
|||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var GroupValidator
|
||||
* @var \Flarum\Group\GroupValidator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
* @param GroupValidator $validator
|
||||
* @param \Flarum\Group\GroupValidator $validator
|
||||
*/
|
||||
public function __construct(Dispatcher $events, GroupValidator $validator)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ class CreateGroupHandler
|
|||
|
||||
/**
|
||||
* @param CreateGroup $command
|
||||
* @return Group
|
||||
* @return \Flarum\Group\Group
|
||||
* @throws \Flarum\User\Exception\PermissionDeniedException
|
||||
*/
|
||||
public function handle(CreateGroup $command)
|
||||
|
@ -59,7 +59,7 @@ class CreateGroupHandler
|
|||
);
|
||||
|
||||
$this->events->fire(
|
||||
new GroupWillBeSaved($group, $actor, $data)
|
||||
new Saving($group, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($group->getAttributes());
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace Flarum\Core\Command;
|
|||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Repository\GroupRepository;
|
||||
use Flarum\Group\GroupRepository;
|
||||
use Flarum\Foundation\DispatchEventsTrait;
|
||||
use Flarum\Event\GroupWillBeDeleted;
|
||||
use Flarum\Group\Event\Deleting;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class DeleteGroupHandler
|
||||
|
@ -39,7 +39,7 @@ class DeleteGroupHandler
|
|||
|
||||
/**
|
||||
* @param DeleteGroup $command
|
||||
* @return \Flarum\Core\Group
|
||||
* @return \Flarum\Group\Group
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
public function handle(DeleteGroup $command)
|
||||
|
@ -51,7 +51,7 @@ class DeleteGroupHandler
|
|||
$this->assertCan($actor, 'delete', $group);
|
||||
|
||||
$this->events->fire(
|
||||
new GroupWillBeDeleted($group, $actor, $command->data)
|
||||
new Deleting($group, $actor, $command->data)
|
||||
);
|
||||
|
||||
$group->delete();
|
||||
|
|
|
@ -13,11 +13,11 @@ namespace Flarum\Core\Command;
|
|||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Repository\GroupRepository;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\Group\GroupRepository;
|
||||
use Flarum\Foundation\DispatchEventsTrait;
|
||||
use Flarum\Core\Validator\GroupValidator;
|
||||
use Flarum\Event\GroupWillBeSaved;
|
||||
use Flarum\Group\GroupValidator;
|
||||
use Flarum\Group\Event\Saving;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class EditGroupHandler
|
||||
|
@ -26,7 +26,7 @@ class EditGroupHandler
|
|||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var GroupRepository
|
||||
* @var \Flarum\Group\GroupRepository
|
||||
*/
|
||||
protected $groups;
|
||||
|
||||
|
@ -76,7 +76,7 @@ class EditGroupHandler
|
|||
}
|
||||
|
||||
$this->events->fire(
|
||||
new GroupWillBeSaved($group, $actor, $data)
|
||||
new Saving($group, $actor, $data)
|
||||
);
|
||||
|
||||
$this->validator->assertValid($group->getDirty());
|
||||
|
|
|
@ -114,7 +114,7 @@ class CoreServiceProvider extends AbstractServiceProvider
|
|||
$events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier');
|
||||
|
||||
$events->subscribe('Flarum\Discussion\DiscussionPolicy');
|
||||
$events->subscribe('Flarum\Core\Access\GroupPolicy');
|
||||
$events->subscribe('Flarum\Group\GroupPolicy');
|
||||
$events->subscribe('Flarum\Post\PostPolicy');
|
||||
$events->subscribe('Flarum\User\UserPolicy');
|
||||
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
namespace Flarum\Group\Event;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\User\User;
|
||||
|
||||
class GroupWasCreated
|
||||
class Created
|
||||
{
|
||||
/**
|
||||
* @var Group
|
||||
* @var \Flarum\Group\Group
|
||||
*/
|
||||
public $group;
|
||||
|
|
@ -9,15 +9,15 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
namespace Flarum\Group\Event;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\User\User;
|
||||
|
||||
class GroupWasDeleted
|
||||
class Deleted
|
||||
{
|
||||
/**
|
||||
* @var Group
|
||||
* @var \Flarum\Group\Group
|
||||
*/
|
||||
public $group;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class GroupWasDeleted
|
|||
public $actor;
|
||||
|
||||
/**
|
||||
* @param Group $group
|
||||
* @param \Flarum\Group\Group $group
|
||||
* @param User $actor
|
||||
*/
|
||||
public function __construct(Group $group, User $actor = null)
|
|
@ -9,12 +9,12 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
namespace Flarum\Group\Event;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\User\User;
|
||||
|
||||
class GroupWillBeDeleted
|
||||
class Deleting
|
||||
{
|
||||
/**
|
||||
* The group that will be deleted.
|
|
@ -9,15 +9,15 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
namespace Flarum\Group\Event;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\User\User;
|
||||
|
||||
class GroupWasRenamed
|
||||
class Renamed
|
||||
{
|
||||
/**
|
||||
* @var Group
|
||||
* @var \Flarum\Group\Group
|
||||
*/
|
||||
public $group;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class GroupWasRenamed
|
|||
public $actor;
|
||||
|
||||
/**
|
||||
* @param Group $group
|
||||
* @param \Flarum\Group\Group $group
|
||||
* @param User $actor
|
||||
*/
|
||||
public function __construct(Group $group, User $actor = null)
|
|
@ -9,17 +9,17 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
namespace Flarum\Group\Event;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\User\User;
|
||||
|
||||
class GroupWillBeSaved
|
||||
class Saving
|
||||
{
|
||||
/**
|
||||
* The group that will be saved.
|
||||
*
|
||||
* @var Group
|
||||
* @var \Flarum\Group\Group
|
||||
*/
|
||||
public $group;
|
||||
|
|
@ -9,14 +9,14 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core;
|
||||
namespace Flarum\Group;
|
||||
|
||||
use Flarum\Foundation\EventGeneratorTrait;
|
||||
use Flarum\Database\ScopeVisibilityTrait;
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Flarum\Event\GroupWasCreated;
|
||||
use Flarum\Event\GroupWasDeleted;
|
||||
use Flarum\Event\GroupWasRenamed;
|
||||
use Flarum\Group\Event\Created;
|
||||
use Flarum\Group\Event\Deleting;
|
||||
use Flarum\Group\Event\Renamed;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
|
@ -67,7 +67,7 @@ class Group extends AbstractModel
|
|||
parent::boot();
|
||||
|
||||
static::deleted(function (Group $group) {
|
||||
$group->raise(new GroupWasDeleted($group));
|
||||
$group->raise(new Deleting($group));
|
||||
|
||||
$group->permissions()->delete();
|
||||
});
|
||||
|
@ -91,7 +91,7 @@ class Group extends AbstractModel
|
|||
$group->color = $color;
|
||||
$group->icon = $icon;
|
||||
|
||||
$group->raise(new GroupWasCreated($group));
|
||||
$group->raise(new Created($group));
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class Group extends AbstractModel
|
|||
$this->name_singular = $nameSingular;
|
||||
$this->name_plural = $namePlural;
|
||||
|
||||
$this->raise(new GroupWasRenamed($this));
|
||||
$this->raise(new Renamed($this));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -130,6 +130,6 @@ class Group extends AbstractModel
|
|||
*/
|
||||
public function permissions()
|
||||
{
|
||||
return $this->hasMany('Flarum\Core\Permission');
|
||||
return $this->hasMany('Flarum\Group\Permission');
|
||||
}
|
||||
}
|
|
@ -9,9 +9,8 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core\Access;
|
||||
namespace Flarum\Group;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\User\AbstractPolicy;
|
||||
use Flarum\User\User;
|
||||
|
|
@ -9,9 +9,8 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core\Repository;
|
||||
namespace Flarum\Group;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
|
@ -33,7 +32,7 @@ class GroupRepository
|
|||
*
|
||||
* @param int $id
|
||||
* @param User $actor
|
||||
* @return Group
|
||||
* @return \Flarum\Group\Group
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
*/
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core\Validator;
|
||||
namespace Flarum\Group;
|
||||
|
||||
use Flarum\Foundation\AbstractValidator;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core;
|
||||
namespace Flarum\Group;
|
||||
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
@ -31,7 +31,7 @@ class Permission extends AbstractModel
|
|||
*/
|
||||
public function group()
|
||||
{
|
||||
return $this->belongsTo('Flarum\Core\Group', 'group_id');
|
||||
return $this->belongsTo('Flarum\Group\Group', 'group_id');
|
||||
}
|
||||
|
||||
/**
|
|
@ -13,8 +13,8 @@ namespace Flarum\Install\Console;
|
|||
|
||||
use Exception;
|
||||
use Flarum\Console\AbstractCommand;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Core\Permission;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\Group\Permission;
|
||||
use Flarum\User\User;
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
|
|
@ -23,7 +23,7 @@ class GroupsChanged
|
|||
public $user;
|
||||
|
||||
/**
|
||||
* @var \Flarum\Core\Group[]
|
||||
* @var \Flarum\Group\Group[]
|
||||
*/
|
||||
public $oldGroups;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class GroupsChanged
|
|||
|
||||
/**
|
||||
* @param User $user The user whose groups were changed.
|
||||
* @param \Flarum\Core\Group[] $oldGroups
|
||||
* @param \Flarum\Group\Group[] $oldGroups
|
||||
* @param User $actor
|
||||
*/
|
||||
public function __construct(User $user, array $oldGroups, User $actor = null)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\User;
|
||||
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
|
||||
class Guest extends User
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ class Guest extends User
|
|||
/**
|
||||
* Get the guest's group, containing only the 'guests' group model.
|
||||
*
|
||||
* @return Group
|
||||
* @return \Flarum\Group\Group
|
||||
*/
|
||||
public function getGroupsAttribute()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\Core\User\Search\Gambit;
|
||||
|
||||
use Flarum\Core\Repository\GroupRepository;
|
||||
use Flarum\Group\GroupRepository;
|
||||
use Flarum\Search\AbstractRegexGambit;
|
||||
use Flarum\Search\AbstractSearch;
|
||||
use Flarum\Core\User\Search\UserSearch;
|
||||
|
@ -30,7 +30,7 @@ class GroupGambit extends AbstractRegexGambit
|
|||
protected $groups;
|
||||
|
||||
/**
|
||||
* @param \Flarum\Core\Repository\GroupRepository $groups
|
||||
* @param \Flarum\Group\GroupRepository $groups
|
||||
*/
|
||||
public function __construct(GroupRepository $groups)
|
||||
{
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace Flarum\User;
|
|||
|
||||
use DomainException;
|
||||
use Flarum\User\Gate;
|
||||
use Flarum\Core\Group;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\Core\Notification;
|
||||
use Flarum\Core\Permission;
|
||||
use Flarum\Group\Permission;
|
||||
use Flarum\Foundation\EventGeneratorTrait;
|
||||
use Flarum\Database\ScopeVisibilityTrait;
|
||||
use Flarum\Database\AbstractModel;
|
||||
|
@ -623,7 +623,7 @@ class User extends AbstractModel
|
|||
*/
|
||||
public function groups()
|
||||
{
|
||||
return $this->belongsToMany('Flarum\Core\Group', 'users_groups');
|
||||
return $this->belongsToMany('Flarum\Group\Group', 'users_groups');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user