mirror of
https://github.com/flarum/core.git
synced 2025-07-23 17:51:24 +02:00
Get rid of Repository interfaces
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Activity;
|
<?php namespace Flarum\Api\Actions\Activity;
|
||||||
|
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Activity\ActivityRepositoryInterface;
|
use Flarum\Core\Activity\ActivityRepository;
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
use Flarum\Api\Actions\SerializeCollectionAction;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
@@ -9,12 +9,12 @@ use Tobscure\JsonApi\Document;
|
|||||||
class IndexAction extends SerializeCollectionAction
|
class IndexAction extends SerializeCollectionAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ActivityRepositoryInterface
|
* @var ActivityRepository
|
||||||
*/
|
*/
|
||||||
protected $activity;
|
protected $activity;
|
||||||
|
|
||||||
@@ -58,10 +58,10 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
public static $sort;
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
* @param ActivityRepositoryInterface $activity
|
* @param ActivityRepository $activity
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users, ActivityRepositoryInterface $activity)
|
public function __construct(UserRepository $users, ActivityRepository $activity)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->activity = $activity;
|
$this->activity = $activity;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Discussions;
|
<?php namespace Flarum\Api\Actions\Discussions;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
use Flarum\Api\Actions\SerializeResourceAction;
|
||||||
use Flarum\Api\Actions\Posts\GetsPosts;
|
use Flarum\Api\Actions\Posts\GetsPosts;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
@@ -12,7 +12,7 @@ class ShowAction extends SerializeResourceAction
|
|||||||
use GetsPosts;
|
use GetsPosts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Flarum\Core\Discussions\DiscussionRepositoryInterface
|
* @var \Flarum\Core\Discussions\DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
@@ -64,10 +64,10 @@ class ShowAction extends SerializeResourceAction
|
|||||||
/**
|
/**
|
||||||
* Instantiate the action.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
* @param DiscussionRepositoryInterface $discussions
|
* @param DiscussionRepository $discussions
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionRepositoryInterface $discussions, PostRepositoryInterface $posts)
|
public function __construct(DiscussionRepository $discussions, PostRepository $posts)
|
||||||
{
|
{
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Notifications;
|
<?php namespace Flarum\Api\Actions\Notifications;
|
||||||
|
|
||||||
use Flarum\Core\Notifications\NotificationRepositoryInterface;
|
use Flarum\Core\Notifications\NotificationRepository;
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
use Flarum\Api\Actions\SerializeCollectionAction;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
@@ -9,7 +9,7 @@ use Tobscure\JsonApi\Document;
|
|||||||
class IndexAction extends SerializeCollectionAction
|
class IndexAction extends SerializeCollectionAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var NotificationRepositoryInterface
|
* @var NotificationRepository
|
||||||
*/
|
*/
|
||||||
protected $notifications;
|
protected $notifications;
|
||||||
|
|
||||||
@@ -55,9 +55,9 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
/**
|
/**
|
||||||
* Instantiate the action.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
* @param NotificationRepositoryInterface $notifications
|
* @param NotificationRepository $notifications
|
||||||
*/
|
*/
|
||||||
public function __construct(NotificationRepositoryInterface $notifications)
|
public function __construct(NotificationRepository $notifications)
|
||||||
{
|
{
|
||||||
$this->notifications = $notifications;
|
$this->notifications = $notifications;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ use Flarum\Api\JsonApiRequest;
|
|||||||
trait GetsPosts
|
trait GetsPosts
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Flarum\Core\Posts\PostRepositoryInterface
|
* @var \Flarum\Core\Posts\PostRepository
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Posts;
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Api\Actions\SerializeCollectionAction;
|
use Flarum\Api\Actions\SerializeCollectionAction;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
@@ -51,9 +51,9 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
public static $sort;
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepositoryInterface $posts)
|
public function __construct(PostRepository $posts)
|
||||||
{
|
{
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Posts;
|
<?php namespace Flarum\Api\Actions\Posts;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
use Flarum\Api\Actions\SerializeResourceAction;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
@@ -9,7 +9,7 @@ use Tobscure\JsonApi\Document;
|
|||||||
class ShowAction extends SerializeResourceAction
|
class ShowAction extends SerializeResourceAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var PostRepositoryInterface
|
* @var PostRepository
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
@@ -55,9 +55,9 @@ class ShowAction extends SerializeResourceAction
|
|||||||
public static $sort;
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepositoryInterface $posts)
|
public function __construct(PostRepository $posts)
|
||||||
{
|
{
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use Flarum\Api\Commands\GenerateAccessToken;
|
use Flarum\Api\Commands\GenerateAccessToken;
|
||||||
use Flarum\Api\Request;
|
use Flarum\Api\Request;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||||
use Flarum\Core\Users\Events\UserEmailChangeWasRequested;
|
use Flarum\Core\Users\Events\UserEmailChangeWasRequested;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
@@ -14,7 +14,7 @@ class TokenAction extends JsonApiAction
|
|||||||
|
|
||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
public function __construct(UserRepositoryInterface $users, Dispatcher $bus)
|
public function __construct(UserRepository $users, Dispatcher $bus)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->bus = $bus;
|
$this->bus = $bus;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Api\Actions\Users;
|
<?php namespace Flarum\Api\Actions\Users;
|
||||||
|
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Api\Actions\SerializeResourceAction;
|
use Flarum\Api\Actions\SerializeResourceAction;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
@@ -8,7 +8,7 @@ use Tobscure\JsonApi\Document;
|
|||||||
class ShowAction extends SerializeResourceAction
|
class ShowAction extends SerializeResourceAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
@@ -50,9 +50,9 @@ class ShowAction extends SerializeResourceAction
|
|||||||
public static $sort;
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users)
|
public function __construct(UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,17 @@
|
|||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Users\User;
|
||||||
|
|
||||||
class EloquentActivityRepository implements ActivityRepositoryInterface
|
class ActivityRepository
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find a user's activity.
|
||||||
|
*
|
||||||
|
* @param int $userId
|
||||||
|
* @param User $actor
|
||||||
|
* @param null|int $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @param null|string $type
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection
|
||||||
*/
|
*/
|
||||||
public function findByUser($userId, User $actor, $limit = null, $offset = 0, $type = null)
|
public function findByUser($userId, User $actor, $limit = null, $offset = 0, $type = null)
|
||||||
{
|
{
|
@@ -1,18 +0,0 @@
|
|||||||
<?php namespace Flarum\Core\Activity;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
|
|
||||||
interface ActivityRepositoryInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Find a user's activity.
|
|
||||||
*
|
|
||||||
* @param integer $userId
|
|
||||||
* @param \Flarum\Core\Users\User $actor
|
|
||||||
* @param null|integer $count
|
|
||||||
* @param integer $start
|
|
||||||
* @param null|string $type
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
public function findByUser($userId, User $actor, $count = null, $start = 0, $type = null);
|
|
||||||
}
|
|
@@ -8,16 +8,16 @@
|
|||||||
class ActivitySyncer
|
class ActivitySyncer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ActivityRepositoryInterface
|
* @var ActivityRepository
|
||||||
*/
|
*/
|
||||||
protected $activity;
|
protected $activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of the activity syncer.
|
* Create a new instance of the activity syncer.
|
||||||
*
|
*
|
||||||
* @param ActivityRepositoryInterface $activity
|
* @param ActivityRepository $activity
|
||||||
*/
|
*/
|
||||||
public function __construct(ActivityRepositoryInterface $activity)
|
public function __construct(ActivityRepository $activity)
|
||||||
{
|
{
|
||||||
$this->activity = $activity;
|
$this->activity = $activity;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Discussions\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Discussions\Events\DiscussionWillBeDeleted;
|
use Flarum\Core\Discussions\Events\DiscussionWillBeDeleted;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
|
|
||||||
@@ -9,14 +9,14 @@ class DeleteDiscussionHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Flarum\Core\Discussions\DiscussionRepositoryInterface
|
* @var \Flarum\Core\Discussions\DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Flarum\Core\Discussions\DiscussionRepositoryInterface $discussions
|
* @param \Flarum\Core\Discussions\DiscussionRepository $discussions
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionRepositoryInterface $discussions)
|
public function __construct(DiscussionRepository $discussions)
|
||||||
{
|
{
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Discussions\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Discussions\Events\DiscussionWillBeSaved;
|
use Flarum\Core\Discussions\Events\DiscussionWillBeSaved;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
|
|
||||||
@@ -9,14 +9,14 @@ class EditDiscussionHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DiscussionRepositoryInterface
|
* @var DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DiscussionRepositoryInterface $discussions
|
* @param DiscussionRepository $discussions
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionRepositoryInterface $discussions)
|
public function __construct(DiscussionRepository $discussions)
|
||||||
{
|
{
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Commands;
|
<?php namespace Flarum\Core\Discussions\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Discussions\Events\DiscussionStateWillBeSaved;
|
use Flarum\Core\Discussions\Events\DiscussionStateWillBeSaved;
|
||||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
@@ -10,14 +10,14 @@ class ReadDiscussionHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DiscussionRepositoryInterface
|
* @var DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DiscussionRepositoryInterface $discussions
|
* @param DiscussionRepository $discussions
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionRepositoryInterface $discussions)
|
public function __construct(DiscussionRepository $discussions)
|
||||||
{
|
{
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Users\User;
|
||||||
|
|
||||||
class EloquentDiscussionRepository implements DiscussionRepositoryInterface
|
class DiscussionRepository
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get a new query builder for the discussions table.
|
* Get a new query builder for the discussions table.
|
@@ -1,33 +0,0 @@
|
|||||||
<?php namespace Flarum\Core\Discussions;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
|
|
||||||
interface DiscussionRepositoryInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get a new query builder for the discussions table.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function query();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a discussion by ID, optionally making sure it is visible to a certain
|
|
||||||
* user, or throw an exception.
|
|
||||||
*
|
|
||||||
* @param integer $id
|
|
||||||
* @param \Flarum\Core\Users\User $actor
|
|
||||||
* @return \Flarum\Core\Discussions\Discussion
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
|
||||||
*/
|
|
||||||
public function findOrFail($id, User $actor = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the IDs of discussions which a user has read completely.
|
|
||||||
*
|
|
||||||
* @param \Flarum\Core\Users\User $user
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getReadIds(User $user);
|
|
||||||
}
|
|
@@ -42,11 +42,6 @@ class DiscussionsServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
|
||||||
'Flarum\Core\Discussions\DiscussionRepositoryInterface',
|
|
||||||
'Flarum\Core\Discussions\EloquentDiscussionRepository'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->app->bind(
|
$this->app->bind(
|
||||||
'Flarum\Core\Discussions\Search\Fulltext\DriverInterface',
|
'Flarum\Core\Discussions\Search\Fulltext\DriverInterface',
|
||||||
'Flarum\Core\Discussions\Search\Fulltext\MySqlFulltextDriver'
|
'Flarum\Core\Discussions\Search\Fulltext\MySqlFulltextDriver'
|
||||||
|
@@ -5,8 +5,8 @@ use Flarum\Core\Search\AppliesParametersToSearch;
|
|||||||
use Flarum\Core\Search\SearchCriteria;
|
use Flarum\Core\Search\SearchCriteria;
|
||||||
use Flarum\Core\Search\SearcherInterface;
|
use Flarum\Core\Search\SearcherInterface;
|
||||||
use Flarum\Core\Search\GambitManager;
|
use Flarum\Core\Search\GambitManager;
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Core\Discussions\Events\DiscussionSearchWillBePerformed;
|
use Flarum\Core\Discussions\Events\DiscussionSearchWillBePerformed;
|
||||||
use Flarum\Core\Search\SearchResults;
|
use Flarum\Core\Search\SearchResults;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
@@ -25,24 +25,24 @@ class DiscussionSearcher
|
|||||||
protected $gambits;
|
protected $gambits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DiscussionRepositoryInterface
|
* @var DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PostRepositoryInterface
|
* @var PostRepository
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GambitManager $gambits
|
* @param GambitManager $gambits
|
||||||
* @param DiscussionRepositoryInterface $discussions
|
* @param DiscussionRepository $discussions
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
GambitManager $gambits,
|
GambitManager $gambits,
|
||||||
DiscussionRepositoryInterface $discussions,
|
DiscussionRepository $discussions,
|
||||||
PostRepositoryInterface $posts
|
PostRepository $posts
|
||||||
) {
|
) {
|
||||||
$this->gambits = $gambits;
|
$this->gambits = $gambits;
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Search\Gambits;
|
<?php namespace Flarum\Core\Discussions\Search\Gambits;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Search\DiscussionSearch;
|
use Flarum\Core\Discussions\Search\DiscussionSearch;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Search\RegexGambit;
|
use Flarum\Core\Search\RegexGambit;
|
||||||
use Flarum\Core\Search\Search;
|
use Flarum\Core\Search\Search;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
@@ -14,14 +14,14 @@ class AuthorGambit extends RegexGambit
|
|||||||
protected $pattern = 'author:(.+)';
|
protected $pattern = 'author:(.+)';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users)
|
public function __construct(UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Search\Gambits;
|
<?php namespace Flarum\Core\Discussions\Search\Gambits;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\Search\DiscussionSearch;
|
use Flarum\Core\Discussions\Search\DiscussionSearch;
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Core\Search\Search;
|
use Flarum\Core\Search\Search;
|
||||||
use Flarum\Core\Search\GambitInterface;
|
use Flarum\Core\Search\GambitInterface;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
@@ -9,14 +9,14 @@ use LogicException;
|
|||||||
class FulltextGambit implements GambitInterface
|
class FulltextGambit implements GambitInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var PostRepositoryInterface
|
* @var PostRepository
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepositoryInterface $posts)
|
public function __construct(PostRepository $posts)
|
||||||
{
|
{
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Discussions\Search\Gambits;
|
<?php namespace Flarum\Core\Discussions\Search\Gambits;
|
||||||
|
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Discussions\Search\DiscussionSearch;
|
use Flarum\Core\Discussions\Search\DiscussionSearch;
|
||||||
use Flarum\Core\Search\RegexGambit;
|
use Flarum\Core\Search\RegexGambit;
|
||||||
use Flarum\Core\Search\Search;
|
use Flarum\Core\Search\Search;
|
||||||
@@ -14,14 +14,14 @@ class UnreadGambit extends RegexGambit
|
|||||||
protected $pattern = 'is:unread';
|
protected $pattern = 'is:unread';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DiscussionRepositoryInterface
|
* @var DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DiscussionRepositoryInterface $discussions
|
* @param DiscussionRepository $discussions
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionRepositoryInterface $discussions)
|
public function __construct(DiscussionRepository $discussions)
|
||||||
{
|
{
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Users\User;
|
||||||
|
|
||||||
class EloquentNotificationRepository implements NotificationRepositoryInterface
|
class NotificationRepository
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find a user's notifications.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @param int|null $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection
|
||||||
*/
|
*/
|
||||||
public function findByUser(User $user, $limit = null, $offset = 0)
|
public function findByUser(User $user, $limit = null, $offset = 0)
|
||||||
{
|
{
|
@@ -1,16 +0,0 @@
|
|||||||
<?php namespace Flarum\Core\Notifications;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
|
|
||||||
interface NotificationRepositoryInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Find a user's notifications.
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @param int|null $count
|
|
||||||
* @param int $start
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
public function findByUser(User $user, $count = null, $start = 0);
|
|
||||||
}
|
|
@@ -27,7 +27,7 @@ class NotificationSyncer
|
|||||||
protected $sentTo = [];
|
protected $sentTo = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NotificationRepositoryInterface
|
* @var NotificationRepository
|
||||||
*/
|
*/
|
||||||
protected $notifications;
|
protected $notifications;
|
||||||
|
|
||||||
@@ -37,11 +37,11 @@ class NotificationSyncer
|
|||||||
protected $mailer;
|
protected $mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param NotificationRepositoryInterface $notifications
|
* @param NotificationRepository $notifications
|
||||||
* @param NotificationMailer $mailer
|
* @param NotificationMailer $mailer
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NotificationRepositoryInterface $notifications,
|
NotificationRepository $notifications,
|
||||||
NotificationMailer $mailer
|
NotificationMailer $mailer
|
||||||
) {
|
) {
|
||||||
$this->notifications = $notifications;
|
$this->notifications = $notifications;
|
||||||
|
@@ -28,9 +28,5 @@ class NotificationsServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
|
||||||
'Flarum\Core\Notifications\NotificationRepositoryInterface',
|
|
||||||
'Flarum\Core\Notifications\EloquentNotificationRepository'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Commands;
|
<?php namespace Flarum\Core\Posts\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Core\Posts\Events\PostWillBeDeleted;
|
use Flarum\Core\Posts\Events\PostWillBeDeleted;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
|
|
||||||
@@ -9,14 +9,14 @@ class DeletePostHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PostRepositoryInterface
|
* @var PostRepository
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepositoryInterface $posts)
|
public function __construct(PostRepository $posts)
|
||||||
{
|
{
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Commands;
|
<?php namespace Flarum\Core\Posts\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Posts\PostRepositoryInterface;
|
use Flarum\Core\Posts\PostRepository;
|
||||||
use Flarum\Core\Posts\Events\PostWillBeSaved;
|
use Flarum\Core\Posts\Events\PostWillBeSaved;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
use Flarum\Core\Posts\CommentPost;
|
use Flarum\Core\Posts\CommentPost;
|
||||||
@@ -10,14 +10,14 @@ class EditPostHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PostRepositoryInterface
|
* @var PostRepository
|
||||||
*/
|
*/
|
||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PostRepositoryInterface $posts
|
* @param PostRepository $posts
|
||||||
*/
|
*/
|
||||||
public function __construct(PostRepositoryInterface $posts)
|
public function __construct(PostRepository $posts)
|
||||||
{
|
{
|
||||||
$this->posts = $posts;
|
$this->posts = $posts;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Posts\Commands;
|
<?php namespace Flarum\Core\Posts\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Posts\Events\PostWillBeSaved;
|
use Flarum\Core\Posts\Events\PostWillBeSaved;
|
||||||
use Flarum\Core\Discussions\DiscussionRepositoryInterface;
|
use Flarum\Core\Discussions\DiscussionRepository;
|
||||||
use Flarum\Core\Posts\CommentPost;
|
use Flarum\Core\Posts\CommentPost;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
use Flarum\Core\Notifications\NotificationSyncer;
|
use Flarum\Core\Notifications\NotificationSyncer;
|
||||||
@@ -11,7 +11,7 @@ class PostReplyHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DiscussionRepositoryInterface
|
* @var DiscussionRepository
|
||||||
*/
|
*/
|
||||||
protected $discussions;
|
protected $discussions;
|
||||||
|
|
||||||
@@ -21,10 +21,10 @@ class PostReplyHandler
|
|||||||
protected $notifications;
|
protected $notifications;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DiscussionRepositoryInterface $discussions
|
* @param DiscussionRepository $discussions
|
||||||
* @param NotificationSyncer $notifications
|
* @param NotificationSyncer $notifications
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionRepositoryInterface $discussions, NotificationSyncer $notifications)
|
public function __construct(DiscussionRepository $discussions, NotificationSyncer $notifications)
|
||||||
{
|
{
|
||||||
$this->discussions = $discussions;
|
$this->discussions = $discussions;
|
||||||
$this->notifications = $notifications;
|
$this->notifications = $notifications;
|
||||||
|
@@ -26,7 +26,7 @@ use Flarum\Core\Discussions\Search\Fulltext\DriverInterface;
|
|||||||
// 14. Api\Discussions\ShowAction: eager load mentions
|
// 14. Api\Discussions\ShowAction: eager load mentions
|
||||||
// 14. Serializers\DiscussionSerializer: load discussion-user state
|
// 14. Serializers\DiscussionSerializer: load discussion-user state
|
||||||
|
|
||||||
class EloquentPostRepository implements PostRepositoryInterface
|
class PostRepository
|
||||||
{
|
{
|
||||||
protected $fulltext;
|
protected $fulltext;
|
||||||
|
|
||||||
@@ -36,7 +36,14 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find a post by ID, optionally making sure it is visible to a certain
|
||||||
|
* user, or throw an exception.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @param \Flarum\Core\Users\User $actor
|
||||||
|
* @return \Flarum\Core\Posts\Post
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function findOrFail($id, User $actor = null)
|
public function findOrFail($id, User $actor = null)
|
||||||
{
|
{
|
||||||
@@ -50,7 +57,15 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find posts that match certain conditions, optionally making sure they
|
||||||
|
* are visible to a certain user, and/or using other criteria.
|
||||||
|
*
|
||||||
|
* @param array $where
|
||||||
|
* @param \Flarum\Core\Users\User|null $actor
|
||||||
|
* @param array $sort
|
||||||
|
* @param integer $count
|
||||||
|
* @param integer $start
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection
|
||||||
*/
|
*/
|
||||||
public function findWhere($where = [], User $actor = null, $sort = [], $count = null, $start = 0)
|
public function findWhere($where = [], User $actor = null, $sort = [], $count = null, $start = 0)
|
||||||
{
|
{
|
||||||
@@ -68,7 +83,12 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find posts by their IDs, optionally making sure they are visible to a
|
||||||
|
* certain user.
|
||||||
|
*
|
||||||
|
* @param array $ids
|
||||||
|
* @param \Flarum\Core\Users\User|null $actor
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection
|
||||||
*/
|
*/
|
||||||
public function findByIds(array $ids, User $actor = null)
|
public function findByIds(array $ids, User $actor = null)
|
||||||
{
|
{
|
||||||
@@ -80,7 +100,12 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find posts by matching a string of words against their content,
|
||||||
|
* optionally making sure they are visible to a certain user.
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param \Flarum\Core\Users\User|null $actor
|
||||||
|
* @return \Illuminate\Database\Eloquent\Collection
|
||||||
*/
|
*/
|
||||||
public function findByContent($string, User $actor = null)
|
public function findByContent($string, User $actor = null)
|
||||||
{
|
{
|
||||||
@@ -100,7 +125,14 @@ class EloquentPostRepository implements PostRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Get the position within a discussion where a post with a certain number
|
||||||
|
* is. If the post with that number does not exist, the index of the
|
||||||
|
* closest post to it will be returned.
|
||||||
|
*
|
||||||
|
* @param integer $discussionId
|
||||||
|
* @param integer $number
|
||||||
|
* @param \Flarum\Core\Users\User|null $actor
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getIndexForNumber($discussionId, $number, User $actor = null)
|
public function getIndexForNumber($discussionId, $number, User $actor = null)
|
||||||
{
|
{
|
@@ -1,63 +0,0 @@
|
|||||||
<?php namespace Flarum\Core\Posts;
|
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
|
||||||
|
|
||||||
interface PostRepositoryInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Find a post by ID, optionally making sure it is visible to a certain
|
|
||||||
* user, or throw an exception.
|
|
||||||
*
|
|
||||||
* @param integer $id
|
|
||||||
* @param \Flarum\Core\Users\User $actor
|
|
||||||
* @return \Flarum\Core\Posts\Post
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
|
||||||
*/
|
|
||||||
public function findOrFail($id, User $actor = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find posts that match certain conditions, optionally making sure they
|
|
||||||
* are visible to a certain user, and/or using other criteria.
|
|
||||||
*
|
|
||||||
* @param array $where
|
|
||||||
* @param \Flarum\Core\Users\User|null $actor
|
|
||||||
* @param array $sort
|
|
||||||
* @param integer $count
|
|
||||||
* @param integer $start
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
public function findWhere($where = [], User $actor = null, $sort = [], $count = null, $start = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find posts by their IDs, optionally making sure they are visible to a
|
|
||||||
* certain user.
|
|
||||||
*
|
|
||||||
* @param array $ids
|
|
||||||
* @param \Flarum\Core\Users\User|null $actor
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
public function findByIds(array $ids, User $actor = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find posts by matching a string of words against their content,
|
|
||||||
* optionally making sure they are visible to a certain user.
|
|
||||||
*
|
|
||||||
* @param string $string
|
|
||||||
* @param \Flarum\Core\Users\User|null $actor
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
|
||||||
public function findByContent($string, User $actor = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the position within a discussion where a post with a certain number
|
|
||||||
* is. If the post with that number does not exist, the index of the
|
|
||||||
* closest post to it will be returned.
|
|
||||||
*
|
|
||||||
* @param integer $discussionId
|
|
||||||
* @param integer $number
|
|
||||||
* @param \Flarum\Core\Users\User|null $actor
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
public function getIndexForNumber($discussionId, $number, User $actor = null);
|
|
||||||
}
|
|
@@ -60,9 +60,5 @@ class PostsServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
|
||||||
'Flarum\Core\Posts\PostRepositoryInterface',
|
|
||||||
'Flarum\Core\Posts\EloquentPostRepository'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Users\Events\UserWillBeSaved;
|
use Flarum\Core\Users\Events\UserWillBeSaved;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
use Flarum\Core\Exceptions\InvalidConfirmationTokenException;
|
use Flarum\Core\Exceptions\InvalidConfirmationTokenException;
|
||||||
@@ -11,14 +11,14 @@ class ConfirmEmailHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users)
|
public function __construct(UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Users\Events\AvatarWillBeDeleted;
|
use Flarum\Core\Users\Events\AvatarWillBeDeleted;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
use League\Flysystem\FilesystemInterface;
|
use League\Flysystem\FilesystemInterface;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ class DeleteAvatarHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
@@ -20,10 +20,10 @@ class DeleteAvatarHandler
|
|||||||
protected $uploadDir;
|
protected $uploadDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
* @param FilesystemInterface $uploadDir
|
* @param FilesystemInterface $uploadDir
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users, FilesystemInterface $uploadDir)
|
public function __construct(UserRepository $users, FilesystemInterface $uploadDir)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->uploadDir = $uploadDir;
|
$this->uploadDir = $uploadDir;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Users\User;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Users\Events\UserWillBeDeleted;
|
use Flarum\Core\Users\Events\UserWillBeDeleted;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
|
|
||||||
@@ -10,14 +10,14 @@ class DeleteUserHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users)
|
public function __construct(UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Users\User;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Users\Events\UserWillBeSaved;
|
use Flarum\Core\Users\Events\UserWillBeSaved;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
|
|
||||||
@@ -10,14 +10,14 @@ class EditUserHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users)
|
public function __construct(UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Users\PasswordToken;
|
use Flarum\Core\Users\PasswordToken;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Illuminate\Contracts\Mail\Mailer;
|
use Illuminate\Contracts\Mail\Mailer;
|
||||||
use Illuminate\Mail\Message;
|
use Illuminate\Mail\Message;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
@@ -11,7 +11,7 @@ use Flarum\Http\UrlGeneratorInterface;
|
|||||||
class RequestPasswordResetHandler
|
class RequestPasswordResetHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ class RequestPasswordResetHandler
|
|||||||
protected $mailer;
|
protected $mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
* @param Mailer $mailer
|
* @param Mailer $mailer
|
||||||
* @param UrlGeneratorInterface $url
|
* @param UrlGeneratorInterface $url
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users, Mailer $mailer, UrlGeneratorInterface $url)
|
public function __construct(UserRepository $users, Mailer $mailer, UrlGeneratorInterface $url)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
use Flarum\Core\Users\Events\AvatarWillBeSaved;
|
use Flarum\Core\Users\Events\AvatarWillBeSaved;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Support\DispatchesEvents;
|
use Flarum\Core\Support\DispatchesEvents;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use League\Flysystem\Adapter\Local;
|
use League\Flysystem\Adapter\Local;
|
||||||
@@ -15,7 +15,7 @@ class UploadAvatarHandler
|
|||||||
use DispatchesEvents;
|
use DispatchesEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
@@ -25,10 +25,10 @@ class UploadAvatarHandler
|
|||||||
protected $uploadDir;
|
protected $uploadDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
* @param FilesystemInterface $uploadDir
|
* @param FilesystemInterface $uploadDir
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users, FilesystemInterface $uploadDir)
|
public function __construct(UserRepository $users, FilesystemInterface $uploadDir)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->uploadDir = $uploadDir;
|
$this->uploadDir = $uploadDir;
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
<?php namespace Flarum\Core\Users\Search\Gambits;
|
<?php namespace Flarum\Core\Users\Search\Gambits;
|
||||||
|
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Search\Search;
|
use Flarum\Core\Search\Search;
|
||||||
use Flarum\Core\Search\GambitInterface;
|
use Flarum\Core\Search\GambitInterface;
|
||||||
|
|
||||||
class FulltextGambit implements GambitInterface
|
class FulltextGambit implements GambitInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users)
|
public function __construct(UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ use Flarum\Core\Search\AppliesParametersToSearch;
|
|||||||
use Flarum\Core\Search\GambitManager;
|
use Flarum\Core\Search\GambitManager;
|
||||||
use Flarum\Core\Search\SearchCriteria;
|
use Flarum\Core\Search\SearchCriteria;
|
||||||
use Flarum\Core\Search\SearchResults;
|
use Flarum\Core\Search\SearchResults;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Core\Users\Events\UserSearchWillBePerformed;
|
use Flarum\Core\Users\Events\UserSearchWillBePerformed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,15 +21,15 @@ class UserSearcher
|
|||||||
protected $gambits;
|
protected $gambits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GambitManager $gambits
|
* @param GambitManager $gambits
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
*/
|
*/
|
||||||
public function __construct(GambitManager $gambits, UserRepositoryInterface $users)
|
public function __construct(GambitManager $gambits, UserRepository $users)
|
||||||
{
|
{
|
||||||
$this->gambits = $gambits;
|
$this->gambits = $gambits;
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
|
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
class EloquentUserRepository implements UserRepositoryInterface
|
class UserRepository
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Get a new query builder for the users table.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
public function query()
|
public function query()
|
||||||
{
|
{
|
||||||
@@ -13,7 +15,14 @@ class EloquentUserRepository implements UserRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find a user by ID, optionally making sure it is visible to a certain
|
||||||
|
* user, or throw an exception.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param User $actor
|
||||||
|
* @return User
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function findOrFail($id, User $actor = null)
|
public function findOrFail($id, User $actor = null)
|
||||||
{
|
{
|
||||||
@@ -23,7 +32,10 @@ class EloquentUserRepository implements UserRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find a user by an identification (username or email).
|
||||||
|
*
|
||||||
|
* @param string $identification
|
||||||
|
* @return User|null
|
||||||
*/
|
*/
|
||||||
public function findByIdentification($identification)
|
public function findByIdentification($identification)
|
||||||
{
|
{
|
||||||
@@ -33,7 +45,10 @@ class EloquentUserRepository implements UserRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find a user by email.
|
||||||
|
*
|
||||||
|
* @param string $email
|
||||||
|
* @return User|null
|
||||||
*/
|
*/
|
||||||
public function findByEmail($email)
|
public function findByEmail($email)
|
||||||
{
|
{
|
||||||
@@ -41,7 +56,11 @@ class EloquentUserRepository implements UserRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Get the ID of a user with the given username.
|
||||||
|
*
|
||||||
|
* @param string $username
|
||||||
|
* @param User|null $actor
|
||||||
|
* @return integer|null
|
||||||
*/
|
*/
|
||||||
public function getIdForUsername($username, User $actor = null)
|
public function getIdForUsername($username, User $actor = null)
|
||||||
{
|
{
|
||||||
@@ -51,7 +70,12 @@ class EloquentUserRepository implements UserRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Find users by matching a string of words against their username,
|
||||||
|
* optionally making sure they are visible to a certain user.
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param User|null $actor
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getIdsForUsername($string, User $actor = null)
|
public function getIdsForUsername($string, User $actor = null)
|
||||||
{
|
{
|
@@ -1,58 +0,0 @@
|
|||||||
<?php namespace Flarum\Core\Users;
|
|
||||||
|
|
||||||
interface UserRepositoryInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get a new query builder for the users table.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function query();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a user by ID, optionally making sure it is visible to a certain
|
|
||||||
* user, or throw an exception.
|
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @param User $actor
|
|
||||||
* @return User
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
|
||||||
*/
|
|
||||||
public function findOrFail($id, User $actor = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a user by an identification (username or email).
|
|
||||||
*
|
|
||||||
* @param string $identification
|
|
||||||
* @return User|null
|
|
||||||
*/
|
|
||||||
public function findByIdentification($identification);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a user by email.
|
|
||||||
*
|
|
||||||
* @param string $email
|
|
||||||
* @return User|null
|
|
||||||
*/
|
|
||||||
public function findByEmail($email);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ID of a user with the given username.
|
|
||||||
*
|
|
||||||
* @param string $username
|
|
||||||
* @param User|null $actor
|
|
||||||
* @return integer|null
|
|
||||||
*/
|
|
||||||
public function getIdForUsername($username, User $actor = null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find users by matching a string of words against their username,
|
|
||||||
* optionally making sure they are visible to a certain user.
|
|
||||||
*
|
|
||||||
* @param string $string
|
|
||||||
* @param User|null $actor
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getIdsForUsername($string, User $actor = null);
|
|
||||||
}
|
|
@@ -41,11 +41,6 @@ class UsersServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
|
||||||
'Flarum\Core\Users\UserRepositoryInterface',
|
|
||||||
'Flarum\Core\Users\EloquentUserRepository'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->registerAvatarsFilesystem();
|
$this->registerAvatarsFilesystem();
|
||||||
$this->registerGambits();
|
$this->registerGambits();
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use Flarum\Api\Client;
|
use Flarum\Api\Client;
|
||||||
use Flarum\Forum\Events\UserLoggedIn;
|
use Flarum\Forum\Events\UserLoggedIn;
|
||||||
use Flarum\Core\Users\UserRepositoryInterface;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Flarum\Support\Action;
|
use Flarum\Support\Action;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Zend\Diactoros\Response\EmptyResponse;
|
use Zend\Diactoros\Response\EmptyResponse;
|
||||||
@@ -13,7 +13,7 @@ class LoginAction extends Action
|
|||||||
use WritesRememberCookie;
|
use WritesRememberCookie;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UserRepositoryInterface
|
* @var UserRepository
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
@@ -23,10 +23,10 @@ class LoginAction extends Action
|
|||||||
protected $apiClient;
|
protected $apiClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepository $users
|
||||||
* @param Client $apiClient
|
* @param Client $apiClient
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $users, Client $apiClient)
|
public function __construct(UserRepository $users, Client $apiClient)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
|
Reference in New Issue
Block a user