You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because event listeners are instantiated right when they are registered, anything resolved in its constructor will be immediately resolved early in the forum lifecycle.
This means that the UrlGenerator is resolved at the time time your extend.php is read, which in turn resolves the route collection, which in turn prevents any extension that's read after yours to register new routes.
You should instead resolve the UrlGenerator, and possibly all other classes used in the constructor directly in the sendWebPushNotification method using $url = app(UrlGenerator::class).
This will also improve performance because those will be resolved only when your event triggers, instead of every time Flarum code runs.
The text was updated successfully, but these errors were encountered:
clarkwinkelmann
added a commit
to clarkwinkelmann/flarum-ext-web-push
that referenced
this issue
Nov 11, 2019
Hello,
Following the issue reported here https://discuss.flarum.org/d/7026-linguist-customize-translations-with-ease/57 I investigated why your extension might break compatibility with Linguist.
I noticed that you resolve the
UrlGenerator
in the constructor of an event listener hereflarum-ext-web-push/src/Listener/SendWebPushNotification.php
Line 24 in e13f0d7
Because event listeners are instantiated right when they are registered, anything resolved in its constructor will be immediately resolved early in the forum lifecycle.
This means that the
UrlGenerator
is resolved at the time time yourextend.php
is read, which in turn resolves the route collection, which in turn prevents any extension that's read after yours to register new routes.You should instead resolve the UrlGenerator, and possibly all other classes used in the constructor directly in the
sendWebPushNotification
method using$url = app(UrlGenerator::class)
.This will also improve performance because those will be resolved only when your event triggers, instead of every time Flarum code runs.
The text was updated successfully, but these errors were encountered: