<commit_before><?php namespace Flarum\Sticky;

use Flarum\Support\ServiceProvider;
use Illuminate\Contracts\Events\Dispatcher;

class StickyServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot(Dispatcher $events)
    {
        $events->subscribe('Flarum\Sticky\Handlers\StickySaver');
        $events->subscribe('Flarum\Sticky\Handlers\StickySearchModifier');
        $events->subscribe('Flarum\Sticky\Handlers\DiscussionStickiedNotifier');

        $this->forumAssets([
            __DIR__.'/../js/dist/extension.js',
            __DIR__.'/../less/sticky.less'
        ]);

        $this->postType('Flarum\Sticky\DiscussionStickiedPost');

        $this->serializeAttributes('Flarum\Api\Serializers\DiscussionSerializer', function (&$attributes, $model, $serializer) {
            $attributes['isSticky'] = (bool) $model->is_sticky;
            $attributes['canSticky'] = (bool) $model->can($serializer->actor->getUser(), 'sticky');
        });

        $this->discussionGambit('Flarum\Sticky\StickyGambit');

        $this->notificationType('Flarum\Sticky\DiscussionStickiedNotification', ['alert' => true]);

        $this->permission('discussion.sticky');
    }
}<commit_msg>Update for new extension API<commit_after><?php namespace Flarum\Sticky;

use Flarum\Support\ServiceProvider;
use Flarum\Extend\EventSubscribers;
use Flarum\Extend\ForumAssets;
use Flarum\Extend\PostType;
use Flarum\Extend\SerializeAttributes;
use Flarum\Extend\DiscussionGambit;
use Flarum\Extend\NotificationType;
use Flarum\Extend\Permission;

class StickyServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->extend(
            new EventSubscribers([
                'Flarum\Sticky\Handlers\StickySaver',
                'Flarum\Sticky\Handlers\StickySearchModifier',
                'Flarum\Sticky\Handlers\DiscussionStickiedNotifier'
            ]),

            new ForumAssets([
                __DIR__.'/../js/dist/extension.js',
                __DIR__.'/../less/sticky.less'
            ]),

            new PostType('Flarum\Sticky\DiscussionStickiedPost'),

            new SerializeAttributes('Flarum\Api\Serializers\DiscussionSerializer', function (&$attributes, $model, $serializer) {
                $attributes['isSticky'] = (bool) $model->is_sticky;
                $attributes['canSticky'] = (bool) $model->can($serializer->actor->getUser(), 'sticky');
            }),

            new DiscussionGambit('Flarum\Sticky\StickyGambit'),

            (new NotificationType('Flarum\Sticky\DiscussionStickiedNotification'))->enableByDefault('alert'),

            new Permission('discussion.sticky')
        );
    }
}
{'fraction_non_alphanumeric': 0.1366120218579235, 'fraction_numerical': 0.0, 'mean_word_length': 2.968208092485549, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7222997', 'n_tokens_mistral': 844, 'n_tokens_neox': 784, 'n_words': 106}