当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getPost方法代码示例

本文整理汇总了PHP中Nette\Application\Request::getPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getPost方法的具体用法?PHP Request::getPost怎么用?PHP Request::getPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Application\Request的用法示例。


在下文中一共展示了Request::getPost方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initGlobalParameters

	/**
	 * Initializes $this->globalParams, $this->signal & $this->signalReceiver, $this->action, $this->view. Called by run().
	 * @return void
	 * @throws Nette\Application\BadRequestException if action name is not valid
	 */
	private function initGlobalParameters()
	{
		// init $this->globalParams
		$this->globalParams = array();
		$selfParams = array();

		$params = $this->request->getParameters();
		if ($this->isAjax()) {
			$params += $this->request->getPost();
		}
		if (isset($this->request->post[self::SIGNAL_KEY])) {
			$params[self::SIGNAL_KEY] = $this->request->post[self::SIGNAL_KEY];
		}

		foreach ($params as $key => $value) {
			if (!preg_match('#^((?:[a-z0-9_]+-)*)((?!\d+\z)[a-z0-9_]+)\z#i', $key, $matches)) {
				continue;
			} elseif (!$matches[1]) {
				$selfParams[$key] = $value;
			} else {
				$this->globalParams[substr($matches[1], 0, -1)][$matches[2]] = $value;
			}
		}

		// init & validate $this->action & $this->view
		$this->changeAction(isset($selfParams[self::ACTION_KEY]) ? $selfParams[self::ACTION_KEY] : self::DEFAULT_ACTION);

		// init $this->signalReceiver and key 'signal' in appropriate params array
		$this->signalReceiver = $this->getUniqueId();
		if (isset($selfParams[self::SIGNAL_KEY])) {
			$param = $selfParams[self::SIGNAL_KEY];
			if (!is_string($param)) {
				$this->error('Signal name is not string.');
			}
			$pos = strrpos($param, '-');
			if ($pos) {
				$this->signalReceiver = substr($param, 0, $pos);
				$this->signal = substr($param, $pos + 1);
			} else {
				$this->signalReceiver = $this->getUniqueId();
				$this->signal = $param;
			}
			if ($this->signal == NULL) { // intentionally ==
				$this->signal = NULL;
			}
		}

		$this->loadState($selfParams);
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:54,代码来源:Presenter.php

示例2: initGlobalParams

	/**
	 * Initializes $this->globalParams, $this->signal & $this->signalReceiver, $this->action, $this->view. Called by run().
	 * @return void
	 * @throws Nette\Application\BadRequestException if action name is not valid
	 */
	private function initGlobalParams()
	{
		// init $this->globalParams
		$this->globalParams = array();
		$selfParams = array();

		$params = $this->request->getParams();
		if ($this->isAjax()) {
			$params = $this->request->getPost() + $params;
		}

		foreach ($params as $key => $value) {
			$a = strlen($key) > 2 ? strrpos($key, self::NAME_SEPARATOR, -2) : FALSE;
			if ($a === FALSE) {
				$selfParams[$key] = $value;
			} else {
				$this->globalParams[substr($key, 0, $a)][substr($key, $a + 1)] = $value;
			}
		}

		// init & validate $this->action & $this->view
		$this->changeAction(isset($selfParams[self::ACTION_KEY]) ? $selfParams[self::ACTION_KEY] : self::DEFAULT_ACTION);

		// init $this->signalReceiver and key 'signal' in appropriate params array
		$this->signalReceiver = $this->getUniqueId();
		if (!empty($selfParams[self::SIGNAL_KEY])) {
			$param = $selfParams[self::SIGNAL_KEY];
			$pos = strrpos($param, '-');
			if ($pos) {
				$this->signalReceiver = substr($param, 0, $pos);
				$this->signal = substr($param, $pos + 1);
			} else {
				$this->signalReceiver = $this->getUniqueId();
				$this->signal = $param;
			}
			if ($this->signal == NULL) { // intentionally ==
				$this->signal = NULL;
			}
		}

		$this->loadState($selfParams);
	}
开发者ID:norbe,项目名称:nette,代码行数:47,代码来源:Presenter.php

示例3: handleRequest

 /**
  * @param FormInterface $form
  * @param Request       $request
  */
 public function handleRequest(FormInterface $form, $request = null)
 {
     if (!$request instanceof Request) {
         throw new UnexpectedTypeException($request, 'Nette\\Application\\Request');
     }
     $name = $form->getName();
     if ($name === '') {
         throw new InvalidArgumentException('Forms are not allowed to have an emtpy string as name.');
     }
     $method = $form->getConfig()->getMethod();
     if ($method !== $request->getMethod()) {
         return;
     }
     if ($method === 'GET') {
         $get = $request->getParameters();
         // Don't submit GET requests if the form's name does not exist in the request.
         if (!isset($get[$name])) {
             return;
         }
         $data = $get[$name];
     } else {
         $post = $request->getPost();
         $files = $request->getFiles();
         $default = $form->getConfig()->getCompound() ? [] : null;
         $postData = isset($post[$name]) ? $post[$name] : $default;
         $filesData = isset($files[$name]) ? $files[$name] : $default;
         if (is_array($postData) && is_array($filesData)) {
             $data = array_replace_recursive($postData, $filesData);
         } else {
             $data = $postData ?: $filesData;
         }
         // Don't submit the form if it is not present in the request.
         if (!$data) {
             return;
         }
     }
     $form->submit($data, $method !== 'PATCH');
 }
开发者ID:Arachne,项目名称:Forms,代码行数:42,代码来源:ApplicationRequestHandler.php

示例4: processRender

 /**
  * Renders only specified fields. Useful for dynamic ajax forms.
  */
 protected function processRender(FormInterface $form, Request $request)
 {
     $presenter = $this->getPresenter();
     if (!$presenter->isAjax()) {
         throw new BadRequestException('The render signal is only allowed in ajax mode.');
     }
     $fields = $request->getPost($this->lookupPath('Nette\\Application\\UI\\Presenter', true) . self::NAME_SEPARATOR . 'fields');
     if (!$fields) {
         throw new BadRequestException('No fields specified for rendering.');
     }
     $form->handleRequest($request);
     if (!$form->isSubmitted()) {
         throw new BadRequestException('The form was not submitted.');
     }
     $view = $this->getView();
     $widgets = [];
     foreach ($fields as $field) {
         // Validate the field identifier for security reasons. A dot in the identifier would be particularly dangerous.
         if (!Strings::match($field, '~^(?:\\[\\w++\\])++$~')) {
             throw new BadRequestException(sprintf('Field identifier "%s" contains unallowed characters.', $field));
         }
         // Skip duplicates. The renderer would return an empty string on second try.
         if (isset($widgets[$field])) {
             continue;
         }
         // Wrap an exception from PropertyAccessor in a BadRequestException.
         try {
             $fieldView = $this->propertyAccessor->getValue($view, $field);
         } catch (ExceptionInterface $e) {
             throw new BadRequestException(sprintf('FormView not found for field identifier "%s".', $field), 0, $e);
         }
         // Render the field widget.
         $widgets[$field] = $this->renderer->searchAndRenderBlock($fieldView, 'widget');
     }
     $this->getPresenter()->sendJson((object) ['widgets' => $widgets]);
 }
开发者ID:Arachne,项目名称:Forms,代码行数:39,代码来源:FormComponent.php

示例5: getSignal

 /**
  * @param \Ark8\Security\Authorizators\Request $request
  * @return array
  * @throws \Nette\InvalidStateException
  */
 private function getSignal(Request $request)
 {
     $params = $request->getParameters();
     if ($this->httpRequest->isAjax()) {
         $params += $request->getPost();
     } elseif (($tmp = $request->getPost(Presenter::SIGNAL_KEY)) !== NULL) {
         $params[self::SIGNAL_KEY] = $tmp;
     }
     $signal = NULL;
     $signalReceiver = '';
     if (isset($params[Presenter::SIGNAL_KEY])) {
         $param = $params[Presenter::SIGNAL_KEY];
         $pos = strrpos($param, '-');
         if ($pos) {
             $signalReceiver = substr($param, 0, $pos);
             $signal = substr($param, $pos + 1);
         } else {
             $signalReceiver = $this->getUniqueId();
             $signal = $param;
         }
         if ($signal == NULL) {
             // intentionally ==
             $signal = NULL;
         }
     }
     return [$signal, explode('-', $signalReceiver)];
 }
开发者ID:ark8,项目名称:security,代码行数:32,代码来源:SignalAuthorizator.php

示例6: handleWebRequest

 /**
  * @param Request $request
  */
 protected function handleWebRequest(Request $request)
 {
     $module = $this->getModule($request->getPresenterName());
     $this->client->setAppname($this->appUrl . ($module ? "/{$module}" : ''));
     if ($module === 'Cron') {
         $this->client->backgroundJob(TRUE);
     }
     $params = $request->getParameters() + $request->getPost();
     $this->transactionName = $this->resolveTransactionName($request, $params);
     $this->client->nameTransaction($this->transactionName);
 }
开发者ID:damejidlo,项目名称:newrelic,代码行数:14,代码来源:NewRelicProfilingListener.php


注:本文中的Nette\Application\Request::getPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。