You are here

public function TextExtractorPluginBase::getRealpath in Search API attachments 9.0.x

Same name and namespace in other branches
  1. 8 src/TextExtractorPluginBase.php \Drupal\search_api_attachments\TextExtractorPluginBase::getRealpath()

Helper method to get the real path from an uri.

Parameters

string $uri: The URI of the file, e.g. public://directory/file.jpg.

Return value

mixed The real path to the file if it is a local file. An URL otherwise.

5 calls to TextExtractorPluginBase::getRealpath()
DocconvExtractor::extract in src/Plugin/search_api_attachments/DocconvExtractor.php
Extract method.
PdftotextExtractor::extract in src/Plugin/search_api_attachments/PdftotextExtractor.php
Extract file with Pdftotext command line tool.
PythonPdf2txtExtractor::extract in src/Plugin/search_api_attachments/PythonPdf2txtExtractor.php
Extract file with python Pdf2txt library.
SolrExtractor::extract in src/Plugin/search_api_attachments/SolrExtractor.php
Extract file with a search api solr backend.
TikaExtractor::extract in src/Plugin/search_api_attachments/TikaExtractor.php
Extract file with Tika library.

File

src/TextExtractorPluginBase.php, line 147

Class

TextExtractorPluginBase
Base class for plugins able to extract file content.

Namespace

Drupal\search_api_attachments

Code

public function getRealpath($uri) {
  $wrapper = $this->streamWrapperManager
    ->getViaUri($uri);
  $scheme = $this->streamWrapperManager
    ->getScheme($uri);
  $local_wrappers = $this->streamWrapperManager
    ->getWrappers(StreamWrapperInterface::LOCAL);
  if (in_array($scheme, array_keys($local_wrappers))) {
    return $wrapper
      ->realpath();
  }
  else {
    return $wrapper
      ->getExternalUrl();
  }
}