function RoutingFixtures::contentRouteCollection

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php \Drupal\Tests\Core\Routing\RoutingFixtures::contentRouteCollection()
  2. 10 core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php \Drupal\Tests\Core\Routing\RoutingFixtures::contentRouteCollection()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php \Drupal\Tests\Core\Routing\RoutingFixtures::contentRouteCollection()

Returns a Content-type restricted set of routes for testing.

Return value

\Symfony\Component\Routing\RouteCollection

File

core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php, line 215

Class

RoutingFixtures
Utility methods to generate sample data, database configuration, etc.

Namespace

Drupal\Tests\Core\Routing

Code

public function contentRouteCollection() {
    $collection = new RouteCollection();
    $route = new Route('path/three');
    $route->setMethods([
        'POST',
    ]);
    $route->setRequirement('_content_type_format', 'json');
    $collection->add('route_f', $route);
    $route = new Route('path/three');
    $route->setMethods([
        'PATCH',
    ]);
    $route->setRequirement('_content_type_format', 'xml');
    $collection->add('route_g', $route);
    return $collection;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.