예제 #1
0
 /**
  * @covers ::resetRouteMatch
  */
 public function testResetRouteMatch()
 {
     $route = new Route('/test-route/{foo}');
     $request = new Request();
     $request->attributes->set(RouteObjectInterface::ROUTE_NAME, 'test_route');
     $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $route);
     $request_stack = new RequestStack();
     $request_stack->push($request);
     $current_route_match = new CurrentRouteMatch($request_stack);
     $route_name = $current_route_match->getRouteName();
     $this->assertSame('test_route', $route_name);
     // Replace the matched route on the request.
     $request->attributes->set(RouteObjectInterface::ROUTE_NAME, NULL);
     $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, NULL);
     // Reset the route match.
     $current_route_match->resetRouteMatch();
     $route_name = $current_route_match->getRouteName();
     $this->assertNull($route_name);
 }
 /**
  * Checks whether a route is the "Latest version" tab of a node.
  *
  * @param \Drupal\node\Entity\Node $node
  *   A node.
  *
  * @return bool
  *  True if the current route is the latest version tab of the given node.
  */
 public function isLatestVersionPage(Node $node)
 {
     return $this->routeMatch->getRouteName() == 'entity.node.latest_version' && ($pageNode = $this->routeMatch->getParameter('node')) && $pageNode->id() == $node->id();
 }