diff --git a/framework/core/src/Api/Controller/CreateDiscussionController.php b/framework/core/src/Api/Controller/CreateDiscussionController.php index 6c3c005e7..ab6eb9cde 100644 --- a/framework/core/src/Api/Controller/CreateDiscussionController.php +++ b/framework/core/src/Api/Controller/CreateDiscussionController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\ReadDiscussion; use Flarum\Core\Command\StartDiscussion; -use Flarum\Core\Post\Floodgate; +use Flarum\Post\Floodgate; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; diff --git a/framework/core/src/Api/Controller/CreatePostController.php b/framework/core/src/Api/Controller/CreatePostController.php index 16ba2a679..a268b7d21 100644 --- a/framework/core/src/Api/Controller/CreatePostController.php +++ b/framework/core/src/Api/Controller/CreatePostController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\PostReply; use Flarum\Core\Command\ReadDiscussion; -use Flarum\Core\Post\Floodgate; +use Flarum\Post\Floodgate; use Illuminate\Contracts\Bus\Dispatcher; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -41,13 +41,13 @@ class CreatePostController extends AbstractCreateController protected $bus; /** - * @var Floodgate + * @var \Flarum\Post\Floodgate */ protected $floodgate; /** * @param Dispatcher $bus - * @param Floodgate $floodgate + * @param \Flarum\Post\Floodgate $floodgate */ public function __construct(Dispatcher $bus, Floodgate $floodgate) { diff --git a/framework/core/src/Api/Controller/ListPostsController.php b/framework/core/src/Api/Controller/ListPostsController.php index c50490d07..071dbc41d 100644 --- a/framework/core/src/Api/Controller/ListPostsController.php +++ b/framework/core/src/Api/Controller/ListPostsController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\Event\ConfigurePostsQuery; use Illuminate\Database\Eloquent\Builder; use Psr\Http\Message\ServerRequestInterface; @@ -42,12 +42,12 @@ class ListPostsController extends AbstractListController public $sortFields = ['time']; /** - * @var \Flarum\Core\Repository\PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** - * @param \Flarum\Core\Repository\PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(PostRepository $posts) { diff --git a/framework/core/src/Api/Controller/ShowDiscussionController.php b/framework/core/src/Api/Controller/ShowDiscussionController.php index d3417ff8c..171ddc8e4 100644 --- a/framework/core/src/Api/Controller/ShowDiscussionController.php +++ b/framework/core/src/Api/Controller/ShowDiscussionController.php @@ -13,7 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Discussion; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\User\User; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -59,7 +59,7 @@ class ShowDiscussionController extends AbstractShowController /** * @param \Flarum\Core\Repository\DiscussionRepository $discussions - * @param \Flarum\Core\Repository\PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(DiscussionRepository $discussions, PostRepository $posts) { diff --git a/framework/core/src/Api/Controller/ShowPostController.php b/framework/core/src/Api/Controller/ShowPostController.php index 25e2f0e79..49a5f2dec 100644 --- a/framework/core/src/Api/Controller/ShowPostController.php +++ b/framework/core/src/Api/Controller/ShowPostController.php @@ -11,7 +11,7 @@ namespace Flarum\Api\Controller; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -34,12 +34,12 @@ class ShowPostController extends AbstractShowController ]; /** - * @var \Flarum\Core\Repository\PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** - * @param PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(PostRepository $posts) { diff --git a/framework/core/src/Api/ExceptionHandler/FloodingExceptionHandler.php b/framework/core/src/Api/ExceptionHandler/FloodingExceptionHandler.php index 53b6de082..0a55870dc 100644 --- a/framework/core/src/Api/ExceptionHandler/FloodingExceptionHandler.php +++ b/framework/core/src/Api/ExceptionHandler/FloodingExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Flarum\Core\Exception\FloodingException; +use Flarum\Post\Exception\FloodingException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; diff --git a/framework/core/src/Api/Serializer/BasicPostSerializer.php b/framework/core/src/Api/Serializer/BasicPostSerializer.php index 2988a6343..2e0a75951 100644 --- a/framework/core/src/Api/Serializer/BasicPostSerializer.php +++ b/framework/core/src/Api/Serializer/BasicPostSerializer.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Serializer; use Flarum\Core\Post; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use InvalidArgumentException; class BasicPostSerializer extends AbstractSerializer diff --git a/framework/core/src/Api/Serializer/PostSerializer.php b/framework/core/src/Api/Serializer/PostSerializer.php index e385b3533..9f22c5704 100644 --- a/framework/core/src/Api/Serializer/PostSerializer.php +++ b/framework/core/src/Api/Serializer/PostSerializer.php @@ -12,7 +12,7 @@ namespace Flarum\Api\Serializer; use Flarum\User\Gate; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; class PostSerializer extends BasicPostSerializer { diff --git a/framework/core/src/Core/Command/DeletePostHandler.php b/framework/core/src/Core/Command/DeletePostHandler.php index a616dbcc5..176aa5d3f 100644 --- a/framework/core/src/Core/Command/DeletePostHandler.php +++ b/framework/core/src/Core/Command/DeletePostHandler.php @@ -13,9 +13,9 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\User\Exception\PermissionDeniedException; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Event\PostWillBeDeleted; +use Flarum\Post\Event\Deleting; use Illuminate\Contracts\Events\Dispatcher; class DeletePostHandler @@ -24,13 +24,13 @@ class DeletePostHandler use AssertPermissionTrait; /** - * @var PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** * @param Dispatcher $events - * @param PostRepository $posts + * @param \Flarum\Post\PostRepository $posts */ public function __construct(Dispatcher $events, PostRepository $posts) { @@ -52,7 +52,7 @@ class DeletePostHandler $this->assertCan($actor, 'delete', $post); $this->events->fire( - new PostWillBeDeleted($post, $actor, $command->data) + new Deleting($post, $actor, $command->data) ); $post->delete(); diff --git a/framework/core/src/Core/Command/EditPostHandler.php b/framework/core/src/Core/Command/EditPostHandler.php index 65707e301..af0a52a45 100644 --- a/framework/core/src/Core/Command/EditPostHandler.php +++ b/framework/core/src/Core/Command/EditPostHandler.php @@ -12,11 +12,11 @@ namespace Flarum\Core\Command; use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Post\CommentPost; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\CommentPost; +use Flarum\Post\PostRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\PostValidator; -use Flarum\Event\PostWillBeSaved; +use Flarum\Post\PostValidator; +use Flarum\Post\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class EditPostHandler @@ -25,19 +25,19 @@ class EditPostHandler use AssertPermissionTrait; /** - * @var PostRepository + * @var \Flarum\Post\PostRepository */ protected $posts; /** - * @var PostValidator + * @var \Flarum\Post\PostValidator */ protected $validator; /** * @param Dispatcher $events * @param PostRepository $posts - * @param PostValidator $validator + * @param \Flarum\Post\PostValidator $validator */ public function __construct(Dispatcher $events, PostRepository $posts, PostValidator $validator) { @@ -79,7 +79,7 @@ class EditPostHandler } $this->events->fire( - new PostWillBeSaved($post, $actor, $data) + new Saving($post, $actor, $data) ); $this->validator->assertValid($post->getDirty()); diff --git a/framework/core/src/Core/Command/PostReplyHandler.php b/framework/core/src/Core/Command/PostReplyHandler.php index 260116bca..a6b327b6d 100644 --- a/framework/core/src/Core/Command/PostReplyHandler.php +++ b/framework/core/src/Core/Command/PostReplyHandler.php @@ -14,11 +14,11 @@ namespace Flarum\Core\Command; use DateTime; use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Notification\NotificationSyncer; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\Core\Repository\DiscussionRepository; use Flarum\Foundation\DispatchEventsTrait; -use Flarum\Core\Validator\PostValidator; -use Flarum\Event\PostWillBeSaved; +use Flarum\Post\PostValidator; +use Flarum\Post\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class PostReplyHandler @@ -37,7 +37,7 @@ class PostReplyHandler protected $notifications; /** - * @var PostValidator + * @var \Flarum\Post\PostValidator */ protected $validator; @@ -96,7 +96,7 @@ class PostReplyHandler } $this->events->fire( - new PostWillBeSaved($post, $actor, $command->data) + new Saving($post, $actor, $command->data) ); $this->validator->assertValid($post->getAttributes()); diff --git a/framework/core/src/Core/CoreServiceProvider.php b/framework/core/src/Core/CoreServiceProvider.php index d697aba1c..c3234f488 100644 --- a/framework/core/src/Core/CoreServiceProvider.php +++ b/framework/core/src/Core/CoreServiceProvider.php @@ -11,11 +11,12 @@ namespace Flarum\Core; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\Event\ConfigurePostTypes; use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\GetPermission; use Flarum\Foundation\AbstractServiceProvider; +use Flarum\Post\Post; use Flarum\User\Gate; use Flarum\User\User; use Illuminate\Contracts\Container\Container; @@ -114,7 +115,7 @@ class CoreServiceProvider extends AbstractServiceProvider $events->subscribe('Flarum\Core\Access\DiscussionPolicy'); $events->subscribe('Flarum\Core\Access\GroupPolicy'); - $events->subscribe('Flarum\Core\Access\PostPolicy'); + $events->subscribe('Flarum\Post\PostPolicy'); $events->subscribe('Flarum\User\UserPolicy'); $events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']); @@ -123,8 +124,8 @@ class CoreServiceProvider extends AbstractServiceProvider public function registerPostTypes() { $models = [ - 'Flarum\Core\Post\CommentPost', - 'Flarum\Core\Post\DiscussionRenamedPost' + 'Flarum\Post\Post\CommentPost', + 'Flarum\Post\Post\DiscussionRenamedPost' ]; $this->app->make('events')->fire( diff --git a/framework/core/src/Core/Discussion.php b/framework/core/src/Core/Discussion.php index f81ade832..d185e8440 100644 --- a/framework/core/src/Core/Discussion.php +++ b/framework/core/src/Core/Discussion.php @@ -11,7 +11,7 @@ namespace Flarum\Core; -use Flarum\Core\Post\MergeableInterface; +use Flarum\Post\MergeableInterface; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; @@ -20,8 +20,9 @@ use Flarum\Event\DiscussionWasHidden; use Flarum\Event\DiscussionWasRenamed; use Flarum\Event\DiscussionWasRestored; use Flarum\Event\DiscussionWasStarted; -use Flarum\Event\PostWasDeleted; +use Flarum\Post\Event\Deleted; use Flarum\Event\ScopePostVisibility; +use Flarum\Post\Post; use Flarum\User\Guest; use Flarum\User\User; use Flarum\Util\Str; @@ -109,7 +110,7 @@ class Discussion extends AbstractModel $posts = $discussion->posts()->allTypes(); foreach ($posts->get() as $post) { - $discussion->raise(new PostWasDeleted($post)); + $discussion->raise(new Deleted($post)); } $posts->delete(); @@ -272,7 +273,7 @@ class Discussion extends AbstractModel * DiscussionRenamedPost, and delete if the title has been reverted * completely.) * - * @param MergeableInterface $post The post to save. + * @param \Flarum\Post\MergeableInterface $post The post to save. * @return Post The resulting post. It may or may not be the same post as * was originally intended to be saved. It also may not exist, if the * merge logic resulted in deletion. @@ -303,7 +304,7 @@ class Discussion extends AbstractModel */ public function posts() { - return $this->hasMany('Flarum\Core\Post'); + return $this->hasMany('Flarum\Post\Post'); } /** @@ -355,7 +356,7 @@ class Discussion extends AbstractModel */ public function startPost() { - return $this->belongsTo('Flarum\Core\Post', 'start_post_id'); + return $this->belongsTo('Flarum\Post\Post', 'start_post_id'); } /** @@ -375,7 +376,7 @@ class Discussion extends AbstractModel */ public function lastPost() { - return $this->belongsTo('Flarum\Core\Post', 'last_post_id'); + return $this->belongsTo('Flarum\Post\Post', 'last_post_id'); } /** diff --git a/framework/core/src/Core/Listener/DiscussionMetadataUpdater.php b/framework/core/src/Core/Listener/DiscussionMetadataUpdater.php index b715e08ae..ea05dba72 100755 --- a/framework/core/src/Core/Listener/DiscussionMetadataUpdater.php +++ b/framework/core/src/Core/Listener/DiscussionMetadataUpdater.php @@ -11,11 +11,11 @@ namespace Flarum\Core\Listener; -use Flarum\Core\Post; -use Flarum\Event\PostWasDeleted; -use Flarum\Event\PostWasHidden; -use Flarum\Event\PostWasPosted; -use Flarum\Event\PostWasRestored; +use Flarum\Post\Post; +use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Hidden; +use Flarum\Post\Event\Posted; +use Flarum\Post\Event\Restored; use Illuminate\Contracts\Events\Dispatcher; class DiscussionMetadataUpdater @@ -25,16 +25,16 @@ class DiscussionMetadataUpdater */ public function subscribe(Dispatcher $events) { - $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, 'whenPostWasPosted']); + $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']); + $events->listen(Hidden::class, [$this, 'whenPostWasHidden']); + $events->listen(Restored::class, [$this, 'whenPostWasRestored']); } /** - * @param PostWasPosted $event + * @param Posted $event */ - public function whenPostWasPosted(PostWasPosted $event) + public function whenPostWasPosted(Posted $event) { $discussion = $event->post->discussion; @@ -47,9 +47,9 @@ class DiscussionMetadataUpdater } /** - * @param \Flarum\Event\PostWasDeleted $event + * @param \Flarum\Post\Event\Deleted $event */ - public function whenPostWasDeleted(PostWasDeleted $event) + public function whenPostWasDeleted(Deleted $event) { $this->removePost($event->post); @@ -61,17 +61,17 @@ class DiscussionMetadataUpdater } /** - * @param PostWasHidden $event + * @param \Flarum\Post\Event\Hidden $event */ - public function whenPostWasHidden(PostWasHidden $event) + public function whenPostWasHidden(Hidden $event) { $this->removePost($event->post); } /** - * @param PostWasRestored $event + * @param Restored $event */ - public function whenPostWasRestored(PostWasRestored $event) + public function whenPostWasRestored(Restored $event) { $discussion = $event->post->discussion; diff --git a/framework/core/src/Core/Listener/DiscussionRenamedNotifier.php b/framework/core/src/Core/Listener/DiscussionRenamedNotifier.php index 61d212d20..1357b1948 100755 --- a/framework/core/src/Core/Listener/DiscussionRenamedNotifier.php +++ b/framework/core/src/Core/Listener/DiscussionRenamedNotifier.php @@ -13,7 +13,7 @@ namespace Flarum\Core\Listener; use Flarum\Core\Notification\DiscussionRenamedBlueprint; use Flarum\Core\Notification\NotificationSyncer; -use Flarum\Core\Post\DiscussionRenamedPost; +use Flarum\Post\DiscussionRenamedPost; use Flarum\Event\DiscussionWasRenamed; use Illuminate\Contracts\Events\Dispatcher; diff --git a/framework/core/src/Core/Notification/DiscussionRenamedBlueprint.php b/framework/core/src/Core/Notification/DiscussionRenamedBlueprint.php index 5a19d8c7b..b47cac1f9 100644 --- a/framework/core/src/Core/Notification/DiscussionRenamedBlueprint.php +++ b/framework/core/src/Core/Notification/DiscussionRenamedBlueprint.php @@ -11,12 +11,12 @@ namespace Flarum\Core\Notification; -use Flarum\Core\Post\DiscussionRenamedPost; +use Flarum\Post\DiscussionRenamedPost; class DiscussionRenamedBlueprint implements BlueprintInterface { /** - * @var DiscussionRenamedPost + * @var \Flarum\Post\DiscussionRenamedPost */ protected $post; diff --git a/framework/core/src/Core/Search/Discussion/DiscussionSearcher.php b/framework/core/src/Core/Search/Discussion/DiscussionSearcher.php index b85df3f52..f606d99c2 100644 --- a/framework/core/src/Core/Search/Discussion/DiscussionSearcher.php +++ b/framework/core/src/Core/Search/Discussion/DiscussionSearcher.php @@ -13,7 +13,7 @@ namespace Flarum\Core\Search\Discussion; use Flarum\Core\Discussion; use Flarum\Core\Repository\DiscussionRepository; -use Flarum\Core\Repository\PostRepository; +use Flarum\Post\PostRepository; use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\GambitManager; use Flarum\Core\Search\SearchCriteria; diff --git a/framework/core/src/Core/Post/AbstractEventPost.php b/framework/core/src/Post/AbstractEventPost.php similarity index 93% rename from framework/core/src/Core/Post/AbstractEventPost.php rename to framework/core/src/Post/AbstractEventPost.php index 10d242750..0e949c963 100755 --- a/framework/core/src/Core/Post/AbstractEventPost.php +++ b/framework/core/src/Post/AbstractEventPost.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; - -use Flarum\Core\Post; +namespace Flarum\Post; abstract class AbstractEventPost extends Post { diff --git a/framework/core/src/Core/Post/CommentPost.php b/framework/core/src/Post/CommentPost.php similarity index 90% rename from framework/core/src/Core/Post/CommentPost.php rename to framework/core/src/Post/CommentPost.php index a8016cbb2..e42403b7e 100755 --- a/framework/core/src/Core/Post/CommentPost.php +++ b/framework/core/src/Post/CommentPost.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; +namespace Flarum\Post; -use Flarum\Core\Post; -use Flarum\Event\PostWasHidden; -use Flarum\Event\PostWasPosted; -use Flarum\Event\PostWasRestored; -use Flarum\Event\PostWasRevised; +use Flarum\Post\Event\Hidden; +use Flarum\Post\Event\Posted; +use Flarum\Post\Event\Restored; +use Flarum\Post\Event\Revised; use Flarum\Formatter\Formatter; use Flarum\User\User; @@ -61,7 +60,7 @@ class CommentPost extends Post // Set content last, as the parsing may rely on other post attributes. $post->content = $content; - $post->raise(new PostWasPosted($post)); + $post->raise(new Posted($post)); return $post; } @@ -81,7 +80,7 @@ class CommentPost extends Post $this->edit_time = time(); $this->edit_user_id = $actor->id; - $this->raise(new PostWasRevised($this)); + $this->raise(new Revised($this)); } return $this; @@ -99,7 +98,7 @@ class CommentPost extends Post $this->hide_time = time(); $this->hide_user_id = $actor ? $actor->id : null; - $this->raise(new PostWasHidden($this)); + $this->raise(new Hidden($this)); } return $this; @@ -116,7 +115,7 @@ class CommentPost extends Post $this->hide_time = null; $this->hide_user_id = null; - $this->raise(new PostWasRestored($this)); + $this->raise(new Restored($this)); } return $this; diff --git a/framework/core/src/Core/Post/DiscussionRenamedPost.php b/framework/core/src/Post/DiscussionRenamedPost.php similarity index 97% rename from framework/core/src/Core/Post/DiscussionRenamedPost.php rename to framework/core/src/Post/DiscussionRenamedPost.php index 75cb3f764..21243d902 100755 --- a/framework/core/src/Core/Post/DiscussionRenamedPost.php +++ b/framework/core/src/Post/DiscussionRenamedPost.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; - -use Flarum\Core\Post; +namespace Flarum\Post; /** * A post which indicates that a discussion's title was changed. diff --git a/framework/core/src/Event/PostWasPosted.php b/framework/core/src/Post/Event/Deleted.php similarity index 78% rename from framework/core/src/Event/PostWasPosted.php rename to framework/core/src/Post/Event/Deleted.php index e59bcc0dc..4fba65f8c 100644 --- a/framework/core/src/Event/PostWasPosted.php +++ b/framework/core/src/Post/Event/Deleted.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWasPosted +class Deleted { /** - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -27,7 +27,7 @@ class PostWasPosted public $actor; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post */ public function __construct(Post $post, User $actor = null) { diff --git a/framework/core/src/Event/PostWillBeDeleted.php b/framework/core/src/Post/Event/Deleting.php similarity index 85% rename from framework/core/src/Event/PostWillBeDeleted.php rename to framework/core/src/Post/Event/Deleting.php index d5b32cae6..899b17997 100644 --- a/framework/core/src/Event/PostWillBeDeleted.php +++ b/framework/core/src/Post/Event/Deleting.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWillBeDeleted +class Deleting { /** * The post that is going to be deleted. * - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -38,7 +38,7 @@ class PostWillBeDeleted public $data; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post * @param User $actor * @param array $data */ diff --git a/framework/core/src/Event/PostWasHidden.php b/framework/core/src/Post/Event/Hidden.php similarity index 87% rename from framework/core/src/Event/PostWasHidden.php rename to framework/core/src/Post/Event/Hidden.php index e41a6a7b3..aeeb104e3 100644 --- a/framework/core/src/Event/PostWasHidden.php +++ b/framework/core/src/Post/Event/Hidden.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\User\User; -class PostWasHidden +class Hidden { /** * @var CommentPost diff --git a/framework/core/src/Event/PostWasDeleted.php b/framework/core/src/Post/Event/Posted.php similarity index 78% rename from framework/core/src/Event/PostWasDeleted.php rename to framework/core/src/Post/Event/Posted.php index c98fdb373..9b6ab19c8 100644 --- a/framework/core/src/Event/PostWasDeleted.php +++ b/framework/core/src/Post/Event/Posted.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWasDeleted +class Posted { /** - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -27,7 +27,7 @@ class PostWasDeleted public $actor; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post */ public function __construct(Post $post, User $actor = null) { diff --git a/framework/core/src/Event/PostWasRestored.php b/framework/core/src/Post/Event/Restored.php similarity index 76% rename from framework/core/src/Event/PostWasRestored.php rename to framework/core/src/Post/Event/Restored.php index 581a6b601..fdd5dc4ae 100644 --- a/framework/core/src/Event/PostWasRestored.php +++ b/framework/core/src/Post/Event/Restored.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\User\User; -class PostWasRestored +class Restored { /** - * @var CommentPost + * @var \Flarum\Post\CommentPost */ public $post; @@ -27,7 +27,7 @@ class PostWasRestored public $actor; /** - * @param CommentPost $post + * @param \Flarum\Post\CommentPost $post */ public function __construct(CommentPost $post, User $actor = null) { diff --git a/framework/core/src/Event/PostWasRevised.php b/framework/core/src/Post/Event/Revised.php similarity index 76% rename from framework/core/src/Event/PostWasRevised.php rename to framework/core/src/Post/Event/Revised.php index ddfd2afa0..62d602e0e 100644 --- a/framework/core/src/Event/PostWasRevised.php +++ b/framework/core/src/Post/Event/Revised.php @@ -9,15 +9,15 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post\CommentPost; +use Flarum\Post\CommentPost; use Flarum\User\User; -class PostWasRevised +class Revised { /** - * @var CommentPost + * @var \Flarum\Post\CommentPost */ public $post; @@ -27,7 +27,7 @@ class PostWasRevised public $actor; /** - * @param CommentPost $post + * @param \Flarum\Post\CommentPost $post */ public function __construct(CommentPost $post, User $actor = null) { diff --git a/framework/core/src/Event/PostWillBeSaved.php b/framework/core/src/Post/Event/Saving.php similarity index 85% rename from framework/core/src/Event/PostWillBeSaved.php rename to framework/core/src/Post/Event/Saving.php index fb1736ab0..f9d2092ea 100644 --- a/framework/core/src/Event/PostWillBeSaved.php +++ b/framework/core/src/Post/Event/Saving.php @@ -9,17 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Event; +namespace Flarum\Post\Event; -use Flarum\Core\Post; +use Flarum\Post\Post; use Flarum\User\User; -class PostWillBeSaved +class Saving { /** * The post that will be saved. * - * @var \Flarum\Core\Post + * @var \Flarum\Post\Post */ public $post; @@ -38,7 +38,7 @@ class PostWillBeSaved public $data; /** - * @param \Flarum\Core\Post $post + * @param \Flarum\Post\Post $post * @param User $actor * @param array $data */ diff --git a/framework/core/src/Core/Exception/FloodingException.php b/framework/core/src/Post/Exception/FloodingException.php similarity index 89% rename from framework/core/src/Core/Exception/FloodingException.php rename to framework/core/src/Post/Exception/FloodingException.php index 9174539b8..f9221b934 100644 --- a/framework/core/src/Core/Exception/FloodingException.php +++ b/framework/core/src/Post/Exception/FloodingException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Exception; +namespace Flarum\Post\Exception; use Exception; diff --git a/framework/core/src/Core/Post/Floodgate.php b/framework/core/src/Post/Floodgate.php similarity index 84% rename from framework/core/src/Core/Post/Floodgate.php rename to framework/core/src/Post/Floodgate.php index a62811fb1..94cc66d79 100644 --- a/framework/core/src/Core/Post/Floodgate.php +++ b/framework/core/src/Post/Floodgate.php @@ -9,18 +9,17 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; +namespace Flarum\Post; use DateTime; -use Flarum\Core\Exception\FloodingException; -use Flarum\Core\Post; +use Flarum\Post\Exception\FloodingException; use Flarum\User\User; class Floodgate { /** * @param User $actor - * @throws FloodingException + * @throws \Flarum\Post\Exception\FloodingException */ public function assertNotFlooding(User $actor) { diff --git a/framework/core/src/Core/Post/MergeableInterface.php b/framework/core/src/Post/MergeableInterface.php similarity index 91% rename from framework/core/src/Core/Post/MergeableInterface.php rename to framework/core/src/Post/MergeableInterface.php index e1932522e..ea85bca29 100644 --- a/framework/core/src/Core/Post/MergeableInterface.php +++ b/framework/core/src/Post/MergeableInterface.php @@ -9,9 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; - -use Flarum\Core\Post; +namespace Flarum\Post; /** * A post that has the ability to be merged into an adjacent post. @@ -26,7 +24,7 @@ interface MergeableInterface * Save the model, given that it is going to appear immediately after the * passed model. * - * @param Post|null $previous + * @param \Flarum\Post\Post|null $previous * @return Post The model resulting after the merge. If the merge is * unsuccessful, this should be the current model instance. Otherwise, * it should be the model that was merged into. diff --git a/framework/core/src/Core/Post.php b/framework/core/src/Post/Post.php similarity index 97% rename from framework/core/src/Core/Post.php rename to framework/core/src/Post/Post.php index bb5f0e731..ab081b6a6 100755 --- a/framework/core/src/Core/Post.php +++ b/framework/core/src/Post/Post.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Flarum\Core; +namespace Flarum\Post; -use Flarum\Core\Post\RegisteredTypesScope; +use Flarum\Core\User; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; -use Flarum\Event\PostWasDeleted; +use Flarum\Post\Event\Deleted; use Illuminate\Database\Eloquent\Builder; /** @@ -97,7 +97,7 @@ class Post extends AbstractModel }); static::deleted(function (Post $post) { - $post->raise(new PostWasDeleted($post)); + $post->raise(new Deleted($post)); }); static::addGlobalScope(new RegisteredTypesScope); diff --git a/framework/core/src/Core/Access/PostPolicy.php b/framework/core/src/Post/PostPolicy.php similarity index 97% rename from framework/core/src/Core/Access/PostPolicy.php rename to framework/core/src/Post/PostPolicy.php index 9e6f5829b..bc63b7ebc 100644 --- a/framework/core/src/Core/Access/PostPolicy.php +++ b/framework/core/src/Post/PostPolicy.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Access; +namespace Flarum\Post; use Carbon\Carbon; -use Flarum\Core\Post; use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePrivatePostVisibility; use Flarum\Settings\SettingsRepositoryInterface; @@ -58,7 +57,7 @@ class PostPolicy extends AbstractPolicy /** * @param User $actor * @param string $ability - * @param Post $post + * @param \Flarum\Post\Post $post * @return bool|null */ public function after(User $actor, $ability, Post $post) diff --git a/framework/core/src/Core/Repository/PostRepository.php b/framework/core/src/Post/PostRepository.php similarity index 98% rename from framework/core/src/Core/Repository/PostRepository.php rename to framework/core/src/Post/PostRepository.php index df296e358..b9560be91 100644 --- a/framework/core/src/Core/Repository/PostRepository.php +++ b/framework/core/src/Post/PostRepository.php @@ -9,10 +9,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Repository; +namespace Flarum\Post; use Flarum\Core\Discussion; -use Flarum\Core\Post; use Flarum\Event\ScopePostVisibility; use Flarum\User\User; use Illuminate\Database\Eloquent\ModelNotFoundException; diff --git a/framework/core/src/Core/Validator/PostValidator.php b/framework/core/src/Post/PostValidator.php similarity index 92% rename from framework/core/src/Core/Validator/PostValidator.php rename to framework/core/src/Post/PostValidator.php index 87142c9fd..0306b592f 100644 --- a/framework/core/src/Core/Validator/PostValidator.php +++ b/framework/core/src/Post/PostValidator.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Validator; +namespace Flarum\Post; use Flarum\Foundation\AbstractValidator; diff --git a/framework/core/src/Core/Post/RegisteredTypesScope.php b/framework/core/src/Post/RegisteredTypesScope.php similarity index 98% rename from framework/core/src/Core/Post/RegisteredTypesScope.php rename to framework/core/src/Post/RegisteredTypesScope.php index 35dd977e8..e18945259 100644 --- a/framework/core/src/Core/Post/RegisteredTypesScope.php +++ b/framework/core/src/Post/RegisteredTypesScope.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Core\Post; +namespace Flarum\Post; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; diff --git a/framework/core/src/User/User.php b/framework/core/src/User/User.php index 9849b2d88..dfb81d60d 100755 --- a/framework/core/src/User/User.php +++ b/framework/core/src/User/User.php @@ -21,7 +21,7 @@ use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\AbstractModel; use Flarum\Event\CheckUserPassword; use Flarum\Event\ConfigureUserPreferences; -use Flarum\Event\PostWasDeleted; +use Flarum\Post\Event\Deleted; use Flarum\Event\PrepareUserGroups; use Flarum\User\Event\AvatarChanged; use Flarum\User\Event\BioChanged; @@ -136,7 +136,7 @@ class User extends AbstractModel $posts = $user->posts()->allTypes(); foreach ($posts->get() as $post) { - $user->raise(new PostWasDeleted($post)); + $user->raise(new Deleted($post)); } $posts->delete(); @@ -603,7 +603,7 @@ class User extends AbstractModel */ public function posts() { - return $this->hasMany('Flarum\Core\Post'); + return $this->hasMany('Flarum\Post\Post'); } /** diff --git a/framework/core/src/User/UserMetadataUpdater.php b/framework/core/src/User/UserMetadataUpdater.php index 3d5e9ad5b..3e8af5404 100755 --- a/framework/core/src/User/UserMetadataUpdater.php +++ b/framework/core/src/User/UserMetadataUpdater.php @@ -15,10 +15,10 @@ use Flarum\Core\Discussion; use Flarum\Core\Post; 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\Post\Event\Deleted; +use Flarum\Post\Event\Hidden; +use Flarum\Post\Event\Posted; +use Flarum\Post\Event\Restored; use Illuminate\Contracts\Events\Dispatcher; class UserMetadataUpdater @@ -28,42 +28,42 @@ class UserMetadataUpdater */ public function subscribe(Dispatcher $events) { - $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, 'whenPostWasPosted']); + $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']); + $events->listen(Hidden::class, [$this, 'whenPostWasHidden']); + $events->listen(Restored::class, [$this, 'whenPostWasRestored']); $events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']); $events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']); } /** - * @param PostWasPosted $event + * @param \Flarum\Post\Event\Posted $event */ - public function whenPostWasPosted(PostWasPosted $event) + public function whenPostWasPosted(Posted $event) { $this->updateCommentsCount($event->post, 1); } /** - * @param \Flarum\Event\PostWasDeleted $event + * @param \Flarum\Post\Event\Deleted $event */ - public function whenPostWasDeleted(PostWasDeleted $event) + public function whenPostWasDeleted(Deleted $event) { $this->updateCommentsCount($event->post, -1); } /** - * @param PostWasHidden $event + * @param \Flarum\Post\Event\Hidden $event */ - public function whenPostWasHidden(PostWasHidden $event) + public function whenPostWasHidden(Hidden $event) { $this->updateCommentsCount($event->post, -1); } /** - * @param \Flarum\Event\PostWasRestored $event + * @param \Flarum\Post\Event\Restored $event */ - public function whenPostWasRestored(PostWasRestored $event) + public function whenPostWasRestored(Restored $event) { $this->updateCommentsCount($event->post, 1); } diff --git a/framework/core/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php b/framework/core/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php index 6a70a96bc..3abfbeade 100644 --- a/framework/core/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php +++ b/framework/core/tests/Flarum/Api/Handler/FloodingExceptionHandlerTest.php @@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\FloodingExceptionHandler; -use Flarum\Core\Exception\FloodingException; +use Flarum\Post\Exception\FloodingException; use Tests\Test\TestCase; class FloodingExceptionHandlerTest extends TestCase