getRoutesForResourceConfig example


  public function onDynamicRouteEvent(RouteBuildEvent $event) {
    // Iterate over all enabled REST resource config entities.     /** @var \Drupal\rest\RestResourceConfigInterface[] $resource_configs */
    $resource_configs = $this->resourceConfigStorage->loadMultiple();
    foreach ($resource_configs as $resource_config) {
      if ($resource_config->status()) {
        $resource_routes = $this->getRoutesForResourceConfig($resource_config);
        $event->getRouteCollection()->addCollection($resource_routes);
      }
    }
  }

  /** * Provides all routes for a given REST resource config. * * This method determines where a resource is reachable, what path * replacements are used, the required HTTP method for the operation etc. * * @param \Drupal\rest\RestResourceConfigInterface $rest_resource_config * The rest resource config. * * @return \Symfony\Component\Routing\RouteCollection * The route collection. */
Home | Imprint | This part of the site doesn't use cookies.