Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractUriElement.php

function AbstractUriElement::__construct

Parameters

\DOMElement $node A \DOMElement instance:

string|null $currentUri The URI of the page where the link is embedded (or the base href):

string|null $method The method to use for the link (GET by default):

Throws

\InvalidArgumentException if the node is not a link

4 calls to AbstractUriElement::__construct()
Form::__construct in vendor/symfony/dom-crawler/Form.php
Form::__construct in vendor/symfony/dom-crawler/Form.php
Image::__construct in vendor/symfony/dom-crawler/Image.php
Image::__construct in vendor/symfony/dom-crawler/Image.php
2 methods override AbstractUriElement::__construct()
Form::__construct in vendor/symfony/dom-crawler/Form.php
Image::__construct in vendor/symfony/dom-crawler/Image.php

File

vendor/symfony/dom-crawler/AbstractUriElement.php, line 31

Class

AbstractUriElement
Any HTML element that can link to an URI.

Namespace

Symfony\Component\DomCrawler

Code

public function __construct(\DOMElement $node, ?string $currentUri = null, ?string $method = 'GET') {
    $this->setNode($node);
    $this->method = $method ? strtoupper($method) : null;
    $elementUriIsRelative = !parse_url(trim($this->getRawUri()), \PHP_URL_SCHEME);
    $baseUriIsAbsolute = null !== $this->currentUri && \in_array(strtolower(substr($this->currentUri, 0, 4)), [
        'http',
        'file',
    ]);
    if ($elementUriIsRelative && !$baseUriIsAbsolute) {
        throw new \InvalidArgumentException(\sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the "%s" class ("%s" was passed).', __CLASS__, $this->currentUri));
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal