mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 01:36:53 +08:00
Update some APIs
- Rename DiscussionSearchWillBePerformed to ConfigureDiscussionSearch, same with users - Add some handy methods
This commit is contained in:
parent
663de42917
commit
1c3fda4a71
|
@ -16,7 +16,7 @@ use Flarum\Core\Search\SearchCriteria;
|
|||
use Flarum\Core\Search\GambitManager;
|
||||
use Flarum\Core\Repository\DiscussionRepository;
|
||||
use Flarum\Core\Repository\PostRepository;
|
||||
use Flarum\Event\DiscussionSearchWillBePerformed;
|
||||
use Flarum\Event\ConfigureDiscussionSearch;
|
||||
use Flarum\Core\Search\SearchResults;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
|
@ -82,7 +82,7 @@ class DiscussionSearcher
|
|||
$this->applyLimit($search, $limit + 1);
|
||||
|
||||
// TODO: inject dispatcher
|
||||
event(new DiscussionSearchWillBePerformed($search, $criteria));
|
||||
event(new ConfigureDiscussionSearch($search, $criteria));
|
||||
|
||||
// Execute the search query and retrieve the results. We get one more
|
||||
// results than the user asked for, so that we can say if there are more
|
||||
|
|
|
@ -15,7 +15,7 @@ use Flarum\Core\Search\GambitManager;
|
|||
use Flarum\Core\Search\SearchCriteria;
|
||||
use Flarum\Core\Search\SearchResults;
|
||||
use Flarum\Core\Repository\UserRepository;
|
||||
use Flarum\Event\UserSearchWillBePerformed;
|
||||
use Flarum\Event\ConfigureUserSearch;
|
||||
|
||||
/**
|
||||
* Takes a UserSearchCriteria object, performs a search using gambits,
|
||||
|
@ -68,7 +68,7 @@ class UserSearcher
|
|||
$this->applyOffset($search, $offset);
|
||||
$this->applyLimit($search, $limit + 1);
|
||||
|
||||
event(new UserSearchWillBePerformed($search, $criteria));
|
||||
event(new ConfigureUserSearch($search, $criteria));
|
||||
|
||||
// Execute the search query and retrieve the results. We get one more
|
||||
// results than the user asked for, so that we can say if there are more
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Flarum\Event;
|
|||
use Flarum\Core\Search\Discussion\DiscussionSearch;
|
||||
use Flarum\Core\Search\SearchCriteria;
|
||||
|
||||
class DiscussionSearchWillBePerformed
|
||||
class ConfigureDiscussionSearch
|
||||
{
|
||||
/**
|
||||
* @var DiscussionSearch
|
|
@ -37,4 +37,13 @@ class ConfigureModelDates
|
|||
$this->model = $model;
|
||||
$this->dates = &$dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $model
|
||||
* @return bool
|
||||
*/
|
||||
public function isModel($model)
|
||||
{
|
||||
return $this->model instanceof $model;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Flarum\Event;
|
|||
use Flarum\Core\Search\User\UserSearch;
|
||||
use Flarum\Core\Search\SearchCriteria;
|
||||
|
||||
class UserSearchWillBePerformed
|
||||
class ConfigureUserSearch
|
||||
{
|
||||
/**
|
||||
* @var UserSearch
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
namespace Flarum\Event;
|
||||
|
||||
use DateTime;
|
||||
use Flarum\Api\Serializer\AbstractSerializer;
|
||||
|
||||
/**
|
||||
|
@ -67,4 +68,15 @@ class PrepareApiAttributes
|
|||
{
|
||||
return $this->serializer instanceof $serializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime|null $date
|
||||
* @return string|null
|
||||
*/
|
||||
public function formatDate(DateTime $date = null)
|
||||
{
|
||||
if ($date) {
|
||||
return $date->format(DateTime::RFC3339);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user