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
I was able to handle this case by sort of re-implementing the renderAssets method in AsseticBundle/Listener.php but perhaps there should be some sort of configuration option to handle this case. My fix for the issue is below:
Application/Module.php
class Module
{
publicfunctiononBootstrap(MvcEvent$e)
{
$e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'handleDispatchError'), 32);
}
publicfunctionhandleDispatchError(MvcEvent$e)
{
$sm = $e->getApplication()->getServiceManager();
if ($e->getName() != MvcEvent::EVENT_DISPATCH_ERROR)
return;
$config = $sm->get('AsseticConfiguration');
if ($e->getName() === MvcEvent::EVENT_DISPATCH_ERROR) {
$error = $e->getError();
if ($error && !in_array($error, $config->getAcceptableErrors())) {
// break if not an acceptable errorreturn;
}
}
$response = $e->getResponse();
if (!$response) {
$response = newResponse();
$e->setResponse($response);
}
$routeMatch = $e->getRouteMatch();
if ($routeMatch)
return;
/** @var $asseticService \AsseticBundle\Service */$asseticService = $sm->get('AsseticService');
$asseticService->setRouteName('error_404');
$asseticService->setControllerName('Application\Controller\Index');
$asseticService->setActionName('error_' . uniqid());
// Create all objects$asseticService->build();
// Init assets for modules$asseticService->setupRenderer($sm->get('ViewRenderer'));
}
}
Regular 404s where a route is matched but there is no corresponding method to handle the route work just fine.
The case where a route can not be matched are not handled however, like:
I was able to handle this case by sort of re-implementing the renderAssets method in AsseticBundle/Listener.php but perhaps there should be some sort of configuration option to handle this case. My fix for the issue is below:
Application/Module.php
Snippet from module.config.php
The text was updated successfully, but these errors were encountered: