class FeedsExJmesPathLines in Feeds extensible parsers 7
Same name and namespace in other branches
- 7.2 src/FeedsExJmesPathLines.inc \FeedsExJmesPathLines
Parses JSON Lines documents with JMESPath.
Hierarchy
- class \FeedsExBase extends \FeedsParser
- class \FeedsExJmesPath
- class \FeedsExJmesPathLines
- class \FeedsExJmesPath
Expanded class hierarchy of FeedsExJmesPathLines
2 string references to 'FeedsExJmesPathLines'
- FeedsExJmesPathLines.test in src/
Tests/ FeedsExJmesPathLines.test - feeds_ex_feeds_plugins in ./
feeds_ex.feeds.inc - Implements hook_feeds_plugins().
File
- src/
FeedsExJmesPathLines.inc, line 11 - Contains FeedsExJmesPathLines.
View source
class FeedsExJmesPathLines extends FeedsExJmesPath {
/**
* The file iterator.
*
* @var FeedsExLineIterator
*/
protected $iterator;
/**
* {@inheritdoc}
*/
protected function hasConfigurableContext() {
return FALSE;
}
/**
* {@inheritdoc}
*/
protected function setUp(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
parent::setUp($source, $fetcher_result);
$this->iterator = new FeedsExLineIterator($fetcher_result
->getFilePath());
if (!$this->iterator
->getSize()) {
throw new FeedsExEmptyException();
}
$this->iterator
->setLineLimit($source->importer
->getLimit());
$state = $source
->state(FEEDS_PARSE);
if (!$state->total) {
$state->total = $this->iterator
->getSize();
}
$this->iterator
->setStartPosition((int) $state->pointer);
}
/**
* {@inheritdoc}
*/
protected function parseItems(FeedsSource $source, FeedsFetcherResult $fetcher_result, FeedsParserResult $result) {
$expressions = $this
->prepareExpressions();
$variable_map = $this
->prepareVariables($expressions);
foreach ($this->iterator as $row) {
$row = $this
->getEncoder()
->convertEncoding($row);
try {
$row = FeedsExJsonUtility::decodeJsonArray($row);
} catch (RuntimeException $e) {
// An array wasn't returned. Skip this item.
continue;
}
if ($item = $this
->executeSources($row, $expressions, $variable_map)) {
$result->items[] = $item;
}
}
}
/**
* {@inheritdoc}
*/
protected function cleanUp(FeedsSource $source, FeedsParserResult $result) {
$source
->state(FEEDS_PARSE)->pointer = $this->iterator
->ftell();
unset($this->iterator);
parent::cleanUp($source, $result);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsExBase:: |
protected | property | The encoder used to convert encodings. | |
FeedsExBase:: |
protected | property | The class used as the text encoder. | 1 |
FeedsExBase:: |
protected | property | The object used to display messages to the user. | |
FeedsExBase:: |
public | function | 1 | |
FeedsExBase:: |
public | function | 1 | |
FeedsExBase:: |
protected | function | Returns a form element for a specific column. | 1 |
FeedsExBase:: |
protected | function | Reuturns the list of table headers. | 1 |
FeedsExBase:: |
public | function | 1 | |
FeedsExBase:: |
protected | function | Renders our debug messages into a list. | |
FeedsExBase:: |
protected | function | Executes the source expressions. | |
FeedsExBase:: |
public | function | Returns the encoder. | |
FeedsExBase:: |
protected | function | Returns the configuration form table header. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | Returns the messenger. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
protected | function | Logs errors. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
protected | function | Prepares the expressions for parsing. | |
FeedsExBase:: |
protected | function | Prepares the raw string for parsing. | |
FeedsExBase:: |
protected | function | Prepares the variable map used to substitution. | |
FeedsExBase:: |
protected | function | Prints errors to the screen. | |
FeedsExBase:: |
public | function | Sets the encoder. | |
FeedsExBase:: |
public | function | Sets the messenger to be used to display messages. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
protected | function | Stops internal error handling. | 1 |
FeedsExJmesPath:: |
protected | property | The JMESPath parser. | |
FeedsExJmesPath:: |
protected | function | Creates a runtime object. | |
FeedsExJmesPath:: |
protected | function |
Returns rows to be parsed. Overrides FeedsExBase:: |
|
FeedsExJmesPath:: |
protected | function |
Executes a single source expression. Overrides FeedsExBase:: |
|
FeedsExJmesPath:: |
protected | function | Generates a directory path to store auto-generated PHP files. | |
FeedsExJmesPath:: |
protected | function | Returns the compilation directory. | |
FeedsExJmesPath:: |
protected | function |
Returns the errors after parsing. Overrides FeedsExBase:: |
|
FeedsExJmesPath:: |
protected | function |
Loads the necessary library. Overrides FeedsExBase:: |
|
FeedsExJmesPath:: |
protected | function | Returns data from the input array that matches a JMESPath expression. | |
FeedsExJmesPath:: |
protected | function |
Starts internal error handling. Overrides FeedsExBase:: |
|
FeedsExJmesPath:: |
protected | function | Validates that a compile directory exists and is valid. | |
FeedsExJmesPath:: |
protected | function |
Validates an expression. Overrides FeedsExBase:: |
|
FeedsExJmesPathLines:: |
protected | property | The file iterator. | |
FeedsExJmesPathLines:: |
protected | function |
Allows subclasses to cleanup after parsing. Overrides FeedsExJmesPath:: |
|
FeedsExJmesPathLines:: |
protected | function |
Returns whether or not this parser uses a context query. Overrides FeedsExBase:: |
|
FeedsExJmesPathLines:: |
protected | function |
Performs the actual parsing. Overrides FeedsExBase:: |
|
FeedsExJmesPathLines:: |
protected | function |
Allows subclasses to prepare for parsing. Overrides FeedsExBase:: |