A fix for "Target class [web] does not exist." and an update to the Demo to work with custom url_prefix and middlewares #1026
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the change:
Issue 1:
if (config('lfm.use_package_routes')) is true then a route with prefix
'filemanger'
and middleware['web','auth’]
is appliedin this case if the user doesn’t have
web
middleware he will getTarget class [web] does not exist.
error.The suggested solution:
this can be fixed by adding
middlewares
array in config, if present it will take the values or fallback to['web','auth’]
making the prefix variable is also preferable by adding
url_prefix
, so ifurl_prefix
is present in config the route will take that value, else it will fallback tofilemanager
Issue 2:
The demo is using
/filemanger
route, but in case the user creates custom route with prefix different than/filemanger
(and sets thelfm.use_package_routes
to false) the demo will no longer work because it will not find any route named/filemanger
The suggested solution:
This can be fixed by initializing the variable
route_prefix
in the demo view with theurl_prefix
value from config if present, then fallback to/filemanager
if no value is presentRecap:
Optional
url_prefix
andmiddlewares
are added to config file, so in case ofuse_package_routes
is true, the route generated will try to getprefix
value andmiddleware
array from config file before falling back to static values.Also if the user creates a route with a custom prefix, he can set that prefix in config, so it will be used in the demo without failing if
use_package_routes
is false.