Commit 184a05e0 authored by alexpott's avatar alexpott

Issue #2795395 by Yogesh Pawar, tresti88, marvin_B8, shashikant_chauhan,...

Issue #2795395 by Yogesh Pawar, tresti88, marvin_B8, shashikant_chauhan, tstoeckler, dawehner: PathRootsSubscriber breaks if there are no routes
parent 3fff17d0
......@@ -20,7 +20,7 @@ class PathRootsSubscriber implements EventSubscriberInterface {
*
* @var array
*/
protected $pathRoots;
protected $pathRoots = [];
/**
* The state key value store.
......@@ -58,7 +58,7 @@ public function onRouteAlter(RouteBuildEvent $event) {
*/
public function onRouteFinished() {
$this->state->set('router.path_roots', array_keys($this->pathRoots));
unset($this->pathRoots);
$this->pathRoots = [];
}
/**
......
......@@ -43,6 +43,11 @@ protected function setUp() {
* @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'));
......
Markdown is supported
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