Updating For Beta 15
Beta 15 features multiple new extenders, a total redesign of the admin dashboard, and several other interesting new features for extensions. As before, we have done our best to provide backwards compatibility layers, and we recommend switching away from deprecated systems as soon as possible to make your extensions more stable.
If you need help applying these changes or using new features, please start a discussion on the community forum or Discord chat.
New Features / Deprecations
Extenders
Flarum\Api\Event\WillGetDataandFlarum\Api\Event\WillSerializeDatahave been deprecated, theApiControllerextender should be used insteadFlarum\Api\Event\SerializingandFlarum\Event\GetApiRelationshiphave been deprecated, theApiSerializerextender should be used insteadFlarum\Formatter\Event\Parsinghas been deprecated, theparsemethod of theFormatterextender should be used insteadFlarum\Formatter\Event\Renderinghas been deprecated, therendermethod of theFormatterextender should be used insteadFlarum\Notification\Event\Sendinghas been deprecated, thedrivermethod of theNotificationextender should be used instead- Please note that the new notification driver system is not an exact analogue of the old
Sendingevent, as it can only add new drivers, not change the functionality of the default notification bell alert driver. If your extension needs to modify how or to whom notifications are sent, you may need to replaceFlarum\Notification\NotificationSynceron the service provider level
- Please note that the new notification driver system is not an exact analogue of the old
Flarum\Event\ConfigureNotificationTypeshas been deprecated, thetypemethod of theNotificationextender should be used insteadFlarum\Event\ConfigurePostTypeshas been deprecated, thetypemethod of thePostextender should be used insteadFlarum\Post\Event\CheckingForFloodinghas been deprecated, as well asFlarum\Post\Floodgate. They have been replaced with a middleware-based throttling system that applies to ALL requests to /api/*, and can be configured via theThrottleApiextender. Please see our api-throttling documentation for more information.Flarum\Event\ConfigureUserPreferenceshas been deprecated, theregisterPreferencemethod of theUserextender should be used insteadFlarum\Foundation\Event\Validatinghas been deprecated, theconfiguremethod of theValidatorextender should be used insteadThe Policy system has been reworked a bit to be more intuitive. Previously, policies contained both actual policies, which determine whether a user can perform some ability, and model visibility scopers, which allowed efficient restriction of queries to only items that users have access to. See the authorization documentation for more information on how to use the new systems. Now:
Flarum\Event\ScopeModelVisibilityhas been deprecated. New scopers can be registered via theModelVisibilityextender, and anyEloquent\Builderquery can be scoped by calling thewhereVisibleTomethod on it, with the ability in question as an optional 2nd argument (defaults toview).Flarum\Event\GetPermissionhas been deprecated. Policies can be registered via thePolicyextender.Flarum\User\User::canhas not changed. Please note that the new policies must return one of$this->allow(),$this->deny(),$this->forceAllow(),$this->forceDeny(), not a boolean.
A
ModelUrlextender has been added, allowing new slug drivers to be registered. This accompanies Flarum's new slug driving system, which allows for extensions to define custom slugging strategies for sluggable models. The extender supports sluggable models outside of Flarum core. Please see our model slugging documentation for more information.A
Settingsextender has been added, whoseserializeToForummethod makes it easy to serialize a setting to the forum.A
ServiceProviderextender has been added. This should be used with extreme caution for advanced use cases only, where there is no alternative. Please note that the service provider layer is not considered public API, and is liable to change at any time, without notice.
Admin UX Redesign
The admin dashboard has been completely redesigned, with a focus on providing navbar pages for each extension. The API for extensions to register settings, permissions, and custom pages has also been greatly simplified. You can also now update your extension's composer.json to provide links for funding, support, website, etc that will show up on your extension's admin page. Please see our Admin JS documentation for more information on how to use the new system.
Other New Features
- On the backend, the route name is now available via
$request->getAttribute('routeName')for controllers, and for middleware that run afterFlarum\Http\Middleware\ResolveRoute.php. Flarum\Api\Controller\UploadImageController.phpcan now be used as a base class for controllers that upload images (like for the logo and favicon).- Automatic browser scroll restoration can now be disabled for individual pages see our frontend page documentation for more info.
Breaking Changes
- The following deprecated frontend BC layers were removed:
momentjsno longer works as an alias fordayjsthis.propsandthis.initPropsno longer aliasthis.attrsandthis.initAttrsfor theComponentbase classm.withAttrandm.streamno longer aliasflarum/utils/withAttrandflarum/utils/Streamapp.cache.discussionListhas been removedthis.contentandthis.editorhave been removed fromComposerBodythis.component,this.content, andthis.valuehave been removed fromComposerState
- The following deprecated backend BC layers were removed:
- The
publicPath,storagePath, andvendorPathmethods ofFlarum\Foundation\Applicationhave been removed - The
base_path,public_path, andstorage_pathglobal helpers have been removed - The
getEmailSubjectmethod ofFlarum\Notification\MailableInterfaceMUST now take a translator instance as an argument Flarum\User\AssertPermissionTraithas been removed, the analogous methods onFlarum\User\Usershould be used instead- The
Flarum\Event\PrepareUserGroupsevent has been removed, use theUserextender instead - The
Flarum\User\Event\GetDisplayNameevent has been removed, use the display name driver feature of theUserextender instead
- The