diff --git a/src/Pdf/CakePdf.php b/src/Pdf/CakePdf.php index 86336b2d..669c7ce9 100644 --- a/src/Pdf/CakePdf.php +++ b/src/Pdf/CakePdf.php @@ -7,6 +7,7 @@ use Cake\Core\Exception\Exception; use Cake\Filesystem\File; use Cake\Http\ServerRequestFactory; +use Cake\Routing\Router; class CakePdf { @@ -953,8 +954,13 @@ protected function _render() $viewOptions[$var] = $this->{$prop}; } + $request = Router::getRequest(true); + if (!$request) { + $request = ServerRequestFactory::fromGlobals(); + } + $View = new $viewClass( - ServerRequestFactory::fromGlobals(), + $request, null, null, $viewOptions