当前位置: 首页>>代码示例>>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;未经允许,请勿转载。