Symfony\Component\DomCrawler\Form::getUri PHP Метод

getUri() публичный Метод

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.
public getUri ( ) : string
Результат string The URI
    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;
    }

Usage Example

Пример #1
0
 protected function makeRequestUsingForm(Form $form)
 {
     $files = [];
     $plainFiles = $form->getFiles();
     foreach ($plainFiles as $key => $file) {
         $files[$key] = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error'], true);
     }
     return $this->makeRequest($form->getMethod(), $form->getUri(), $form->getValues(), [], $files);
 }
All Usage Examples Of Symfony\Component\DomCrawler\Form::getUri