Extract Flarum\Group namespace

This commit is contained in:
Franz Liedke 2017-06-24 14:05:00 +02:00
parent 11bf3e34b7
commit c22219ec20
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
24 changed files with 69 additions and 71 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -11,7 +11,7 @@
namespace Flarum\Api\Serializer;
use Flarum\Core\Group;
use Flarum\Group\Group;
use InvalidArgumentException;
use Symfony\Component\Translation\TranslatorInterface;

View File

@ -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());

View File

@ -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();

View File

@ -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());

View File

@ -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');

View File

@ -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;

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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;

View File

@ -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');
}
}

View File

@ -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;

View File

@ -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
*/

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Validator;
namespace Flarum\Group;
use Flarum\Foundation\AbstractValidator;

View File

@ -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');
}
/**

View File

@ -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;

View File

@ -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)

View File

@ -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()
{

View File

@ -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)
{

View File

@ -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');
}
/**