You are here

public function XmlSitemapEnginesTestController::render in XML sitemap 8

Same name and namespace in other branches
  1. 2.x xmlsitemap_engines/tests/modules/xmlsitemap_engines_test/src/Controller/XmlSitemapEnginesTestController.php \Drupal\xmlsitemap_engines_test\Controller\XmlSitemapEnginesTestController::render()

Callback for the xmlsitemap_engines_test.ping route.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

\Symfony\Component\HttpFoundation\Response A response with 200 code if the url query is valid.

Throws

\Symfony\Component\HttpKernel\Exception\NotFoundHttpException Throw a NotFoundHttpException if query url is not valid.

1 string reference to 'XmlSitemapEnginesTestController::render'
xmlsitemap_engines_test.routing.yml in xmlsitemap_engines/tests/modules/xmlsitemap_engines_test/xmlsitemap_engines_test.routing.yml
xmlsitemap_engines/tests/modules/xmlsitemap_engines_test/xmlsitemap_engines_test.routing.yml

File

xmlsitemap_engines/tests/modules/xmlsitemap_engines_test/src/Controller/XmlSitemapEnginesTestController.php, line 56

Class

XmlSitemapEnginesTestController
Returns responses for xmlsitemap_engines_test.ping route.

Namespace

Drupal\xmlsitemap_engines_test\Controller

Code

public function render(Request $request) {
  $query = $request->query
    ->get('sitemap');
  if (empty($query) || !UrlHelper::isValid($query)) {
    $this->logger
      ->debug('No valid sitemap parameter provided.');

    // @todo Remove this? Causes an extra watchdog error to be handled.
    throw new NotFoundHttpException();
  }
  else {
    $this->logger
      ->debug('Received ping for @sitemap.', [
      '@sitemap' => $query,
    ]);
  }
  return new Response('', 200);
}