Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing;
- use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
- use Drupal\Core\DrupalContainer;
- /**
- * Execute the page callback associated with given request.
- *
- * @param Request $request
- * The Symfony Request object used to determine what will be executed.
- * @return Response
- * A Symfony Response object describing the response to deliver to the client.
- */
- function router_execute_request(Request $request) {
- try {
- $parameters = new ParameterBag();
- $parameters->set('request', $request);
- $container = new DrupalContainer($parameters);
- $request->attributes->add($container->get('matcher')->match($request->getPathInfo()));
- return $container->get('kernel')->handle($request);
- }
- catch (Routing\Exception\ResourceNotFoundException $e) {
- $response = new Response('Not Found', 404);
- }
- //catch (Exception $e) {
- // $response = new Response('An error occurred', 500);
- //}
- return $response;
- }
Advertisement
Add Comment
Please, Sign In to add comment