Skip to content

Commit

Permalink
Allow accessing the last matched requested.
Browse files Browse the repository at this point in the history
  • Loading branch information
fago committed Jul 25, 2019
1 parent 69bf5e2 commit 016f188
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/RequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public static function getInstance() {
return static::$instance;
}

/**
* The last request that has been matched.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $lastMatchedRequest;

/**
* The allowed site variants (like admin, api, ...).
*
Expand Down Expand Up @@ -243,7 +250,7 @@ public function match(Request $request = NULL) {
if (!$request) {
$request = $this->getRequestFromGlobals();
}

$this->lastMatchedRequest = $request;
$host = $request->getHost();
$site_host = $host;

Expand Down Expand Up @@ -316,4 +323,17 @@ public function match(Request $request = NULL) {
return $site;
}

/**
* Gets the last request that has been matched, if any.
*
* Note that request objects created by the request matcher do not have forms
* parsed!
*
* @return \Symfony\Component\HttpFoundation\Request|null
* The last request that has been matched, if any.
*/
public function getLastMatchedRequest() {
return $this->lastMatchedRequest;
}

}

0 comments on commit 016f188

Please sign in to comment.