Update for beta 8 (#44)

* Update for beta 8

* Make StyleCI happy

* Update Tag.php
This commit is contained in:
Charlie 2017-09-01 00:07:39 -07:00 committed by Toby Zerner
parent e85f4122ee
commit 360b9b04f1
24 changed files with 94 additions and 94 deletions

View File

@ -9,8 +9,8 @@
* file that was distributed with this source code.
*/
use Flarum\Core\Group;
use Flarum\Database\Migration;
use Flarum\Group\Group;
return Migration::addPermissions([
'discussion.tag' => Group::MODERATOR_ID

View File

@ -12,12 +12,12 @@
namespace Flarum\Tags\Access;
use Carbon\Carbon;
use Flarum\Core\Access\AbstractPolicy;
use Flarum\Core\Discussion;
use Flarum\Core\User;
use Flarum\Discussion\Discussion;
use Flarum\Event\ScopeHiddenDiscussionVisibility;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Tags\Tag;
use Flarum\User\AbstractPolicy;
use Flarum\User\User;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;

View File

@ -11,10 +11,10 @@
namespace Flarum\Tags\Access;
use Flarum\Core\Access\AbstractPolicy;
use Flarum\Core\User;
use Flarum\Flags\Flag;
use Flarum\Tags\Tag;
use Flarum\User\AbstractPolicy;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;

View File

@ -11,9 +11,9 @@
namespace Flarum\Tags\Access;
use Flarum\Core\Access\AbstractPolicy;
use Flarum\Core\User;
use Flarum\Tags\Tag;
use Flarum\User\AbstractPolicy;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
class TagPolicy extends AbstractPolicy

View File

@ -11,9 +11,9 @@
namespace Flarum\Tags\Api\Controller;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Http\Controller\ControllerInterface;
use Flarum\Tags\Tag;
use Flarum\User\AssertPermissionTrait;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\EmptyResponse;

View File

@ -11,7 +11,7 @@
namespace Flarum\Tags\Command;
use Flarum\Core\User;
use Flarum\User\User;
class CreateTag
{

View File

@ -11,9 +11,9 @@
namespace Flarum\Tags\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Tags\Tag;
use Flarum\Tags\TagValidator;
use Flarum\User\AssertPermissionTrait;
class CreateTagHandler
{

View File

@ -11,7 +11,7 @@
namespace Flarum\Tags\Command;
use Flarum\Core\User;
use Flarum\User\User;
class DeleteTag
{

View File

@ -11,8 +11,8 @@
namespace Flarum\Tags\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Tags\TagRepository;
use Flarum\User\AssertPermissionTrait;
class DeleteTagHandler
{
@ -34,7 +34,7 @@ class DeleteTagHandler
/**
* @param DeleteTag $command
* @return \Flarum\Tags\Tag
* @throws \Flarum\Core\Exception\PermissionDeniedException
* @throws \Flarum\User\Exception\PermissionDeniedException
*/
public function handle(DeleteTag $command)
{

View File

@ -11,7 +11,7 @@
namespace Flarum\Tags\Command;
use Flarum\Core\User;
use Flarum\User\User;
class EditTag
{

View File

@ -11,10 +11,10 @@
namespace Flarum\Tags\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Tags\Event\TagWillBeSaved;
use Flarum\Tags\TagRepository;
use Flarum\Tags\TagValidator;
use Flarum\User\AssertPermissionTrait;
class EditTagHandler
{
@ -43,7 +43,7 @@ class EditTagHandler
/**
* @param EditTag $command
* @return \Flarum\Tags\Tag
* @throws \Flarum\Core\Exception\PermissionDeniedException
* @throws \Flarum\User\Exception\PermissionDeniedException
*/
public function handle(EditTag $command)
{

View File

@ -11,8 +11,8 @@
namespace Flarum\Tags\Event;
use Flarum\Core\Discussion;
use Flarum\Core\User;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWasTagged
{

View File

@ -11,8 +11,8 @@
namespace Flarum\Tags\Event;
use Flarum\Core\User;
use Flarum\Tags\Tag;
use Flarum\User\User;
class TagWillBeSaved
{

View File

@ -12,7 +12,7 @@
namespace Flarum\Tags\Listener;
use Flarum\Event\ConfigureForumRoutes;
use Flarum\Event\ConfigureWebApp;
use Flarum\Event\Rendering;
use Illuminate\Contracts\Events\Dispatcher;
class AddClientAssets
@ -22,14 +22,14 @@ class AddClientAssets
*/
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureWebApp::class, [$this, 'addAssets']);
$events->listen(Rendering::class, [$this, 'addAssets']);
$events->listen(ConfigureForumRoutes::class, [$this, 'addRoutes']);
}
/**
* @param ConfigureWebApp $app
* @param Rendering $app
*/
public function addAssets(ConfigureWebApp $app)
public function addAssets(Rendering $app)
{
if ($app->isForum()) {
$app->addAssets([

View File

@ -13,11 +13,11 @@ namespace Flarum\Tags\Listener;
use Flarum\Api\Controller;
use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Core\Discussion;
use Flarum\Event\ConfigureApiController;
use Flarum\Discussion\Discussion;
use Flarum\Event\GetApiRelationship;
use Flarum\Event\GetModelRelationship;
use Flarum\Event\PrepareApiAttributes;
use Flarum\Event\Serializing;
use Flarum\Event\WillGetData;
use Flarum\Tags\Tag;
use Illuminate\Contracts\Events\Dispatcher;
@ -30,8 +30,8 @@ class AddDiscussionTagsRelationship
{
$events->listen(GetModelRelationship::class, [$this, 'getModelRelationship']);
$events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
$events->listen(ConfigureApiController::class, [$this, 'includeTagsRelationship']);
$events->listen(PrepareApiAttributes::class, [$this, 'prepareApiAttributes']);
$events->listen(WillGetData::class, [$this, 'includeTagsRelationship']);
$events->listen(Serializing::class, [$this, 'prepareApiAttributes']);
}
/**
@ -57,9 +57,9 @@ class AddDiscussionTagsRelationship
}
/**
* @param ConfigureApiController $event
* @param WillGetData $event
*/
public function includeTagsRelationship(ConfigureApiController $event)
public function includeTagsRelationship(WillGetData $event)
{
if ($event->isController(Controller\ListDiscussionsController::class)
|| $event->isController(Controller\ShowDiscussionController::class)
@ -69,9 +69,9 @@ class AddDiscussionTagsRelationship
}
/**
* @param PrepareApiAttributes $event
* @param Serializing $event
*/
public function prepareApiAttributes(PrepareApiAttributes $event)
public function prepareApiAttributes(Serializing $event)
{
if ($event->isSerializer(DiscussionSerializer::class)) {
$event->attributes['canTag'] = $event->actor->can('tag', $event->model);

View File

@ -13,10 +13,10 @@ namespace Flarum\Tags\Listener;
use Flarum\Api\Controller\ShowForumController;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Event\ConfigureApiController;
use Flarum\Event\GetApiRelationship;
use Flarum\Event\PrepareApiAttributes;
use Flarum\Event\PrepareApiData;
use Flarum\Event\Serializing;
use Flarum\Event\WillGetData;
use Flarum\Event\WillSerializeData;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Tags\Tag;
use Illuminate\Contracts\Events\Dispatcher;
@ -42,9 +42,9 @@ class AddForumTagsRelationship
public function subscribe(Dispatcher $events)
{
$events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
$events->listen(PrepareApiData::class, [$this, 'loadTagsRelationship']);
$events->listen(ConfigureApiController::class, [$this, 'includeTagsRelationship']);
$events->listen(PrepareApiAttributes::class, [$this, 'prepareApiAttributes']);
$events->listen(WillSerializeData::class, [$this, 'loadTagsRelationship']);
$events->listen(WillGetData::class, [$this, 'includeTagsRelationship']);
$events->listen(Serializing::class, [$this, 'prepareApiAttributes']);
}
/**
@ -59,9 +59,9 @@ class AddForumTagsRelationship
}
/**
* @param PrepareApiData $event
* @param WillSerializeData $event
*/
public function loadTagsRelationship(PrepareApiData $event)
public function loadTagsRelationship(WillSerializeData $event)
{
// Expose the complete tag list to clients by adding it as a
// relationship to the /api/forum endpoint. Since the Forum model
@ -73,9 +73,9 @@ class AddForumTagsRelationship
}
/**
* @param ConfigureApiController $event
* @param WillGetData $event
*/
public function includeTagsRelationship(ConfigureApiController $event)
public function includeTagsRelationship(WillGetData $event)
{
if ($event->isController(ShowForumController::class)) {
$event->addInclude(['tags', 'tags.lastDiscussion', 'tags.parent']);
@ -83,9 +83,9 @@ class AddForumTagsRelationship
}
/**
* @param PrepareApiAttributes $event
* @param Serializing $event
*/
public function prepareApiAttributes(PrepareApiAttributes $event)
public function prepareApiAttributes(Serializing $event)
{
if ($event->isSerializer(ForumSerializer::class)) {
$event->attributes['minPrimaryTags'] = $this->settings->get('flarum-tags.min_primary_tags');

View File

@ -11,8 +11,8 @@
namespace Flarum\Tags\Listener;
use Flarum\Event\ConfigureDiscussionGambits;
use Flarum\Event\ConfigureDiscussionSearch;
use Flarum\Discussion\Event\ConfigureDiscussionGambits;
use Flarum\Discussion\Event\Searching;
use Flarum\Tags\Gambit\TagGambit;
use Flarum\Tags\Tag;
use Illuminate\Contracts\Events\Dispatcher;
@ -26,7 +26,7 @@ class FilterDiscussionListByTags
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureDiscussionGambits::class, [$this, 'addTagGambit']);
$events->listen(ConfigureDiscussionSearch::class, [$this, 'hideTagsFromDiscussionList']);
$events->listen(Searching::class, [$this, 'hideTagsFromDiscussionList']);
}
/**
@ -38,9 +38,9 @@ class FilterDiscussionListByTags
}
/**
* @param ConfigureDiscussionSearch $event
* @param Searching $event
*/
public function hideTagsFromDiscussionList(ConfigureDiscussionSearch $event)
public function hideTagsFromDiscussionList(Searching $event)
{
$query = $event->search->getQuery();

View File

@ -11,12 +11,12 @@
namespace Flarum\Tags\Listener;
use Flarum\Core\Exception\PermissionDeniedException;
use Flarum\Core\Exception\ValidationException;
use Flarum\Event\DiscussionWillBeSaved;
use Flarum\Discussion\Event\Saving;
use Flarum\Foundation\ValidationException;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Tags\Event\DiscussionWasTagged;
use Flarum\Tags\Tag;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Validation\Factory;
use Symfony\Component\Translation\TranslatorInterface;
@ -55,15 +55,15 @@ class SaveTagsToDatabase
*/
public function subscribe(Dispatcher $events)
{
$events->listen(DiscussionWillBeSaved::class, [$this, 'whenDiscussionWillBeSaved']);
$events->listen(Saving::class, [$this, 'whenDiscussionIsSaving']);
}
/**
* @param DiscussionWillBeSaved $event
* @param Saving $event
* @throws PermissionDeniedException
* @throws ValidationException
*/
public function whenDiscussionWillBeSaved(DiscussionWillBeSaved $event)
public function whenDiscussionIsSaving(Saving $event)
{
$discussion = $event->discussion;
$actor = $event->actor;

View File

@ -11,12 +11,12 @@
namespace Flarum\Tags\Listener;
use Flarum\Event\DiscussionWasDeleted;
use Flarum\Event\DiscussionWasStarted;
use Flarum\Event\PostWasDeleted;
use Flarum\Event\PostWasHidden;
use Flarum\Event\PostWasPosted;
use Flarum\Event\PostWasRestored;
use Flarum\Discussion\Event\Deleted;
use Flarum\Discussion\Event\Started;
use Flarum\Post\Event\Deleted as PostDeleted;
use Flarum\Post\Event\Hidden;
use Flarum\Post\Event\Posted;
use Flarum\Post\Event\Restored;
use Flarum\Tags\Event\DiscussionWasTagged;
use Flarum\Tags\Tag;
use Illuminate\Contracts\Events\Dispatcher;
@ -28,20 +28,20 @@ class UpdateTagMetadata
*/
public function subscribe(Dispatcher $events)
{
$events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']);
$events->listen(Started::class, [$this, 'whenDiscussionIsStarted']);
$events->listen(DiscussionWasTagged::class, [$this, 'whenDiscussionWasTagged']);
$events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']);
$events->listen(Deleted::class, [$this, 'whenDiscussionIsDeleted']);
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
$events->listen(Posted::class, [$this, 'whenPostIsPosted']);
$events->listen(PostDeleted::class, [$this, 'whenPostIsDeleted']);
$events->listen(Hidden::class, [$this, 'whenPostIsHidden']);
$events->listen(Restored::class, [$this, 'whenPostIsRestored']);
}
/**
* @param DiscussionWasStarted $event
* @param Started $event
*/
public function whenDiscussionWasStarted(DiscussionWasStarted $event)
public function whenDiscussionIsStarted(Started $event)
{
$this->updateTags($event->discussion, 1);
}
@ -58,9 +58,9 @@ class UpdateTagMetadata
}
/**
* @param DiscussionWasDeleted $event
* @param Deleted $event
*/
public function whenDiscussionWasDeleted(DiscussionWasDeleted $event)
public function whenDiscussionIsDeleted(Deleted $event)
{
$this->updateTags($event->discussion, -1);
@ -68,39 +68,39 @@ class UpdateTagMetadata
}
/**
* @param PostWasPosted $event
* @param Posted $event
*/
public function whenPostWasPosted(PostWasPosted $event)
public function whenPostIsPosted(Posted $event)
{
$this->updateTags($event->post->discussion);
}
/**
* @param PostWasDeleted $event
* @param Deleted $event
*/
public function whenPostWasDeleted(PostWasDeleted $event)
public function whenPostIsDeleted(PostDeleted $event)
{
$this->updateTags($event->post->discussion);
}
/**
* @param PostWasHidden $event
* @param Hidden $event
*/
public function whenPostWasHidden(PostWasHidden $event)
public function whenPostIsHidden(Hidden $event)
{
$this->updateTags($event->post->discussion);
}
/**
* @param PostWasRestored $event
* @param Restored $event
*/
public function whenPostWasRestored(PostWasRestored $event)
public function whenPostIsRestored(Restored $event)
{
$this->updateTags($event->post->discussion);
}
/**
* @param \Flarum\Core\Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param int $delta
* @param Tag[]|null $tags
*/

View File

@ -11,9 +11,9 @@
namespace Flarum\Tags\Post;
use Flarum\Core\Post;
use Flarum\Core\Post\AbstractEventPost;
use Flarum\Core\Post\MergeableInterface;
use Flarum\Post\Post;
use Flarum\Post\Post\AbstractEventPost;
use Flarum\Post\Post\MergeableInterface;
class DiscussionTaggedPost extends AbstractEventPost implements MergeableInterface
{

View File

@ -11,11 +11,11 @@
namespace Flarum\Tags;
use Flarum\Core\Discussion;
use Flarum\Core\Permission;
use Flarum\Core\Support\ScopeVisibilityTrait;
use Flarum\Core\User;
use Flarum\Database\AbstractModel;
use Flarum\Database\ScopeVisibilityTrait;
use Flarum\Discussion\Discussion;
use Flarum\Group\Permission;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
class Tag extends AbstractModel
@ -82,7 +82,7 @@ class Tag extends AbstractModel
*/
public function lastDiscussion()
{
return $this->belongsTo('Flarum\Core\Discussion', 'last_discussion_id');
return $this->belongsTo(Discussion::class, 'last_discussion_id');
}
/**
@ -90,7 +90,7 @@ class Tag extends AbstractModel
*/
public function discussions()
{
return $this->belongsToMany('Flarum\Core\Discussion', 'discussions_tags');
return $this->belongsToMany(Discussion::class, 'discussions_tags');
}
/**

View File

@ -11,7 +11,7 @@
namespace Flarum\Tags;
use Flarum\Core\User;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
class TagRepository

View File

@ -11,9 +11,9 @@
namespace Flarum\Tags;
use Flarum\Core\Support\EventGeneratorTrait;
use Flarum\Core\User;
use Flarum\Database\AbstractModel;
use Flarum\Foundation\EventGeneratorTrait;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
/**

View File

@ -11,7 +11,7 @@
namespace Flarum\Tags;
use Flarum\Core\Validator\AbstractValidator;
use Flarum\Foundation\AbstractValidator;
class TagValidator extends AbstractValidator
{