Skip to content
Snippets Groups Projects
Commit 1574594c authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Make cover router factory more error-tolerant.

- Allows the cover router to operate in more contexts (CLI vs. web)
parent e2b698f5
No related merge requests found
...@@ -61,8 +61,15 @@ class RouterFactory implements FactoryInterface ...@@ -61,8 +61,15 @@ class RouterFactory implements FactoryInterface
if (!empty($options)) { if (!empty($options)) {
throw new \Exception('Unexpected options sent to factory.'); throw new \Exception('Unexpected options sent to factory.');
} }
$base = $container->get('ControllerPluginManager')->get('url') // Try to get the base URL from the controller plugin; fail over to
->fromRoute('cover-show'); // the view helper if that doesn't work.
try {
$base = $container->get('ControllerPluginManager')->get('url')
->fromRoute('cover-show');
} catch (\Exception $e) {
$base = $container->get('ViewRenderer')->plugin('url')
->__invoke('cover-show');
}
return new $requestedName($base); return new $requestedName($base);
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment