Issue #2795395 by Yogesh Pawar, tresti88, marvin_B8, shashikant_chauhan, tstoeckler, dawehner: PathRootsSubscriber breaks if there are no routes
parent
3fff17d04a
commit
184a05e06c
|
@ -20,7 +20,7 @@ class PathRootsSubscriber implements EventSubscriberInterface {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $pathRoots;
|
||||
protected $pathRoots = [];
|
||||
|
||||
/**
|
||||
* The state key value store.
|
||||
|
@ -58,7 +58,7 @@ class PathRootsSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
public function onRouteFinished() {
|
||||
$this->state->set('router.path_roots', array_keys($this->pathRoots));
|
||||
unset($this->pathRoots);
|
||||
$this->pathRoots = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,6 +43,11 @@ class PathRootsSubscriberTest extends UnitTestCase {
|
|||
* @covers ::onRouteFinished
|
||||
*/
|
||||
public function testSubscribing() {
|
||||
|
||||
// Ensure that onRouteFinished can be called without throwing notices
|
||||
// when no path roots got set.
|
||||
$this->pathRootsSubscriber->onRouteFinished();
|
||||
|
||||
$route_collection = new RouteCollection();
|
||||
$route_collection->add('test_route1', new Route('/test/bar'));
|
||||
$route_collection->add('test_route2', new Route('/test/baz'));
|
||||
|
|
Loading…
Reference in New Issue