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
We want to render specific template when error is thrown from the plugin. For that we have ErrorController inside main plugin namespace(let's call it Company\Plugin\Controller), so it would be Company\Plugin1\Controller\ErrorController.
Now when we throw exception from prefix route's controller i.e. Company\Plugin\Controller\Prefix1\FooController or Company\Plugin\Controller\Prefix2\BarController, it doesn't take plugin's Company\Plugin1\Controller\ErrorController into account. But, it calls core's controller(App\Controller\ErrorController).
Upon digging into ControllerFactory, it tries to find Company\Plugin\Controller\Prefix1\ErrorController.
// inside Cake\Controller\ControllerFactorypublicfunctiongetControllerClass(ServerRequest$request): ?string
{
...// here in $namespace: Controller/Prefix1 (or Controller/Prefix2)returnApp::className($pluginPath . $controller, $namespace, 'Controller');
}
Expected behavior
Plugin's ErrorController(Company\Plugin1\Controller\ErrorController in our example) should be called.
CakePHP Version
4.3.11
PHP Version
No response
The text was updated successfully, but these errors were encountered:
There isn't currently support for a controller cascade from routing prefixes to the plugin. We could rework the logic in WebExceptionRenderer to attempt the plugin (without prefix) error controller if the current route information includes a prefix.
Moving to a feature as the behavior you're describing does not currently exist. As a workaround you could add a subclass of your plugin error controller to each routing prefix.
When within a plugin + prefix routing scope if there isn't an
ErrorController for the plugin + prefix, fallback to just the plugin
before falling back to the application/core error controller.
This allows plugins to provide error handling for all of their routes if
they need it.
Fixes#17025
Description
Current behavior
We want to render specific template when error is thrown from the plugin. For that we have
ErrorController
inside main plugin namespace(let's call itCompany\Plugin\Controller
), so it would beCompany\Plugin1\Controller\ErrorController
.Now when we throw exception from prefix route's controller i.e.
Company\Plugin\Controller\Prefix1\FooController
orCompany\Plugin\Controller\Prefix2\BarController
, it doesn't take plugin'sCompany\Plugin1\Controller\ErrorController
into account. But, it calls core's controller(App\Controller\ErrorController
).Upon digging into
ControllerFactory
, it tries to findCompany\Plugin\Controller\Prefix1\ErrorController
.Expected behavior
Plugin's ErrorController(
Company\Plugin1\Controller\ErrorController
in our example) should be called.CakePHP Version
4.3.11
PHP Version
No response
The text was updated successfully, but these errors were encountered: