Last active
April 13, 2021 03:15
-
-
Save jibran/e8d5f17aae6424934a77a16f2513420e to your computer and use it in GitHub Desktop.
Setup current request to the given path in Drupal 8/9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Setup page URL with all request parameters as current request and path. | |
$path = '/some-uri'; | |
$request = Request::create($path); | |
$result = \Drupal::service('router.no_access_checks')->matchRequest($request); | |
$request->attributes->add($result); | |
\Drupal::requestStack()->push($request); | |
\Drupal::service('path.current')->setPath($path); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment