Extract new Flarum\Discussion namespace

This commit is contained in:
Franz Liedke 2017-06-24 13:48:04 +02:00
parent 66abd7ecfd
commit 4fb38d6458
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
46 changed files with 149 additions and 147 deletions

View File

@ -12,7 +12,7 @@
namespace Flarum\Api\Controller;
use Flarum\Api\UrlGenerator;
use Flarum\Core\Search\Discussion\DiscussionSearcher;
use Flarum\Discussion\Search\DiscussionSearcher;
use Flarum\Core\Search\SearchCriteria;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;

View File

@ -11,7 +11,7 @@
namespace Flarum\Api\Controller;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\Exception\PermissionDeniedException;
use Flarum\Core\Repository\NotificationRepository;
use Psr\Http\Message\ServerRequestInterface;

View File

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

View File

@ -11,7 +11,7 @@
namespace Flarum\Api\Serializer;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use InvalidArgumentException;
class BasicDiscussionSerializer extends AbstractSerializer

View File

@ -12,7 +12,7 @@
namespace Flarum\Api\Serializer;
use Flarum\User\Gate;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
class DiscussionSerializer extends BasicDiscussionSerializer
{

View File

@ -13,9 +13,9 @@ namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\User\Exception\PermissionDeniedException;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Event\DiscussionWillBeDeleted;
use Flarum\Discussion\Event\Deleting;
use Illuminate\Contracts\Events\Dispatcher;
class DeleteDiscussionHandler
@ -24,7 +24,7 @@ class DeleteDiscussionHandler
use AssertPermissionTrait;
/**
* @var DiscussionRepository
* @var \Flarum\Discussion\DiscussionRepository
*/
protected $discussions;
@ -40,7 +40,7 @@ class DeleteDiscussionHandler
/**
* @param DeleteDiscussion $command
* @return \Flarum\Core\Discussion
* @return \Flarum\Discussion\Discussion
* @throws PermissionDeniedException
*/
public function handle(DeleteDiscussion $command)
@ -52,7 +52,7 @@ class DeleteDiscussionHandler
$this->assertCan($actor, 'delete', $discussion);
$this->events->fire(
new DiscussionWillBeDeleted($discussion, $actor, $command->data)
new Deleting($discussion, $actor, $command->data)
);
$discussion->delete();

View File

@ -13,10 +13,10 @@ namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\User\Exception\PermissionDeniedException;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Core\Validator\DiscussionValidator;
use Flarum\Event\DiscussionWillBeSaved;
use Flarum\Discussion\DiscussionValidator;
use Flarum\Discussion\Event\Saving;
use Illuminate\Contracts\Events\Dispatcher;
class EditDiscussionHandler
@ -48,7 +48,7 @@ class EditDiscussionHandler
/**
* @param EditDiscussion $command
* @return \Flarum\Core\Discussion
* @return \Flarum\Discussion\Discussion
* @throws \Flarum\User\Exception\PermissionDeniedException
*/
public function handle(EditDiscussion $command)
@ -76,7 +76,7 @@ class EditDiscussionHandler
}
$this->events->fire(
new DiscussionWillBeSaved($discussion, $actor, $data)
new Saving($discussion, $actor, $data)
);
$this->validator->assertValid($discussion->getDirty());

View File

@ -15,7 +15,7 @@ use DateTime;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Post\CommentPost;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Post\PostValidator;
use Flarum\Post\Event\Saving;

View File

@ -12,9 +12,9 @@
namespace Flarum\Core\Command;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Event\DiscussionStateWillBeSaved;
use Flarum\Discussion\Event\UserDataSaving;
use Illuminate\Contracts\Events\Dispatcher;
class ReadDiscussionHandler
@ -54,7 +54,7 @@ class ReadDiscussionHandler
$state->read($command->readNumber);
$this->events->fire(
new DiscussionStateWillBeSaved($state)
new UserDataSaving($state)
);
$state->save();

View File

@ -13,10 +13,10 @@ namespace Flarum\Core\Command;
use Exception;
use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\Foundation\DispatchEventsTrait;
use Flarum\Core\Validator\DiscussionValidator;
use Flarum\Event\DiscussionWillBeSaved;
use Flarum\Discussion\DiscussionValidator;
use Flarum\Discussion\Event\Saving;
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
@ -31,14 +31,14 @@ class StartDiscussionHandler
protected $bus;
/**
* @var DiscussionValidator
* @var \Flarum\Discussion\DiscussionValidator
*/
protected $validator;
/**
* @param EventDispatcher $events
* @param BusDispatcher $bus
* @param DiscussionValidator $validator
* @param \Flarum\Discussion\DiscussionValidator $validator
*/
public function __construct(EventDispatcher $events, BusDispatcher $bus, DiscussionValidator $validator)
{
@ -70,7 +70,7 @@ class StartDiscussionHandler
);
$this->events->fire(
new DiscussionWillBeSaved($discussion, $actor, $data)
new Saving($discussion, $actor, $data)
);
$this->validator->assertValid($discussion->getAttributes());

View File

@ -107,13 +107,13 @@ class CoreServiceProvider extends AbstractServiceProvider
$events = $this->app->make('events');
$events->subscribe('Flarum\Core\Listener\SelfDemotionGuard');
$events->subscribe('Flarum\Core\Listener\DiscussionMetadataUpdater');
$events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater');
$events->subscribe('Flarum\User\UserMetadataUpdater');
$events->subscribe('Flarum\Core\Listener\ExtensionValidator');
$events->subscribe('Flarum\User\EmailConfirmationMailer');
$events->subscribe('Flarum\Core\Listener\DiscussionRenamedNotifier');
$events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier');
$events->subscribe('Flarum\Core\Access\DiscussionPolicy');
$events->subscribe('Flarum\Discussion\DiscussionPolicy');
$events->subscribe('Flarum\Core\Access\GroupPolicy');
$events->subscribe('Flarum\Post\PostPolicy');
$events->subscribe('Flarum\User\UserPolicy');

View File

@ -11,9 +11,10 @@
namespace Flarum\Core;
use Flarum\Discussion\Discussion;
use Flarum\Foundation\EventGeneratorTrait;
use Flarum\Database\AbstractModel;
use Flarum\Event\DiscussionWasRead;
use Flarum\Discussion\Event\UserRead;
use Illuminate\Database\Eloquent\Builder;
/**
@ -57,7 +58,7 @@ class DiscussionState extends AbstractModel
$this->read_number = $number;
$this->read_time = time();
$this->raise(new DiscussionWasRead($this));
$this->raise(new UserRead($this));
}
return $this;
@ -70,7 +71,7 @@ class DiscussionState extends AbstractModel
*/
public function discussion()
{
return $this->belongsTo('Flarum\Core\Discussion', 'discussion_id');
return $this->belongsTo('Flarum\Discussion\Discussion', 'discussion_id');
}
/**

View File

@ -56,7 +56,7 @@ class Notification extends AbstractModel
* A map of notification types and the model classes to use for their
* subjects. For example, the 'discussionRenamed' notification type, which
* represents that a user's discussion was renamed, has the subject model
* class 'Flarum\Core\Discussion'.
* class 'Flarum\Discussion\Discussion'.
*
* @var array
*/

View File

@ -65,6 +65,6 @@ class DiscussionRenamedBlueprint implements BlueprintInterface
*/
public static function getSubjectModel()
{
return 'Flarum\Core\Discussion';
return 'Flarum\Discussion\Discussion';
}
}

View File

@ -26,8 +26,8 @@ class SearchServiceProvider extends AbstractServiceProvider
public function register()
{
$this->app->bind(
'Flarum\Core\Search\Discussion\Fulltext\DriverInterface',
'Flarum\Core\Search\Discussion\Fulltext\MySqlFulltextDriver'
'Flarum\Discussion\Search\Fulltext\DriverInterface',
'Flarum\Discussion\Search\Fulltext\MySqlFulltextDriver'
);
$this->registerDiscussionGambits();
@ -56,16 +56,16 @@ class SearchServiceProvider extends AbstractServiceProvider
public function registerDiscussionGambits()
{
$this->app->when('Flarum\Core\Search\Discussion\DiscussionSearcher')
$this->app->when('Flarum\Discussion\Search\DiscussionSearcher')
->needs('Flarum\Core\Search\GambitManager')
->give(function (Container $app) {
$gambits = new GambitManager($app);
$gambits->setFulltextGambit('Flarum\Core\Search\Discussion\Gambit\FulltextGambit');
$gambits->add('Flarum\Core\Search\Discussion\Gambit\AuthorGambit');
$gambits->add('Flarum\Core\Search\Discussion\Gambit\CreatedGambit');
$gambits->add('Flarum\Core\Search\Discussion\Gambit\HiddenGambit');
$gambits->add('Flarum\Core\Search\Discussion\Gambit\UnreadGambit');
$gambits->setFulltextGambit('Flarum\Discussion\Search\Gambit\FulltextGambit');
$gambits->add('Flarum\Discussion\Search\Gambit\AuthorGambit');
$gambits->add('Flarum\Discussion\Search\Gambit\CreatedGambit');
$gambits->add('Flarum\Discussion\Search\Gambit\HiddenGambit');
$gambits->add('Flarum\Discussion\Search\Gambit\UnreadGambit');
$app->make('events')->fire(
new ConfigureDiscussionGambits($gambits)

View File

@ -9,17 +9,18 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core;
namespace Flarum\Discussion;
use Flarum\Core\DiscussionState;
use Flarum\Post\MergeableInterface;
use Flarum\Foundation\EventGeneratorTrait;
use Flarum\Database\ScopeVisibilityTrait;
use Flarum\Database\AbstractModel;
use Flarum\Event\DiscussionWasDeleted;
use Flarum\Event\DiscussionWasHidden;
use Flarum\Event\DiscussionWasRenamed;
use Flarum\Event\DiscussionWasRestored;
use Flarum\Event\DiscussionWasStarted;
use Flarum\Discussion\Event\Deleted;
use Flarum\Discussion\Event\Hidden;
use Flarum\Discussion\Event\Renamed;
use Flarum\Discussion\Event\Restored;
use Flarum\Discussion\Event\Started;
use Flarum\Post\Event\Deleted;
use Flarum\Event\ScopePostVisibility;
use Flarum\Post\Post;
@ -102,7 +103,7 @@ class Discussion extends AbstractModel
parent::boot();
static::deleted(function ($discussion) {
$discussion->raise(new DiscussionWasDeleted($discussion));
$discussion->raise(new Deleted($discussion));
// Delete all of the posts in the discussion. Before we delete them
// in a big batch query, we will loop through them and raise a
@ -138,7 +139,7 @@ class Discussion extends AbstractModel
$discussion->setRelation('startUser', $user);
$discussion->raise(new DiscussionWasStarted($discussion));
$discussion->raise(new Started($discussion));
return $discussion;
}
@ -155,7 +156,7 @@ class Discussion extends AbstractModel
$oldTitle = $this->title;
$this->title = $title;
$this->raise(new DiscussionWasRenamed($this, $oldTitle));
$this->raise(new Renamed($this, $oldTitle));
}
return $this;
@ -173,7 +174,7 @@ class Discussion extends AbstractModel
$this->hide_time = time();
$this->hide_user_id = $actor ? $actor->id : null;
$this->raise(new DiscussionWasHidden($this));
$this->raise(new Hidden($this));
}
return $this;
@ -190,7 +191,7 @@ class Discussion extends AbstractModel
$this->hide_time = null;
$this->hide_user_id = null;
$this->raise(new DiscussionWasRestored($this));
$this->raise(new Restored($this));
}
return $this;

View File

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

View File

@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Access;
namespace Flarum\Discussion;
use Carbon\Carbon;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\Event\ScopeHiddenDiscussionVisibility;
use Flarum\Event\ScopePrivateDiscussionVisibility;
use Flarum\Settings\SettingsRepositoryInterface;
@ -100,7 +100,7 @@ class DiscussionPolicy extends AbstractPolicy
/**
* @param User $actor
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @return bool|null
*/
public function rename(User $actor, Discussion $discussion)
@ -118,7 +118,7 @@ class DiscussionPolicy extends AbstractPolicy
/**
* @param User $actor
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @return bool|null
*/
public function hide(User $actor, Discussion $discussion)

View File

@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Listener;
namespace Flarum\Discussion;
use Flarum\Core\Notification\DiscussionRenamedBlueprint;
use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Post\DiscussionRenamedPost;
use Flarum\Event\DiscussionWasRenamed;
use Flarum\Discussion\Event\Renamed;
use Illuminate\Contracts\Events\Dispatcher;
class DiscussionRenamedNotifier
@ -37,13 +37,13 @@ class DiscussionRenamedNotifier
*/
public function subscribe(Dispatcher $events)
{
$events->listen(DiscussionWasRenamed::class, [$this, 'whenDiscussionWasRenamed']);
$events->listen(Renamed::class, [$this, 'whenDiscussionWasRenamed']);
}
/**
* @param \Flarum\Event\DiscussionWasRenamed $event
* @param \Flarum\Discussion\Event\Renamed $event
*/
public function whenDiscussionWasRenamed(DiscussionWasRenamed $event)
public function whenDiscussionWasRenamed(Renamed $event)
{
$post = DiscussionRenamedPost::reply(
$event->discussion->id,

View File

@ -9,9 +9,8 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Repository;
namespace Flarum\Discussion;
use Flarum\Core\Discussion;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;
@ -34,7 +33,7 @@ class DiscussionRepository
*
* @param int $id
* @param User $user
* @return \Flarum\Core\Discussion
* @return \Flarum\Discussion\Discussion
*/
public function findOrFail($id, User $user = null)
{

View File

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

View File

@ -9,15 +9,15 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWasDeleted
class Deleted
{
/**
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;
@ -27,7 +27,7 @@ class DiscussionWasDeleted
public $actor;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param User $actor
*/
public function __construct(Discussion $discussion, User $actor = null)

View File

@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWillBeDeleted
class Deleting
{
/**
* The discussion that is going to be deleted.

View File

@ -9,15 +9,15 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWasStarted
class Hidden
{
/**
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;
@ -27,7 +27,7 @@ class DiscussionWasStarted
public $actor;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param User $actor
*/
public function __construct(Discussion $discussion, User $actor = null)

View File

@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWasRenamed
class Renamed
{
/**
* @var Discussion
@ -32,7 +32,7 @@ class DiscussionWasRenamed
public $actor;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param User $actor
* @param string $oldTitle
*/

View File

@ -9,15 +9,15 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWasRestored
class Restored
{
/**
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;
@ -27,7 +27,7 @@ class DiscussionWasRestored
public $actor;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param User $actor
*/
public function __construct(Discussion $discussion, User $actor = null)

View File

@ -9,17 +9,17 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWillBeSaved
class Saving
{
/**
* The discussion that will be saved.
*
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;
@ -38,7 +38,7 @@ class DiscussionWillBeSaved
public $data;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param User $actor
* @param array $data
*/

View File

@ -9,15 +9,15 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
class DiscussionWasHidden
class Started
{
/**
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;
@ -27,7 +27,7 @@ class DiscussionWasHidden
public $actor;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param User $actor
*/
public function __construct(Discussion $discussion, User $actor = null)

View File

@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\DiscussionState;
class DiscussionStateWillBeSaved
class UserDataSaving
{
/**
* @var DiscussionState

View File

@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Discussion\Event;
use Flarum\Core\DiscussionState;
class DiscussionWasRead
class UserRead
{
/**
* @var DiscussionState

View File

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

View File

@ -9,10 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion;
namespace Flarum\Discussion\Search;
use Flarum\Core\Discussion;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Discussion\Discussion;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Discussion\Search\DiscussionSearch;
use Flarum\Post\PostRepository;
use Flarum\Core\Search\ApplySearchParametersTrait;
use Flarum\Core\Search\GambitManager;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion\Fulltext;
namespace Flarum\Discussion\Search\Fulltext;
interface DriverInterface
{

View File

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

View File

@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion\Gambit;
namespace Flarum\Discussion\Search\Gambit;
use Flarum\User\UserRepository;
use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Discussion\Search\DiscussionSearch;
use LogicException;
class AuthorGambit extends AbstractRegexGambit

View File

@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion\Gambit;
namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Discussion\Search\DiscussionSearch;
use LogicException;
class CreatedGambit extends AbstractRegexGambit

View File

@ -9,23 +9,23 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion\Gambit;
namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Core\Search\Discussion\Fulltext\DriverInterface;
use Flarum\Discussion\Search\DiscussionSearch;
use Flarum\Discussion\Search\Fulltext\DriverInterface;
use Flarum\Core\Search\GambitInterface;
use LogicException;
class FulltextGambit implements GambitInterface
{
/**
* @var DriverInterface
* @var \Flarum\Discussion\Search\Fulltext\DriverInterface
*/
protected $fulltext;
/**
* @param DriverInterface $fulltext
* @param \Flarum\Discussion\Search\Fulltext\DriverInterface $fulltext
*/
public function __construct(DriverInterface $fulltext)
{

View File

@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion\Gambit;
namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Discussion\Search\DiscussionSearch;
use LogicException;
class HiddenGambit extends AbstractRegexGambit

View File

@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Search\Discussion\Gambit;
namespace Flarum\Discussion\Search\Gambit;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Discussion\Search\DiscussionSearch;
use LogicException;
class UnreadGambit extends AbstractRegexGambit
@ -25,12 +25,12 @@ class UnreadGambit extends AbstractRegexGambit
protected $pattern = 'is:unread';
/**
* @var \Flarum\Core\Repository\DiscussionRepository
* @var \Flarum\Discussion\DiscussionRepository
*/
protected $discussions;
/**
* @param DiscussionRepository $discussions
* @param \Flarum\Discussion\DiscussionRepository $discussions
*/
public function __construct(DiscussionRepository $discussions)
{

View File

@ -11,7 +11,7 @@
namespace Flarum\Event;
use Flarum\Core\Search\Discussion\DiscussionSearch;
use Flarum\Discussion\Search\DiscussionSearch;
use Flarum\Core\Search\SearchCriteria;
class ConfigureDiscussionSearch

View File

@ -11,7 +11,7 @@
namespace Flarum\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Builder;
class ScopePostVisibility
{
/**
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;

View File

@ -11,7 +11,7 @@
namespace Flarum\Event;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Builder;
class ScopePrivatePostVisibility
{
/**
* @var Discussion
* @var \Flarum\Discussion\Discussion
*/
public $discussion;
@ -36,7 +36,7 @@ class ScopePrivatePostVisibility
public $actor;
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param Builder $query
* @param User $actor
*/

View File

@ -30,7 +30,7 @@ use Illuminate\Database\Eloquent\Builder;
* @property int|null $edit_user_id
* @property \Carbon\Carbon|null $hide_time
* @property int|null $hide_user_id
* @property \Flarum\Core\Discussion|null $discussion
* @property \Flarum\Discussion\Discussion|null $discussion
* @property User|null $user
* @property User|null $editUser
* @property User|null $hideUser
@ -129,7 +129,7 @@ class Post extends AbstractModel
*/
public function discussion()
{
return $this->belongsTo('Flarum\Core\Discussion', 'discussion_id');
return $this->belongsTo('Flarum\Discussion\Discussion', 'discussion_id');
}
/**

View File

@ -11,7 +11,7 @@
namespace Flarum\Post;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\Event\ScopePostVisibility;
use Flarum\User\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;

View File

@ -613,7 +613,7 @@ class User extends AbstractModel
*/
public function read()
{
return $this->belongsToMany('Flarum\Core\Discussion', 'users_discussions');
return $this->belongsToMany('Flarum\Discussion\Discussion', 'users_discussions');
}
/**

View File

@ -11,10 +11,10 @@
namespace Flarum\User;
use Flarum\Core\Discussion;
use Flarum\Discussion\Discussion;
use Flarum\Core\Post;
use Flarum\Event\DiscussionWasDeleted;
use Flarum\Event\DiscussionWasStarted;
use Flarum\Discussion\Event\Deleted;
use Flarum\Discussion\Event\Started;
use Flarum\Post\Event\Deleted;
use Flarum\Post\Event\Hidden;
use Flarum\Post\Event\Posted;
@ -32,8 +32,8 @@ class UserMetadataUpdater
$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']);
$events->listen(Started::class, [$this, 'whenDiscussionWasStarted']);
$events->listen(Deleted::class, [$this, 'whenDiscussionWasDeleted']);
}
/**
@ -69,17 +69,17 @@ class UserMetadataUpdater
}
/**
* @param \Flarum\Event\DiscussionWasStarted $event
* @param \Flarum\Discussion\Event\Started $event
*/
public function whenDiscussionWasStarted(DiscussionWasStarted $event)
public function whenDiscussionWasStarted(Started $event)
{
$this->updateDiscussionsCount($event->discussion, 1);
}
/**
* @param \Flarum\Event\DiscussionWasDeleted $event
* @param \Flarum\Discussion\Event\Deleted $event
*/
public function whenDiscussionWasDeleted(DiscussionWasDeleted $event)
public function whenDiscussionWasDeleted(Deleted $event)
{
$this->updateDiscussionsCount($event->discussion, -1);
}
@ -99,7 +99,7 @@ class UserMetadataUpdater
}
/**
* @param Discussion $discussion
* @param \Flarum\Discussion\Discussion $discussion
* @param int $amount
*/
protected function updateDiscussionsCount(Discussion $discussion, $amount)