You are here

protected function FileSearch::extractContentSimple in Search File Attachments 8

Extract simple text.

Parameters

\Drupal\Core\Entity\EntityInterface $file: The file object.

string $file_path: The path to the file.

Return value

string The extracted text.

1 call to FileSearch::extractContentSimple()
FileSearch::getFileContent in src/Plugin/Search/FileSearch.php
Extract the content of the given file.

File

src/Plugin/Search/FileSearch.php, line 355

Class

FileSearch
Executes a keyword search for files against {file_managed} database table.

Namespace

Drupal\search_file_attachments\Plugin\Search

Code

protected function extractContentSimple(EntityInterface $file, $file_path) {
  $content = file_get_contents($file_path);
  $content = iconv("UTF-8", "UTF-8//IGNORE", $content);
  $content = htmlspecialchars(html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), ENT_NOQUOTES, 'UTF-8');
  $content = trim($content);
  return $content;
}