TextExtractorRegistry

class \TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorRegistry

Registry for text extractors, which are registered as tagged services via the #[AsTextExtractor] attribute or the 'fal.text_extractor' service tag. Extractors are ordered by their tag priority, an extractor with a higher priority is asked first whether it can extract text from a file.

Table of Contents

Properties

$instances  : array<int, TextExtractorInterface|StructuredTextExtractorInterface>|null
Instance cache for text extractor classes
$mimeTypeCompatibilityTypeGuesser  : MimeTypeCompatibilityTypeGuesser
$mimeTypeDetector  : MimeTypeDetector
$textExtractors  : iterable<string|int, mixed>

Methods

__construct()  : mixed
extract()  : ExtractedText|null
Extracts the text of a FAL file or of any other system resource, such as a file of a package, with the extractor returned by findTextExtractor().
findTextExtractor()  : TextExtractorInterface|StructuredTextExtractorInterface|null
Returns the text extractor responsible for the resource, asking all extractors in the order of their priority: a structured text extractor if it supports the MIME type of the resource, any other text extractor if it can extract the text of the FAL file. A file reference is resolved to its original file.
getSupportedFileExtensions()  : array<int, string>
The file extensions known for the supported MIME types, for consumers which offer file types for selection, such as a search form.
getTextExtractor()  : TextExtractorInterface|null
Checks whether any registered text extractor can deal with a given file and returns it.
registerTextExtractor()  : void
getSupportedMimeTypes()  : array<int, string>
The MIME types the registered extractors declare to handle. Only extractors implementing StructuredTextExtractorInterface take part.
getTextExtractorInstances()  : array<int, TextExtractorInterface|StructuredTextExtractorInterface>
Get all registered text extractor instances

Properties

$textExtractors read-only

protected iterable<string|int, mixed> $textExtractors = []

Methods

__construct()

public __construct([iterable<string|int, TextExtractorInterface|StructuredTextExtractorInterface> $textExtractors = [] ][, MimeTypeDetector $mimeTypeDetector = new MimeTypeDetector() ][, MimeTypeCompatibilityTypeGuesser $mimeTypeCompatibilityTypeGuesser = new MimeTypeCompatibilityTypeGuesser() ]) : mixed

Parameters

$textExtractors : iterable<string|int, TextExtractorInterface|StructuredTextExtractorInterface> = []
$mimeTypeDetector : MimeTypeDetector = new MimeTypeDetector()
$mimeTypeCompatibilityTypeGuesser : MimeTypeCompatibilityTypeGuesser = new MimeTypeCompatibilityTypeGuesser()

findTextExtractor()

Returns the text extractor responsible for the resource, asking all extractors in the order of their priority: a structured text extractor if it supports the MIME type of the resource, any other text extractor if it can extract the text of the FAL file. A file reference is resolved to its original file.

public findTextExtractor(FileInterface|SystemResourceInterface $resource) : TextExtractorInterface|StructuredTextExtractorInterface|null

A generic MIME type, such as "application/zip" for a Word document, may have been stored before "mimeTypeCompatibility" knew it. Only if no extractor is found, the MIME type mapped by the file extension is used.

Parameters

$resource : FileInterface|SystemResourceInterface

Return values

TextExtractorInterface|StructuredTextExtractorInterface|null

getSupportedFileExtensions()

The file extensions known for the supported MIME types, for consumers which offer file types for selection, such as a search form.

public getSupportedFileExtensions() : array<int, string>

Return values

array<int, string>

registerTextExtractor()

public registerTextExtractor(string $className) : void

Deprecated

since TYPO3 v15.0, this method is a no-op and will be removed in TYPO3 v16.0. Register the text extractor as a tagged service using the #[AsTextExtractor] attribute instead.

Parameters

$className : string

getSupportedMimeTypes()

The MIME types the registered extractors declare to handle. Only extractors implementing StructuredTextExtractorInterface take part.

protected getSupportedMimeTypes() : array<int, string>

Return values

array<int, string>
On this page