You are here

public function Form::getUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Form.php \Symfony\Component\DomCrawler\Form::getUri()

Gets the URI of the form.

The returned URI is not the same as the form "action" attribute. This method merges the value if the method is GET to mimics browser behavior.

Return value

string The URI

Overrides Link::getUri

File

vendor/symfony/dom-crawler/Form.php, line 187

Class

Form
Form represents an HTML form.

Namespace

Symfony\Component\DomCrawler

Code

public function getUri() {
  $uri = parent::getUri();
  if (!in_array($this
    ->getMethod(), array(
    'POST',
    'PUT',
    'DELETE',
    'PATCH',
  ))) {
    $query = parse_url($uri, PHP_URL_QUERY);
    $currentParameters = array();
    if ($query) {
      parse_str($query, $currentParameters);
    }
    $queryString = http_build_query(array_merge($currentParameters, $this
      ->getValues()), null, '&');
    $pos = strpos($uri, '?');
    $base = false === $pos ? $uri : substr($uri, 0, $pos);
    $uri = rtrim($base . '?' . $queryString, '?');
  }
  return $uri;
}