abstract class FeedImportSimpleXPathReader in Feed Import 8
This class is a helper for xpath readers using SimpleXMLElement.
Hierarchy
- class \Drupal\feed_import_base\FeedImportConfigurable
- class \Drupal\feed_import_base\FeedImportReader
- class \Drupal\feed_import_base\FeedImportSimpleXPathReader
- class \Drupal\feed_import_base\FeedImportReader
Expanded class hierarchy of FeedImportSimpleXPathReader
File
- feed_import_base/
src/ FeedImportSimpleXPathReader.php, line 7
Namespace
Drupal\feed_import_baseView source
abstract class FeedImportSimpleXPathReader extends FeedImportReader {
/**
* {@inheritdoc}
*/
public function map(&$item, &$xpath) {
// Get values and handle xpath exceptions.
try {
$values = $item
->xpath($xpath);
} catch (Exception $e) {
return NULL;
}
// Xpath gave no values return null.
if (!$values) {
return NULL;
}
// Get the number of values.
$count = count($values);
$i = -1;
while (++$i < $count) {
// Get each value.
$values[$i] = (string) $values[$i][0];
}
// Return values.
return $count == 1 ? $values[0] : $values;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedImportConfigurable:: |
protected | property | ||
FeedImportConfigurable:: |
public static | function | Helper function to get lines of a string | |
FeedImportConfigurable:: |
public | function | Sets options for this instance | 4 |
FeedImportReader:: |
protected | property | ||
FeedImportReader:: |
public | function | Override this to preprocess your paths before they are used in map(). | 2 |
FeedImportReader:: |
abstract public | function | This method returns the next available item or NULL if there are no items left. | 6 |
FeedImportReader:: |
public | function | Returns a stream context | |
FeedImportReader:: |
abstract public | function | Here you'll init your reader. | 6 |
FeedImportReader:: |
final public | function | Constructor of reader. Constructor is final but you'll have to implement init() to init your reader. | |
FeedImportReader:: |
public | function | Destructor. | 2 |
FeedImportSimpleXPathReader:: |
public | function |
Returns a value mapped from obj by path. Overrides FeedImportReader:: |