You are here

protected function Xml::fetchLocalFile in Views XML Backend 8

Returns the contents of a local file.

Parameters

string $uri: The local file path.

Return value

string The file contents.

1 call to Xml::fetchLocalFile()
Xml::fetchFileContents in src/Plugin/views/query/Xml.php
Returns the contents of an XML file.

File

src/Plugin/views/query/Xml.php, line 602
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 fetchLocalFile($uri) {
  if (file_exists($uri)) {
    return file_get_contents($uri);
  }
  if ($this->livePreview) {
    $this->messenger
      ->setMessage($this
      ->t('Local file not found: @uri', [
      '@uri' => $uri,
    ]), 'error');
  }
  $this->logger
    ->error('Local file not found: @uri', [
    '@uri' => $uri,
  ]);
  return '';
}