Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Factory fixed for non exteded PSR-7 ServerRequest objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Jul 22, 2018
1 parent 4e14a0c commit 05cde89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"minimum-stability": "stable",
"require": {
"php": "^7.1",
"zendframework/zend-servicemanager": "~3.3"
"zendframework/zend-servicemanager": "^3.3"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 10 additions & 1 deletion src/SelamiViewTwigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$request = $container->get(ServerRequestInterface::class);
$viewConfig = $config['view'];
$viewConfig['templates_path'] = $config['app']['templates_path'];
$viewConfig['runtime']['query_parameters'] = $request->getParams();
$viewConfig['runtime']['query_parameters'] = self::getParams($request);
$viewConfig['runtime']['base_url'] = $config['app']['base_url'];
$viewConfig['runtime']['config'] = $config;
$twig = $container->get(Twig_Environment::class);
return new SelamiTwig($twig, $viewConfig);
}
public static function getParams($request) : array
{
$params = $request->getQueryParams();
$postParams = $request->getParsedBody();
if ($postParams) {
$params = array_merge($params, (array)$postParams);
}
return $params;
}
}

0 comments on commit 05cde89

Please sign in to comment.