1818use Doctrine \Common \Persistence \ManagerRegistry ;
1919use Doctrine \ODM \PHPCR \DocumentManager ;
2020
21+ use Psr \Log \LoggerInterface ;
2122use Symfony \Component \Routing \Route as SymfonyRoute ;
2223use Symfony \Component \Routing \RouteCollection ;
2324use Symfony \Component \Routing \Exception \RouteNotFoundException ;
3132/**
3233 * Loads routes from Doctrine PHPCR-ODM.
3334 *
34- * This is <strong>NOT</strong> not a doctrine repository but just the route
35+ * This is <strong>NOT</strong> a doctrine repository but just the route
3536 * provider for the NestedMatcher. (you could of course implement this
3637 * interface in a repository class, if you need that)
3738 *
@@ -44,10 +45,20 @@ class RouteProvider extends DoctrineProvider implements RouteProviderInterface
4445 */
4546 private $ candidatesStrategy ;
4647
47- public function __construct (ManagerRegistry $ managerRegistry , CandidatesInterface $ candidatesStrategy , $ className = null )
48- {
48+ /**
49+ * @var LoggerInterface
50+ */
51+ private $ logger ;
52+
53+ public function __construct (
54+ ManagerRegistry $ managerRegistry ,
55+ CandidatesInterface $ candidatesStrategy ,
56+ $ className = null ,
57+ LoggerInterface $ logger = null
58+ ) {
4959 parent ::__construct ($ managerRegistry , $ className );
5060 $ this ->candidatesStrategy = $ candidatesStrategy ;
61+ $ this ->logger = $ logger ;
5162 }
5263
5364 /**
@@ -79,11 +90,9 @@ public function getRouteCollectionForRequest(Request $request)
7990 }
8091 }
8192 } catch (RepositoryException $ e ) {
82- // TODO: how to determine whether this is a relevant exception or not?
83- // https://github.com/symfony-cmf/RoutingBundle/issues/143
84- // for example, getting /my//test (note the double /) is just an invalid path
85- // and means another router might handle this.
86- // but if the PHPCR backend is down for example, we want to alert the user
93+ if ($ this ->logger ) {
94+ $ this ->logger ->critical ($ e );
95+ }
8796 }
8897
8998 return $ collection ;
0 commit comments