You are here

protected function Xml::fetchFileContents in Views XML Backend 8

Returns the contents of an XML file.

Parameters

string $uri: A URL, or local file path.

Return value

string The contents of the XML file.

1 call to Xml::fetchFileContents()
Xml::doExecute in src/Plugin/views/query/Xml.php
Performs the actual view execution.

File

src/Plugin/views/query/Xml.php, line 575
Contains \Drupal\views_xml_backend\Plugin\views\query\Xml.

Class

Xml
Views query plugin for an XML query.

Namespace

Drupal\views_xml_backend\Plugin\views\query

Code

protected function fetchFileContents($uri) {
  if ($uri === '') {
    if ($this->livePreview) {
      $this->messenger
        ->setMessage($this
        ->t('Please enter a file path or URL in the query settings.'));
    }
    return '';
  }
  $parsed = parse_url($uri);

  // Check for local file.
  if (empty($parsed['host'])) {
    return $this
      ->fetchLocalFile($uri);
  }
  return $this
    ->fetchRemoteFile($uri);
}