mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 17:12:46 +08:00
Extract new Flarum\Post namespace
This commit is contained in:
parent
02a5b65d08
commit
aaa04e2e13
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
{
|
|
@ -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;
|
|
@ -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.
|
|
@ -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)
|
||||
{
|
|
@ -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
|
||||
*/
|
|
@ -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
|
|
@ -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)
|
||||
{
|
|
@ -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)
|
||||
{
|
|
@ -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)
|
||||
{
|
|
@ -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
|
||||
*/
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core\Exception;
|
||||
namespace Flarum\Post\Exception;
|
||||
|
||||
use Exception;
|
||||
|
|
@ -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)
|
||||
{
|
|
@ -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.
|
|
@ -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);
|
|
@ -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)
|
|
@ -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;
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Core\Validator;
|
||||
namespace Flarum\Post;
|
||||
|
||||
use Flarum\Foundation\AbstractValidator;
|
||||
|
|
@ -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;
|
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user