當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::setValues方法代碼示例

本文整理匯總了PHP中Symfony\Component\DomCrawler\Form::setValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::setValues方法的具體用法?PHP Form::setValues怎麽用?PHP Form::setValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DomCrawler\Form的用法示例。


在下文中一共展示了Form::setValues方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isValid

 public function isValid(Form $form)
 {
     if ($form->has('token')) {
         $values = $form->getValues();
         $values['token'] = 'modified by csrf scanner';
         $form->setValues($values);
         $this->client->submit($form);
         $status = $this->client->getResponse()->getStatus();
         if (403 == $status) {
             return true;
         }
         $this->message = "403 response expected, but got a {$status}";
     } else {
         $this->message = "No 'token' input field found";
     }
     return false;
 }
開發者ID:goodhacker,項目名稱:marlon-csrfscanner,代碼行數:17,代碼來源:ModifyingTokenCauses403.php

示例2: form

 /**
  * Returns a Form object for the first node in the list.
  *
  * @param array  $values An array of values for the form fields
  * @param string $method The method for the form
  *
  * @return Form   A Form instance
  *
  * @throws \InvalidArgumentException If the current node list is empty
  *
  * @api
  */
 public function form(array $values = null, $method = null)
 {
     if (!count($this)) {
         throw new \InvalidArgumentException('The current node list is empty.');
     }
     $form = new Form($this->getNode(0), $this->uri, $method);
     if (null !== $values) {
         $form->setValues($values);
     }
     return $form;
 }
開發者ID:radupb,項目名稱:DomCrawler,代碼行數:23,代碼來源:Crawler.php

示例3: submit

    /**
     * Submits a form.
     *
     * @param Form  $form   A Form instance
     * @param array $values An array of form field values
     *
     * @api
     */
    public function submit(Form $form, array $values = array())
    {
        $form->setValues($values);

        return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles());
    }
開發者ID:pmjones,項目名稱:php-framework-benchmarks,代碼行數:14,代碼來源:Client.php

示例4: form

 /**
  * Returns a Form object for the first node in the list.
  *
  * @param array  $values An array of values for the form fields
  * @param string $method The method for the form
  *
  * @return Form A Form instance
  *
  * @throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement
  */
 public function form(array $values = null, $method = null)
 {
     if (!$this->nodes) {
         throw new \InvalidArgumentException('The current node list is empty.');
     }
     $node = $this->getNode(0);
     if (!$node instanceof \DOMElement) {
         throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
     }
     $form = new Form($node, $this->uri, $method, $this->baseHref);
     if (null !== $values) {
         $form->setValues($values);
     }
     return $form;
 }
開發者ID:imydou,項目名稱:dkuu,代碼行數:25,代碼來源:Crawler.php

示例5: loginAsync

 /**
  * @param Form    $form
  * @param string  $username
  * @param string  $password
  * @param Session $session
  *
  * @return Promise
  *
  * @rejects RequestException
  * @rejects InvalidCredentialsException
  */
 public function loginAsync(Form $form, $username, $password, Session $session)
 {
     $form->setValues(['name' => $username, 'pass' => $password]);
     return $this->client->requestAsync($form->getMethod(), $form->getUri(), [RequestOptions::COOKIES => $session->getCookieJar(), RequestOptions::AUTH => $session->getAuthData(), RequestOptions::FORM_PARAMS => $form->getPhpValues(), RequestOptions::HEADERS => ['referer' => $form->getUri()], RequestOptions::ALLOW_REDIRECTS => false])->then(function (ResponseInterface $response) use($form) {
         if (substr($response->getStatusCode(), 0, 1) === '3') {
             // We got a redirect, meaning we got logged in (hopefully).
             return;
         }
         throw new InvalidCredentialsException();
     });
 }
開發者ID:Briareos,項目名稱:Undine,代碼行數:22,代碼來源:Client.php


注:本文中的Symfony\Component\DomCrawler\Form::setValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。