php - Zend Framework 2: Accessing query parameter without params plugin / using params plugin outside of controller -
i writing service stuff query parameter, names known.
since not in controller, can't use params plugin.
how can access query parameters in zend framework 2 without using params plugin? there way use params plugin outside of controller?
yes, can query like:
$request = $this->getservicemanager()->get('request'); $query = $request->getquery();
more detailed example:
<?php use zend\servicemanager\servicemanager; use zend\servicemanager\servicemanagerawareinterface; class someservice implements servicemanagerawareinterface { protected $servicemanager; public function getservicemanager() { return $this->servicemanager; } public function setservicemanager(servicemanager $servicemanager) { $this->servicemanager = $servicemanager; return $this; } public function dosomething() { $request = $this->getservicemanager()->get('request'); $query = $request->getquery(); // as: $params = $this->getservicemanager()->get('controllerpluginmanager')->get('params'); } }
Comments
Post a Comment