18
18
use Doctrine \Common \Persistence \ManagerRegistry ;
19
19
use Doctrine \ODM \PHPCR \DocumentManager ;
20
20
21
+ use Psr \Log \LoggerInterface ;
21
22
use Symfony \Component \Routing \Route as SymfonyRoute ;
22
23
use Symfony \Component \Routing \RouteCollection ;
23
24
use Symfony \Component \Routing \Exception \RouteNotFoundException ;
31
32
/**
32
33
* Loads routes from Doctrine PHPCR-ODM.
33
34
*
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
35
36
* provider for the NestedMatcher. (you could of course implement this
36
37
* interface in a repository class, if you need that)
37
38
*
@@ -44,10 +45,20 @@ class RouteProvider extends DoctrineProvider implements RouteProviderInterface
44
45
*/
45
46
private $ candidatesStrategy ;
46
47
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
+ ) {
49
59
parent ::__construct ($ managerRegistry , $ className );
50
60
$ this ->candidatesStrategy = $ candidatesStrategy ;
61
+ $ this ->logger = $ logger ;
51
62
}
52
63
53
64
/**
@@ -79,11 +90,9 @@ public function getRouteCollectionForRequest(Request $request)
79
90
}
80
91
}
81
92
} 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
+ }
87
96
}
88
97
89
98
return $ collection ;
0 commit comments