Merge pull request #8770 from open-sausages/pulls/4/correct-doc-for-exec-metric-middleware

DOCS Correct documentation for ExecMetricMiddleware
This commit is contained in:
Guy Marriott 2019-01-30 15:09:56 +13:00 committed by GitHub
commit 6f619fa3e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,13 +9,11 @@ use SilverStripe\Control\HTTPResponse;
use SilverStripe\Dev\Debug;
/**
* Secures requests by only allowing a whitelist of Host values
* Display execution metricts for the current request if in dev mode and `execmetric` is provided as a request variable.
*/
class ExecMetricMiddleware implements HTTPMiddleware
{
/**
* @inheritdoc
*/
public function process(HTTPRequest $request, callable $delegate)
{
if (!$this->showMetric($request)) {
@ -38,6 +36,11 @@ class ExecMetricMiddleware implements HTTPMiddleware
}
}
/**
* Check if execution metric should be shown.
* @param HTTPRequest $request
* @return bool
*/
private function showMetric(HTTPRequest $request)
{
return Director::isDev() && array_key_exists('execmetric', $request->getVars());