class RawFetcherResult in Feeds 8.3
A fetcher result object that accepts a raw string.
This will write the string to a file on-demand if the parser requests it.
Hierarchy
- class \Drupal\feeds\Result\FetcherResult implements FetcherResultInterface
- class \Drupal\feeds\Result\RawFetcherResult uses DependencySerializationTrait
Expanded class hierarchy of RawFetcherResult
5 files declare their use of RawFetcherResult
- FeedImportHandler.php in src/
FeedImportHandler.php - OpmlParserTest.php in tests/
src/ Unit/ Feeds/ Parser/ OpmlParserTest.php - RawFetcherResultTest.php in tests/
src/ Unit/ Result/ RawFetcherResultTest.php - SitemapParserTest.php in tests/
src/ Unit/ Feeds/ Parser/ SitemapParserTest.php - SyndicationParserTest.php in tests/
src/ Unit/ Feeds/ Parser/ SyndicationParserTest.php
File
- src/
Result/ RawFetcherResult.php, line 13
Namespace
Drupal\feeds\ResultView source
class RawFetcherResult extends FetcherResult {
use DependencySerializationTrait;
/**
* The raw input string.
*
* @var string
*/
protected $raw;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* Constructs a RawFetcherResult object.
*
* @param string $raw
* The raw result string.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* (optional) The file system service.
*/
public function __construct($raw, FileSystemInterface $file_system = NULL) {
$this->raw = $raw;
if (is_null($file_system)) {
$file_system = \Drupal::service('file_system');
}
$this->fileSystem = $file_system;
}
/**
* {@inheritdoc}
*/
public function getRaw() {
return $this
->sanitizeRaw($this->raw);
}
/**
* {@inheritdoc}
*/
public function getFilePath() {
// Write to a temporary file if the parser expects a file.
if ($this->filePath) {
return $this->filePath;
}
$this->filePath = $this->fileSystem
->tempnam('temporary://', 'feeds-raw');
file_put_contents($this->filePath, $this
->getRaw());
return $this->filePath;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FetcherResult:: |
protected | property | The filepath of the fetched item. | |
FetcherResult:: |
protected | function | Checks that a file exists and is readable. | |
FetcherResult:: |
protected | function | Sanitizes the file in place. | |
FetcherResult:: |
protected | function | Sanitizes the raw content string. | |
RawFetcherResult:: |
protected | property | The file system service. | |
RawFetcherResult:: |
protected | property | The raw input string. | |
RawFetcherResult:: |
public | function |
Returns the path to the file containing the file provided by the fetcher. Overrides FetcherResult:: |
|
RawFetcherResult:: |
public | function |
Returns the file provided by the fetcher as a string. Overrides FetcherResult:: |
|
RawFetcherResult:: |
public | function |
Constructs a RawFetcherResult object. Overrides FetcherResult:: |