![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/laminas/laminas-mvc/src/Controller/Plugin/ |
<?php namespace Laminas\Mvc\Controller\Plugin; use ArrayAccess; use Laminas\Http\Header\HeaderInterface; use Laminas\Mvc\Exception\RuntimeException; use Laminas\Mvc\InjectApplicationEventInterface; class Params extends AbstractPlugin { /** * Grabs a param from route match by default. * * @param string $param * @return mixed */ public function __invoke($param = null, mixed $default = null) { if ($param === null) { return $this; } return $this->fromRoute($param, $default); } /** * Return all files or a single file. * * @param string $name File name to retrieve, or null to get all. * @param mixed $default Default value to use when the file is missing. * @return array|ArrayAccess|null */ public function fromFiles($name = null, mixed $default = null) { if ($name === null) { return $this->getController()->getRequest()->getFiles($name, $default)->toArray(); } return $this->getController()->getRequest()->getFiles($name, $default); } /** * Return all header parameters or a single header parameter. * * @param string $header Header name to retrieve, or null to get all. * @param mixed $default Default value to use when the requested header is missing. * @return null|HeaderInterface */ public function fromHeader($header = null, mixed $default = null) { if ($header === null) { return $this->getController()->getRequest()->getHeaders($header, $default)->toArray(); } return $this->getController()->getRequest()->getHeaders($header, $default); } /** * Return all post parameters or a single post parameter. * * @param string $param Parameter name to retrieve, or null to get all. * @param mixed $default Default value to use when the parameter is missing. * @return mixed */ public function fromPost($param = null, mixed $default = null) { if ($param === null) { return $this->getController()->getRequest()->getPost($param, $default)->toArray(); } return $this->getController()->getRequest()->getPost($param, $default); } /** * Return all query parameters or a single query parameter. * * @param string $param Parameter name to retrieve, or null to get all. * @param mixed $default Default value to use when the parameter is missing. * @return mixed */ public function fromQuery($param = null, mixed $default = null) { if ($param === null) { return $this->getController()->getRequest()->getQuery($param, $default)->toArray(); } return $this->getController()->getRequest()->getQuery($param, $default); } /** * Return all route parameters or a single route parameter. * * @param string $param Parameter name to retrieve, or null to get all. * @param mixed $default Default value to use when the parameter is missing. * @return mixed * @throws RuntimeException */ public function fromRoute($param = null, mixed $default = null) { $controller = $this->getController(); if (! $controller instanceof InjectApplicationEventInterface) { throw new RuntimeException( 'Controllers must implement Laminas\Mvc\InjectApplicationEventInterface to use this plugin.' ); } if ($param === null) { return $controller->getEvent()->getRouteMatch()->getParams(); } return $controller->getEvent()->getRouteMatch()->getParam($param, $default); } }