Commit d219814e authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Nouvelle aide de vue QueryParams: Retourne le tableau des paramètres GET (query parameters).

parent c307b5fe
......@@ -2,6 +2,8 @@
namespace UnicaenApp;
use UnicaenApp\View\Helper\QueryParamsHelperFactory;
return [
/**
* Paramètres de fonctionnement LDAP.
......@@ -326,6 +328,7 @@ return [
'userProfileSelect' => 'UnicaenAuth\View\Helper\UserProfileSelectFactory',
'Message' => 'UnicaenApp\Message\View\Helper\MessageHelperFactory',
'messenger' => 'UnicaenApp\View\Helper\MessengerFactory',
'queryParams' => QueryParamsHelperFactory::class,
],
'invokables' => [
'appConnection' => 'UnicaenApp\View\Helper\AppConnection',
......
<?php
namespace UnicaenApp\View\Helper;
use Zend\Http\Request;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\View\Helper\AbstractHelper;
class QueryParams extends AbstractHelper implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
/**
* @var Request
*/
private $request;
/**
* Retourne le tableau des paramètres GET (query parameters).
*
* @return array
*/
public function __invoke()
{
return $this->request->getUri()->getQueryAsArray();
}
/**
* @param Request $request
*/
public function setRequest(Request $request)
{
$this->request = $request;
}
}
\ No newline at end of file
<?php
namespace UnicaenApp\View\Helper;
use Zend\Http\Request;
use Zend\View\HelperPluginManager;
class QueryParamsHelperFactory
{
/**
* @param HelperPluginManager $hpm
* @return QueryParams
*/
public function __invoke(HelperPluginManager $hpm)
{
/** @var Request $request */
$request = $hpm->getServiceLocator()->get('request');
$helper = new QueryParams();
$helper->setRequest($request);
return $helper;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment