mirror of
https://github.com/flarum/framework.git
synced 2024-12-13 07:03:35 +08:00
4b126d9f4c
* refactor: move gambits to frontend (#3885) * refactor: move gambits to frontend * test: GambitManager * refactor: merge filterer and searcher concepts (#3892) * chore: drop remaining backend regex gambits * refactor: merge filterer & searcher concept * refactor: adapt extenders * refactor: no longer need to push gambits to `q` * refactor: filters to gambits * refactor: drop shred `Query` namespace * chore: cleanup * chore: leftover gambit references on the backend (#3894) * chore: leftover gambit references on the backend * chore: namespace * feat: search driver backend extension API (#3902) * feat: first iteration of search drivers * feat: indexer API & tweaks * feat: changes after POC driver * fix: properly fire custom observables * chore: remove debugging code * fix: phpstan * fix: custom eloquent events * chore: drop POC usage * test: indexer extender API * fix: extension searcher fails without filters * fix: phpstan * fix: frontend created gambit * feat: advanced page and localized driver settings (#3905) * feat: allow getting total search results and replacing filters (#3906) * feat: allow accessing total search results * feat: allow replacing filters * chore: phpstan
63 lines
2.1 KiB
PHP
63 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
use Flarum\Api\Serializer\BasicDiscussionSerializer;
|
|
use Flarum\Api\Serializer\DiscussionSerializer;
|
|
use Flarum\Discussion\Discussion;
|
|
use Flarum\Discussion\Event\Saving;
|
|
use Flarum\Discussion\Search\DiscussionSearcher;
|
|
use Flarum\Extend;
|
|
use Flarum\Lock\Access;
|
|
use Flarum\Lock\Event\DiscussionWasLocked;
|
|
use Flarum\Lock\Event\DiscussionWasUnlocked;
|
|
use Flarum\Lock\Filter\LockedFilter;
|
|
use Flarum\Lock\Listener;
|
|
use Flarum\Lock\Notification\DiscussionLockedBlueprint;
|
|
use Flarum\Lock\Post\DiscussionLockedPost;
|
|
use Flarum\Search\Database\DatabaseSearchDriver;
|
|
|
|
return [
|
|
(new Extend\Frontend('forum'))
|
|
->js(__DIR__.'/js/dist/forum.js')
|
|
->css(__DIR__.'/less/forum.less'),
|
|
|
|
(new Extend\Frontend('admin'))
|
|
->js(__DIR__.'/js/dist/admin.js'),
|
|
|
|
new Extend\Locales(__DIR__.'/locale'),
|
|
|
|
(new Extend\Notification())
|
|
->type(DiscussionLockedBlueprint::class, BasicDiscussionSerializer::class, ['alert']),
|
|
|
|
(new Extend\Model(Discussion::class))
|
|
->cast('is_locked', 'bool'),
|
|
|
|
(new Extend\ApiSerializer(DiscussionSerializer::class))
|
|
->attribute('isLocked', function (DiscussionSerializer $serializer, Discussion $discussion) {
|
|
return $discussion->is_locked;
|
|
})
|
|
->attribute('canLock', function (DiscussionSerializer $serializer, Discussion $discussion) {
|
|
return $serializer->getActor()->can('lock', $discussion);
|
|
}),
|
|
|
|
(new Extend\Post())
|
|
->type(DiscussionLockedPost::class),
|
|
|
|
(new Extend\Event())
|
|
->listen(Saving::class, Listener\SaveLockedToDatabase::class)
|
|
->listen(DiscussionWasLocked::class, Listener\CreatePostWhenDiscussionIsLocked::class)
|
|
->listen(DiscussionWasUnlocked::class, Listener\CreatePostWhenDiscussionIsUnlocked::class),
|
|
|
|
(new Extend\Policy())
|
|
->modelPolicy(Discussion::class, Access\DiscussionPolicy::class),
|
|
|
|
(new Extend\SearchDriver(DatabaseSearchDriver::class))
|
|
->addFilter(DiscussionSearcher::class, LockedFilter::class),
|
|
];
|