1
0
mirror of https://github.com/flarum/core.git synced 2025-07-18 23:31:17 +02:00

Extract new Flarum\Post namespace

This commit is contained in:
Franz Liedke
2017-06-24 13:43:33 +02:00
parent 02a5b65d08
commit aaa04e2e13
38 changed files with 146 additions and 154 deletions

View File

@@ -13,7 +13,7 @@ namespace Flarum\Api\Controller;
use Flarum\Core\Command\ReadDiscussion; use Flarum\Core\Command\ReadDiscussion;
use Flarum\Core\Command\StartDiscussion; use Flarum\Core\Command\StartDiscussion;
use Flarum\Core\Post\Floodgate; use Flarum\Post\Floodgate;
use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;

View File

@@ -13,7 +13,7 @@ namespace Flarum\Api\Controller;
use Flarum\Core\Command\PostReply; use Flarum\Core\Command\PostReply;
use Flarum\Core\Command\ReadDiscussion; use Flarum\Core\Command\ReadDiscussion;
use Flarum\Core\Post\Floodgate; use Flarum\Post\Floodgate;
use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;
@@ -41,13 +41,13 @@ class CreatePostController extends AbstractCreateController
protected $bus; protected $bus;
/** /**
* @var Floodgate * @var \Flarum\Post\Floodgate
*/ */
protected $floodgate; protected $floodgate;
/** /**
* @param Dispatcher $bus * @param Dispatcher $bus
* @param Floodgate $floodgate * @param \Flarum\Post\Floodgate $floodgate
*/ */
public function __construct(Dispatcher $bus, Floodgate $floodgate) public function __construct(Dispatcher $bus, Floodgate $floodgate)
{ {

View File

@@ -11,7 +11,7 @@
namespace Flarum\Api\Controller; namespace Flarum\Api\Controller;
use Flarum\Core\Repository\PostRepository; use Flarum\Post\PostRepository;
use Flarum\Event\ConfigurePostsQuery; use Flarum\Event\ConfigurePostsQuery;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
@@ -42,12 +42,12 @@ class ListPostsController extends AbstractListController
public $sortFields = ['time']; public $sortFields = ['time'];
/** /**
* @var \Flarum\Core\Repository\PostRepository * @var \Flarum\Post\PostRepository
*/ */
protected $posts; protected $posts;
/** /**
* @param \Flarum\Core\Repository\PostRepository $posts * @param \Flarum\Post\PostRepository $posts
*/ */
public function __construct(PostRepository $posts) public function __construct(PostRepository $posts)
{ {

View File

@@ -13,7 +13,7 @@ namespace Flarum\Api\Controller;
use Flarum\Core\Discussion; use Flarum\Core\Discussion;
use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Core\Repository\PostRepository; use Flarum\Post\PostRepository;
use Flarum\User\User; use Flarum\User\User;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;
@@ -59,7 +59,7 @@ class ShowDiscussionController extends AbstractShowController
/** /**
* @param \Flarum\Core\Repository\DiscussionRepository $discussions * @param \Flarum\Core\Repository\DiscussionRepository $discussions
* @param \Flarum\Core\Repository\PostRepository $posts * @param \Flarum\Post\PostRepository $posts
*/ */
public function __construct(DiscussionRepository $discussions, PostRepository $posts) public function __construct(DiscussionRepository $discussions, PostRepository $posts)
{ {

View File

@@ -11,7 +11,7 @@
namespace Flarum\Api\Controller; namespace Flarum\Api\Controller;
use Flarum\Core\Repository\PostRepository; use Flarum\Post\PostRepository;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;
@@ -34,12 +34,12 @@ class ShowPostController extends AbstractShowController
]; ];
/** /**
* @var \Flarum\Core\Repository\PostRepository * @var \Flarum\Post\PostRepository
*/ */
protected $posts; protected $posts;
/** /**
* @param PostRepository $posts * @param \Flarum\Post\PostRepository $posts
*/ */
public function __construct(PostRepository $posts) public function __construct(PostRepository $posts)
{ {

View File

@@ -12,7 +12,7 @@
namespace Flarum\Api\ExceptionHandler; namespace Flarum\Api\ExceptionHandler;
use Exception; use Exception;
use Flarum\Core\Exception\FloodingException; use Flarum\Post\Exception\FloodingException;
use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface;
use Tobscure\JsonApi\Exception\Handler\ResponseBag; use Tobscure\JsonApi\Exception\Handler\ResponseBag;

View File

@@ -12,7 +12,7 @@
namespace Flarum\Api\Serializer; namespace Flarum\Api\Serializer;
use Flarum\Core\Post; use Flarum\Core\Post;
use Flarum\Core\Post\CommentPost; use Flarum\Post\CommentPost;
use InvalidArgumentException; use InvalidArgumentException;
class BasicPostSerializer extends AbstractSerializer class BasicPostSerializer extends AbstractSerializer

View File

@@ -12,7 +12,7 @@
namespace Flarum\Api\Serializer; namespace Flarum\Api\Serializer;
use Flarum\User\Gate; use Flarum\User\Gate;
use Flarum\Core\Post\CommentPost; use Flarum\Post\CommentPost;
class PostSerializer extends BasicPostSerializer class PostSerializer extends BasicPostSerializer
{ {

View File

@@ -13,9 +13,9 @@ namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\User\Exception\PermissionDeniedException; use Flarum\User\Exception\PermissionDeniedException;
use Flarum\Core\Repository\PostRepository; use Flarum\Post\PostRepository;
use Flarum\Foundation\DispatchEventsTrait; use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Event\PostWillBeDeleted; use Flarum\Post\Event\Deleting;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class DeletePostHandler class DeletePostHandler
@@ -24,13 +24,13 @@ class DeletePostHandler
use AssertPermissionTrait; use AssertPermissionTrait;
/** /**
* @var PostRepository * @var \Flarum\Post\PostRepository
*/ */
protected $posts; protected $posts;
/** /**
* @param Dispatcher $events * @param Dispatcher $events
* @param PostRepository $posts * @param \Flarum\Post\PostRepository $posts
*/ */
public function __construct(Dispatcher $events, PostRepository $posts) public function __construct(Dispatcher $events, PostRepository $posts)
{ {
@@ -52,7 +52,7 @@ class DeletePostHandler
$this->assertCan($actor, 'delete', $post); $this->assertCan($actor, 'delete', $post);
$this->events->fire( $this->events->fire(
new PostWillBeDeleted($post, $actor, $command->data) new Deleting($post, $actor, $command->data)
); );
$post->delete(); $post->delete();

View File

@@ -12,11 +12,11 @@
namespace Flarum\Core\Command; namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Post\CommentPost; use Flarum\Post\CommentPost;
use Flarum\Core\Repository\PostRepository; use Flarum\Post\PostRepository;
use Flarum\Foundation\DispatchEventsTrait; use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Core\Validator\PostValidator; use Flarum\Post\PostValidator;
use Flarum\Event\PostWillBeSaved; use Flarum\Post\Event\Saving;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class EditPostHandler class EditPostHandler
@@ -25,19 +25,19 @@ class EditPostHandler
use AssertPermissionTrait; use AssertPermissionTrait;
/** /**
* @var PostRepository * @var \Flarum\Post\PostRepository
*/ */
protected $posts; protected $posts;
/** /**
* @var PostValidator * @var \Flarum\Post\PostValidator
*/ */
protected $validator; protected $validator;
/** /**
* @param Dispatcher $events * @param Dispatcher $events
* @param PostRepository $posts * @param PostRepository $posts
* @param PostValidator $validator * @param \Flarum\Post\PostValidator $validator
*/ */
public function __construct(Dispatcher $events, PostRepository $posts, PostValidator $validator) public function __construct(Dispatcher $events, PostRepository $posts, PostValidator $validator)
{ {
@@ -79,7 +79,7 @@ class EditPostHandler
} }
$this->events->fire( $this->events->fire(
new PostWillBeSaved($post, $actor, $data) new Saving($post, $actor, $data)
); );
$this->validator->assertValid($post->getDirty()); $this->validator->assertValid($post->getDirty());

View File

@@ -14,11 +14,11 @@ namespace Flarum\Core\Command;
use DateTime; use DateTime;
use Flarum\Core\Access\AssertPermissionTrait; use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Notification\NotificationSyncer; use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Core\Post\CommentPost; use Flarum\Post\CommentPost;
use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Foundation\DispatchEventsTrait; use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Core\Validator\PostValidator; use Flarum\Post\PostValidator;
use Flarum\Event\PostWillBeSaved; use Flarum\Post\Event\Saving;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class PostReplyHandler class PostReplyHandler
@@ -37,7 +37,7 @@ class PostReplyHandler
protected $notifications; protected $notifications;
/** /**
* @var PostValidator * @var \Flarum\Post\PostValidator
*/ */
protected $validator; protected $validator;
@@ -96,7 +96,7 @@ class PostReplyHandler
} }
$this->events->fire( $this->events->fire(
new PostWillBeSaved($post, $actor, $command->data) new Saving($post, $actor, $command->data)
); );
$this->validator->assertValid($post->getAttributes()); $this->validator->assertValid($post->getAttributes());

View File

@@ -11,11 +11,12 @@
namespace Flarum\Core; namespace Flarum\Core;
use Flarum\Core\Post\CommentPost; use Flarum\Post\CommentPost;
use Flarum\Event\ConfigurePostTypes; use Flarum\Event\ConfigurePostTypes;
use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\ConfigureUserPreferences;
use Flarum\Event\GetPermission; use Flarum\Event\GetPermission;
use Flarum\Foundation\AbstractServiceProvider; use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Post\Post;
use Flarum\User\Gate; use Flarum\User\Gate;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;
@@ -114,7 +115,7 @@ class CoreServiceProvider extends AbstractServiceProvider
$events->subscribe('Flarum\Core\Access\DiscussionPolicy'); $events->subscribe('Flarum\Core\Access\DiscussionPolicy');
$events->subscribe('Flarum\Core\Access\GroupPolicy'); $events->subscribe('Flarum\Core\Access\GroupPolicy');
$events->subscribe('Flarum\Core\Access\PostPolicy'); $events->subscribe('Flarum\Post\PostPolicy');
$events->subscribe('Flarum\User\UserPolicy'); $events->subscribe('Flarum\User\UserPolicy');
$events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']); $events->listen(ConfigureUserPreferences::class, [$this, 'configureUserPreferences']);
@@ -123,8 +124,8 @@ class CoreServiceProvider extends AbstractServiceProvider
public function registerPostTypes() public function registerPostTypes()
{ {
$models = [ $models = [
'Flarum\Core\Post\CommentPost', 'Flarum\Post\Post\CommentPost',
'Flarum\Core\Post\DiscussionRenamedPost' 'Flarum\Post\Post\DiscussionRenamedPost'
]; ];
$this->app->make('events')->fire( $this->app->make('events')->fire(

View File

@@ -11,7 +11,7 @@
namespace Flarum\Core; namespace Flarum\Core;
use Flarum\Core\Post\MergeableInterface; use Flarum\Post\MergeableInterface;
use Flarum\Foundation\EventGeneratorTrait; use Flarum\Foundation\EventGeneratorTrait;
use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\ScopeVisibilityTrait;
use Flarum\Database\AbstractModel; use Flarum\Database\AbstractModel;
@@ -20,8 +20,9 @@ use Flarum\Event\DiscussionWasHidden;
use Flarum\Event\DiscussionWasRenamed; use Flarum\Event\DiscussionWasRenamed;
use Flarum\Event\DiscussionWasRestored; use Flarum\Event\DiscussionWasRestored;
use Flarum\Event\DiscussionWasStarted; use Flarum\Event\DiscussionWasStarted;
use Flarum\Event\PostWasDeleted; use Flarum\Post\Event\Deleted;
use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePostVisibility;
use Flarum\Post\Post;
use Flarum\User\Guest; use Flarum\User\Guest;
use Flarum\User\User; use Flarum\User\User;
use Flarum\Util\Str; use Flarum\Util\Str;
@@ -109,7 +110,7 @@ class Discussion extends AbstractModel
$posts = $discussion->posts()->allTypes(); $posts = $discussion->posts()->allTypes();
foreach ($posts->get() as $post) { foreach ($posts->get() as $post) {
$discussion->raise(new PostWasDeleted($post)); $discussion->raise(new Deleted($post));
} }
$posts->delete(); $posts->delete();
@@ -272,7 +273,7 @@ class Discussion extends AbstractModel
* DiscussionRenamedPost, and delete if the title has been reverted * DiscussionRenamedPost, and delete if the title has been reverted
* completely.) * 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 * @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 * was originally intended to be saved. It also may not exist, if the
* merge logic resulted in deletion. * merge logic resulted in deletion.
@@ -303,7 +304,7 @@ class Discussion extends AbstractModel
*/ */
public function posts() 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() 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() public function lastPost()
{ {
return $this->belongsTo('Flarum\Core\Post', 'last_post_id'); return $this->belongsTo('Flarum\Post\Post', 'last_post_id');
} }
/** /**

View File

@@ -11,11 +11,11 @@
namespace Flarum\Core\Listener; namespace Flarum\Core\Listener;
use Flarum\Core\Post; use Flarum\Post\Post;
use Flarum\Event\PostWasDeleted; use Flarum\Post\Event\Deleted;
use Flarum\Event\PostWasHidden; use Flarum\Post\Event\Hidden;
use Flarum\Event\PostWasPosted; use Flarum\Post\Event\Posted;
use Flarum\Event\PostWasRestored; use Flarum\Post\Event\Restored;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class DiscussionMetadataUpdater class DiscussionMetadataUpdater
@@ -25,16 +25,16 @@ class DiscussionMetadataUpdater
*/ */
public function subscribe(Dispatcher $events) public function subscribe(Dispatcher $events)
{ {
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']); $events->listen(Posted::class, [$this, 'whenPostWasPosted']);
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']); $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']);
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']); $events->listen(Hidden::class, [$this, 'whenPostWasHidden']);
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']); $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; $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); $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); $this->removePost($event->post);
} }
/** /**
* @param PostWasRestored $event * @param Restored $event
*/ */
public function whenPostWasRestored(PostWasRestored $event) public function whenPostWasRestored(Restored $event)
{ {
$discussion = $event->post->discussion; $discussion = $event->post->discussion;

View File

@@ -13,7 +13,7 @@ namespace Flarum\Core\Listener;
use Flarum\Core\Notification\DiscussionRenamedBlueprint; use Flarum\Core\Notification\DiscussionRenamedBlueprint;
use Flarum\Core\Notification\NotificationSyncer; use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Core\Post\DiscussionRenamedPost; use Flarum\Post\DiscussionRenamedPost;
use Flarum\Event\DiscussionWasRenamed; use Flarum\Event\DiscussionWasRenamed;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;

View File

@@ -11,12 +11,12 @@
namespace Flarum\Core\Notification; namespace Flarum\Core\Notification;
use Flarum\Core\Post\DiscussionRenamedPost; use Flarum\Post\DiscussionRenamedPost;
class DiscussionRenamedBlueprint implements BlueprintInterface class DiscussionRenamedBlueprint implements BlueprintInterface
{ {
/** /**
* @var DiscussionRenamedPost * @var \Flarum\Post\DiscussionRenamedPost
*/ */
protected $post; protected $post;

View File

@@ -13,7 +13,7 @@ namespace Flarum\Core\Search\Discussion;
use Flarum\Core\Discussion; use Flarum\Core\Discussion;
use Flarum\Core\Repository\DiscussionRepository; use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Core\Repository\PostRepository; use Flarum\Post\PostRepository;
use Flarum\Core\Search\ApplySearchParametersTrait; use Flarum\Core\Search\ApplySearchParametersTrait;
use Flarum\Core\Search\GambitManager; use Flarum\Core\Search\GambitManager;
use Flarum\Core\Search\SearchCriteria; use Flarum\Core\Search\SearchCriteria;

View File

@@ -9,9 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Post; namespace Flarum\Post;
use Flarum\Core\Post;
abstract class AbstractEventPost extends Post abstract class AbstractEventPost extends Post
{ {

View File

@@ -9,13 +9,12 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Post; namespace Flarum\Post;
use Flarum\Core\Post; use Flarum\Post\Event\Hidden;
use Flarum\Event\PostWasHidden; use Flarum\Post\Event\Posted;
use Flarum\Event\PostWasPosted; use Flarum\Post\Event\Restored;
use Flarum\Event\PostWasRestored; use Flarum\Post\Event\Revised;
use Flarum\Event\PostWasRevised;
use Flarum\Formatter\Formatter; use Flarum\Formatter\Formatter;
use Flarum\User\User; use Flarum\User\User;
@@ -61,7 +60,7 @@ class CommentPost extends Post
// Set content last, as the parsing may rely on other post attributes. // Set content last, as the parsing may rely on other post attributes.
$post->content = $content; $post->content = $content;
$post->raise(new PostWasPosted($post)); $post->raise(new Posted($post));
return $post; return $post;
} }
@@ -81,7 +80,7 @@ class CommentPost extends Post
$this->edit_time = time(); $this->edit_time = time();
$this->edit_user_id = $actor->id; $this->edit_user_id = $actor->id;
$this->raise(new PostWasRevised($this)); $this->raise(new Revised($this));
} }
return $this; return $this;
@@ -99,7 +98,7 @@ class CommentPost extends Post
$this->hide_time = time(); $this->hide_time = time();
$this->hide_user_id = $actor ? $actor->id : null; $this->hide_user_id = $actor ? $actor->id : null;
$this->raise(new PostWasHidden($this)); $this->raise(new Hidden($this));
} }
return $this; return $this;
@@ -116,7 +115,7 @@ class CommentPost extends Post
$this->hide_time = null; $this->hide_time = null;
$this->hide_user_id = null; $this->hide_user_id = null;
$this->raise(new PostWasRestored($this)); $this->raise(new Restored($this));
} }
return $this; return $this;

View File

@@ -9,9 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Post; namespace Flarum\Post;
use Flarum\Core\Post;
/** /**
* A post which indicates that a discussion's title was changed. * A post which indicates that a discussion's title was changed.

View File

@@ -9,15 +9,15 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWasPosted class Deleted
{ {
/** /**
* @var \Flarum\Core\Post * @var \Flarum\Post\Post
*/ */
public $post; public $post;
@@ -27,7 +27,7 @@ class PostWasPosted
public $actor; public $actor;
/** /**
* @param \Flarum\Core\Post $post * @param \Flarum\Post\Post $post
*/ */
public function __construct(Post $post, User $actor = null) public function __construct(Post $post, User $actor = null)
{ {

View File

@@ -9,17 +9,17 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWillBeDeleted class Deleting
{ {
/** /**
* The post that is going to be deleted. * The post that is going to be deleted.
* *
* @var \Flarum\Core\Post * @var \Flarum\Post\Post
*/ */
public $post; public $post;
@@ -38,7 +38,7 @@ class PostWillBeDeleted
public $data; public $data;
/** /**
* @param \Flarum\Core\Post $post * @param \Flarum\Post\Post $post
* @param User $actor * @param User $actor
* @param array $data * @param array $data
*/ */

View File

@@ -9,12 +9,12 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWasHidden class Hidden
{ {
/** /**
* @var CommentPost * @var CommentPost

View File

@@ -9,15 +9,15 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWasDeleted class Posted
{ {
/** /**
* @var \Flarum\Core\Post * @var \Flarum\Post\Post
*/ */
public $post; public $post;
@@ -27,7 +27,7 @@ class PostWasDeleted
public $actor; public $actor;
/** /**
* @param \Flarum\Core\Post $post * @param \Flarum\Post\Post $post
*/ */
public function __construct(Post $post, User $actor = null) public function __construct(Post $post, User $actor = null)
{ {

View File

@@ -9,15 +9,15 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWasRestored class Restored
{ {
/** /**
* @var CommentPost * @var \Flarum\Post\CommentPost
*/ */
public $post; public $post;
@@ -27,7 +27,7 @@ class PostWasRestored
public $actor; public $actor;
/** /**
* @param CommentPost $post * @param \Flarum\Post\CommentPost $post
*/ */
public function __construct(CommentPost $post, User $actor = null) public function __construct(CommentPost $post, User $actor = null)
{ {

View File

@@ -9,15 +9,15 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWasRevised class Revised
{ {
/** /**
* @var CommentPost * @var \Flarum\Post\CommentPost
*/ */
public $post; public $post;
@@ -27,7 +27,7 @@ class PostWasRevised
public $actor; public $actor;
/** /**
* @param CommentPost $post * @param \Flarum\Post\CommentPost $post
*/ */
public function __construct(CommentPost $post, User $actor = null) public function __construct(CommentPost $post, User $actor = null)
{ {

View File

@@ -9,17 +9,17 @@
* file that was distributed with this source code. * 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; use Flarum\User\User;
class PostWillBeSaved class Saving
{ {
/** /**
* The post that will be saved. * The post that will be saved.
* *
* @var \Flarum\Core\Post * @var \Flarum\Post\Post
*/ */
public $post; public $post;
@@ -38,7 +38,7 @@ class PostWillBeSaved
public $data; public $data;
/** /**
* @param \Flarum\Core\Post $post * @param \Flarum\Post\Post $post
* @param User $actor * @param User $actor
* @param array $data * @param array $data
*/ */

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Exception; namespace Flarum\Post\Exception;
use Exception; use Exception;

View File

@@ -9,18 +9,17 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Post; namespace Flarum\Post;
use DateTime; use DateTime;
use Flarum\Core\Exception\FloodingException; use Flarum\Post\Exception\FloodingException;
use Flarum\Core\Post;
use Flarum\User\User; use Flarum\User\User;
class Floodgate class Floodgate
{ {
/** /**
* @param User $actor * @param User $actor
* @throws FloodingException * @throws \Flarum\Post\Exception\FloodingException
*/ */
public function assertNotFlooding(User $actor) public function assertNotFlooding(User $actor)
{ {

View File

@@ -9,9 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Post; namespace Flarum\Post;
use Flarum\Core\Post;
/** /**
* A post that has the ability to be merged into an adjacent 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 * Save the model, given that it is going to appear immediately after the
* passed model. * passed model.
* *
* @param Post|null $previous * @param \Flarum\Post\Post|null $previous
* @return Post The model resulting after the merge. If the merge is * @return Post The model resulting after the merge. If the merge is
* unsuccessful, this should be the current model instance. Otherwise, * unsuccessful, this should be the current model instance. Otherwise,
* it should be the model that was merged into. * it should be the model that was merged into.

View File

@@ -9,13 +9,13 @@
* file that was distributed with this source code. * 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\Foundation\EventGeneratorTrait;
use Flarum\Database\ScopeVisibilityTrait; use Flarum\Database\ScopeVisibilityTrait;
use Flarum\Database\AbstractModel; use Flarum\Database\AbstractModel;
use Flarum\Event\PostWasDeleted; use Flarum\Post\Event\Deleted;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
/** /**
@@ -97,7 +97,7 @@ class Post extends AbstractModel
}); });
static::deleted(function (Post $post) { static::deleted(function (Post $post) {
$post->raise(new PostWasDeleted($post)); $post->raise(new Deleted($post));
}); });
static::addGlobalScope(new RegisteredTypesScope); static::addGlobalScope(new RegisteredTypesScope);

View File

@@ -9,10 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Access; namespace Flarum\Post;
use Carbon\Carbon; use Carbon\Carbon;
use Flarum\Core\Post;
use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePostVisibility;
use Flarum\Event\ScopePrivatePostVisibility; use Flarum\Event\ScopePrivatePostVisibility;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
@@ -58,7 +57,7 @@ class PostPolicy extends AbstractPolicy
/** /**
* @param User $actor * @param User $actor
* @param string $ability * @param string $ability
* @param Post $post * @param \Flarum\Post\Post $post
* @return bool|null * @return bool|null
*/ */
public function after(User $actor, $ability, Post $post) public function after(User $actor, $ability, Post $post)

View File

@@ -9,10 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Repository; namespace Flarum\Post;
use Flarum\Core\Discussion; use Flarum\Core\Discussion;
use Flarum\Core\Post;
use Flarum\Event\ScopePostVisibility; use Flarum\Event\ScopePostVisibility;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;

View File

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

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Flarum\Core\Post; namespace Flarum\Post;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;

View File

@@ -21,7 +21,7 @@ use Flarum\Database\ScopeVisibilityTrait;
use Flarum\Database\AbstractModel; use Flarum\Database\AbstractModel;
use Flarum\Event\CheckUserPassword; use Flarum\Event\CheckUserPassword;
use Flarum\Event\ConfigureUserPreferences; use Flarum\Event\ConfigureUserPreferences;
use Flarum\Event\PostWasDeleted; use Flarum\Post\Event\Deleted;
use Flarum\Event\PrepareUserGroups; use Flarum\Event\PrepareUserGroups;
use Flarum\User\Event\AvatarChanged; use Flarum\User\Event\AvatarChanged;
use Flarum\User\Event\BioChanged; use Flarum\User\Event\BioChanged;
@@ -136,7 +136,7 @@ class User extends AbstractModel
$posts = $user->posts()->allTypes(); $posts = $user->posts()->allTypes();
foreach ($posts->get() as $post) { foreach ($posts->get() as $post) {
$user->raise(new PostWasDeleted($post)); $user->raise(new Deleted($post));
} }
$posts->delete(); $posts->delete();
@@ -603,7 +603,7 @@ class User extends AbstractModel
*/ */
public function posts() public function posts()
{ {
return $this->hasMany('Flarum\Core\Post'); return $this->hasMany('Flarum\Post\Post');
} }
/** /**

View File

@@ -15,10 +15,10 @@ use Flarum\Core\Discussion;
use Flarum\Core\Post; use Flarum\Core\Post;
use Flarum\Event\DiscussionWasDeleted; use Flarum\Event\DiscussionWasDeleted;
use Flarum\Event\DiscussionWasStarted; use Flarum\Event\DiscussionWasStarted;
use Flarum\Event\PostWasDeleted; use Flarum\Post\Event\Deleted;
use Flarum\Event\PostWasHidden; use Flarum\Post\Event\Hidden;
use Flarum\Event\PostWasPosted; use Flarum\Post\Event\Posted;
use Flarum\Event\PostWasRestored; use Flarum\Post\Event\Restored;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
class UserMetadataUpdater class UserMetadataUpdater
@@ -28,42 +28,42 @@ class UserMetadataUpdater
*/ */
public function subscribe(Dispatcher $events) public function subscribe(Dispatcher $events)
{ {
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']); $events->listen(Posted::class, [$this, 'whenPostWasPosted']);
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']); $events->listen(Deleted::class, [$this, 'whenPostWasDeleted']);
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']); $events->listen(Hidden::class, [$this, 'whenPostWasHidden']);
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']); $events->listen(Restored::class, [$this, 'whenPostWasRestored']);
$events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']); $events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']);
$events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']); $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); $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); $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); $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); $this->updateCommentsCount($event->post, 1);
} }

View File

@@ -13,7 +13,7 @@ namespace Tests\Flarum\Api\Handler;
use Exception; use Exception;
use Flarum\Api\ExceptionHandler\FloodingExceptionHandler; use Flarum\Api\ExceptionHandler\FloodingExceptionHandler;
use Flarum\Core\Exception\FloodingException; use Flarum\Post\Exception\FloodingException;
use Tests\Test\TestCase; use Tests\Test\TestCase;
class FloodingExceptionHandlerTest extends TestCase class FloodingExceptionHandlerTest extends TestCase