mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +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
62 lines
2.0 KiB
PHP
62 lines
2.0 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.
|
|
*/
|
|
|
|
namespace Flarum\Nicknames;
|
|
|
|
use Flarum\Api\Serializer\UserSerializer;
|
|
use Flarum\Extend;
|
|
use Flarum\Nicknames\Access\UserPolicy;
|
|
use Flarum\Search\Database\DatabaseSearchDriver;
|
|
use Flarum\User\Event\Saving;
|
|
use Flarum\User\Search\UserSearcher;
|
|
use Flarum\User\User;
|
|
use Flarum\User\UserValidator;
|
|
|
|
return [
|
|
(new Extend\Frontend('forum'))
|
|
->js(__DIR__.'/js/dist/forum.js'),
|
|
|
|
(new Extend\Frontend('admin'))
|
|
->js(__DIR__.'/js/dist/admin.js'),
|
|
|
|
new Extend\Locales(__DIR__.'/locale'),
|
|
|
|
(new Extend\Model(User::class))
|
|
->cast('nickname', 'string'),
|
|
|
|
(new Extend\User())
|
|
->displayNameDriver('nickname', NicknameDriver::class),
|
|
|
|
(new Extend\Event())
|
|
->listen(Saving::class, SaveNicknameToDatabase::class),
|
|
|
|
(new Extend\ApiSerializer(UserSerializer::class))
|
|
->attribute('canEditNickname', function (UserSerializer $serializer, User $user) {
|
|
return $serializer->getActor()->can('editNickname', $user);
|
|
}),
|
|
|
|
(new Extend\Settings())
|
|
->default('flarum-nicknames.set_on_registration', true)
|
|
->default('flarum-nicknames.min', 1)
|
|
->default('flarum-nicknames.max', 150)
|
|
->default('display_name_driver', 'username')
|
|
->serializeToForum('displayNameDriver', 'display_name_driver')
|
|
->serializeToForum('setNicknameOnRegistration', 'flarum-nicknames.set_on_registration', 'boolval')
|
|
->serializeToForum('randomizeUsernameOnRegistration', 'flarum-nicknames.random_username', 'boolval'),
|
|
|
|
(new Extend\Validator(UserValidator::class))
|
|
->configure(AddNicknameValidation::class),
|
|
|
|
(new Extend\SearchDriver(DatabaseSearchDriver::class))
|
|
->setFulltext(UserSearcher::class, NicknameFullTextFilter::class),
|
|
|
|
(new Extend\Policy())
|
|
->modelPolicy(User::class, UserPolicy::class),
|
|
];
|