本文整理汇总了PHP中Zend\Http\Request::getPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getPost方法的具体用法?PHP Request::getPost怎么用?PHP Request::getPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Request
的用法示例。
在下文中一共展示了Request::getPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isGranted
/**
*
* @param MvcEvent $event
* @return bool
*/
public function isGranted(MvcEvent $event)
{
$request = $event->getRequest();
if (!$request instanceof HttpRequest) {
return true;
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIp = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIp = $_SERVER['REMOTE_ADDR'];
}
if (array_key_exists($clientIp, $this->users)) {
$user = $this->users[$clientIp];
if ($this->auth->hasIdentity()) {
// do nothing
} else {
$adapter = $this->auth->getAdapter();
$request = new HttpRequest();
$request->setMethod(HttpRequest::METHOD_POST);
$request->getPost()->identity = $user['user'];
$request->getPost()->credential = $user['password'];
$request->setContent($request->getPost()->toString());
$result = $adapter->prepareForAuthentication($request);
$authenticate = $this->auth->authenticate($adapter);
if (!$authenticate->isValid()) {
error_log('FAIL');
}
}
}
return true;
}
示例2: process
public function process()
{
if (!$this->wizard || !$this->request->isPost()) {
return;
}
$post = $this->request->getPost();
$values = $post->getArrayCopy();
if (isset($values['previous'])) {
$this->wizard->previousStep();
return;
}
if (isset($values['cancel'])) {
return $this->doCancel();
}
$this->processCurrentStep($values);
$steps = $this->wizard->getSteps();
$currentStep = $this->wizard->getCurrentStep();
if (!$currentStep->isComplete()) {
return;
}
if ($currentStep->isComplete() && $steps->isLast($currentStep)) {
return $this->completeWizard();
}
$this->wizard->nextStep();
}
示例3: createTokenResponse
/**
* {@inheritDoc}
*/
public function createTokenResponse(Request $request, Client $client = null, TokenOwnerInterface $owner = null)
{
$token = $request->getPost('access_token');
$scope = $request->getPost('scope');
if (null === $token) {
throw OAuth2Exception::invalidRequest('Missing parameter access_token');
}
$owner = $this->getOwner($token);
if (!$owner instanceof TokenOwnerInterface) {
throw OAuth2Exception::accessDenied('Unable to load user from this token');
}
/**
* @var AccessToken $accessToken
* @var null|RefreshToken $refreshToken
* */
$accessToken = new AccessToken();
$refreshToken = null;
// Generate token
$this->populateToken($accessToken, $client, $owner, $scope);
$accessToken = $this->accessTokenService->createToken($accessToken);
// Before generating a refresh token, we must make sure the authorization server supports this grant
if ($this->authorizationServer->hasGrant(RefreshTokenGrant::GRANT_TYPE)) {
$refreshToken = new RefreshToken();
$this->populateToken($refreshToken, $client, $owner, $scope);
$refreshToken = $this->refreshTokenService->createToken($refreshToken);
}
return $this->prepareTokenResponse($accessToken, $refreshToken);
}
示例4: getIdentity
/** @return null|mixed */
protected function getIdentity()
{
$accessToken = $this->request->getQuery('access_token', $this->request->getPost('access_token'));
if ($accessToken === null) {
return null;
}
$oAuthRequest = OAuth2RequestFactory::create($this->request);
$accessTokenData = $this->oauthServer->getAccessTokenData($oAuthRequest);
return $this->identity = $this->identityStorageAdapter->findByUsername($accessTokenData['user_id']);
}
示例5: deleteAction
public function deleteAction()
{
if ($this->request->isPost()) {
if ($this->request->getPost('confirm') === 'oui') {
$id = $this->params('id');
$this->contactService->delete($id);
}
return $this->redirect()->toRoute('address-book-contact');
}
return $this->showAction();
}
示例6: addAction
public function addAction()
{
$form = $this->service->createForm();
if ($this->request->isPost()) {
$data = $this->request->getPost();
if ($this->service->insert($data)) {
return $this->redirect()->toRoute('contact');
}
}
return new ViewModel(array('contactForm' => $form->prepare()));
}
示例7: fromZend
/**
* Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
*
* @param ZendRequest $zendRequest
* @return ServerRequest
*/
public static function fromZend(ZendRequest $zendRequest)
{
$body = new Stream('php://memory', 'wb+');
$body->write($zendRequest->getContent());
$headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
$query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
$post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
$files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
$request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
$request = $request->withQueryParams($query);
return $request->withParsedBody($post);
}
示例8: getServer
/**
* (non-PHPdoc)
* @see Tinebase_Server_Plugin_Interface::getServer()
*/
public static function getServer(\Zend\Http\Request $request)
{
/**************************** JSON API *****************************/
if ($request->getHeaders('X-TINE20-REQUEST-TYPE') && $request->getHeaders('X-TINE20-REQUEST-TYPE')->getFieldValue() === 'JSON' || $request->getHeaders('CONTENT-TYPE') && substr($request->getHeaders('CONTENT-TYPE')->getFieldValue(), 0, 16) === 'application/json' || $request->getPost('requestType') === 'JSON' || $request->getHeaders('ACCESS-CONTROL-REQUEST-METHOD')) {
return new Tinebase_Server_Json();
}
}
示例9: makeRequestByOperation
/**
* Prepare a Zend Request by Operation with $parameters
*
* @param Operation $operation
* @param array $parameters
* @param int $options BitMask of options to skip or something else
* @return Request
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function makeRequestByOperation(Operation $operation, array $parameters = [], $options = 0)
{
$request = new Request();
$path = $operation->path;
if ($operation->parameters) {
foreach ($operation->parameters as $parameter) {
if (isset($parameters[$parameter->name])) {
switch ($parameter->in) {
case 'path':
$path = str_replace('{' . $parameter->name . '}', $parameters[$parameter->name], $path);
break;
case 'query':
$request->getQuery()->set($parameter->name, $parameters[$parameter->name]);
break;
case 'formData':
$request->getPost()->set($parameter->name, $parameters[$parameter->name]);
break;
default:
throw new RuntimeException(sprintf('Parameter "%s" with ->in = "%s" is not supported', $parameter->parameter, $parameter->in));
}
} elseif ($parameter->required && !($options & SwaggerWrapper::SKIP_REQUIRED)) {
throw new InvalidArgumentException(sprintf('Parameter "%s" is required, please pass value for this in $parameters', $parameter->name));
}
}
}
$request->setUri($path);
$request->setMethod($operation->method);
return $request;
}
示例10: init
public function init(Request $request)
{
if (!$request->isXmlHttpRequest() || !$request->isPost()) {
$this->noAccess();
}
$this->post = $request->getPost();
}
示例11: create
public static function create(HttpRequest $request)
{
$queryParams = $request->getQuery()->toArray();
$postParams = $request->getPost()->toArray();
$files = $request->getFiles()->toArray();
$cookies = ($c = $request->getCookie()) ? [$c] : [];
return new OAuth2Request($queryParams, $postParams, [], $cookies, $files, $_SERVER);
}
示例12: page
public function page()
{
$pageSize = current($this->getPageSizes());
if (in_array((int) $this->request->getPost('pageSize'), $this->getPageSizes())) {
$pageSize = (int) $this->request->getPost('pageSize');
}
return ['take' => (int) $this->request->getPost('take'), 'page' => (int) $this->request->getPost('page', 1), 'pageSize' => $pageSize];
}
示例13: setUp
public function setUp()
{
$request = new Request();
$request->getQuery()->fromArray(array('all' => 'query', 'query_and_post' => 'query'));
$request->getPost()->fromArray(array('all' => 'post', 'query_and_post' => 'post', 'post_only' => 'post'));
$this->request = $request;
$this->routeMatch = new RouteMatch(array('all' => 'route'));
}
示例14: requestSintegra
/**
* Makes a query for a CNPJ
*
* @param $cnpj
* @return bool|mixed
*/
public function requestSintegra($cnpj)
{
$request = new Request();
$request->setMethod(Request::METHOD_POST);
$request->setUri('http://www.sintegra.es.gov.br/resultado.php');
$request->getPost()->set('botao', 'Consultar');
$request->getPost()->set('num_cnpj', $cnpj);
$client = new Client(null, self::setConfig());
try {
$response = $client->send($request);
if ($response->getStatusCode() == 200) {
return $response->getContent();
}
return false;
} catch (\Exception $e) {
return false;
}
}
示例15: testBodyAccessTokenProxiesOAuthServer
/**
* @dataProvider requestMethodsWithRequestBodies
*/
public function testBodyAccessTokenProxiesOAuthServer($method)
{
$token = ['user_id' => 'test'];
$this->setupMockOAuth2Server($token);
$this->request->setMethod($method);
$this->request->getHeaders()->addHeaderLine('Content-Type', 'application/x-www-form-urlencoded');
$this->request->getPost()->set('access_token', 'TOKEN');
$identity = $this->listener->__invoke($this->mvcAuthEvent);
$this->assertIdentityMatchesToken($token, $identity);
}