abstract class FeedsParser in Feeds 7.2
Same name and namespace in other branches
- 6 plugins/FeedsParser.inc \FeedsParser
- 7 plugins/FeedsParser.inc \FeedsParser
Abstract class, defines interface for parsers.
Hierarchy
- class \FeedsConfigurable
- class \FeedsPlugin implements FeedsSourceInterface
- class \FeedsParser
- class \FeedsPlugin implements FeedsSourceInterface
Expanded class hierarchy of FeedsParser
3 string references to 'FeedsParser'
- FeedsPlugin::typeOf in plugins/
FeedsPlugin.inc - Determines the type of a plugin.
- hook_feeds_plugins in ./
feeds.api.php - Declare Feeds plugins.
- _feeds_feeds_plugins in ./
feeds.plugins.inc - Break out for feeds_feed_plugins().
File
- plugins/
FeedsParser.inc, line 55 - Contains FeedsParser and related classes.
View source
abstract class FeedsParser extends FeedsPlugin {
/**
* Implements FeedsPlugin::pluginType().
*/
public function pluginType() {
return 'parser';
}
/**
* Parse content fetched by fetcher.
*
* Extending classes must implement this method.
*
* @param FeedsSource $source
* Source information.
* @param $fetcher_result
* FeedsFetcherResult returned by fetcher.
*/
public abstract function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result);
/**
* Clear all caches for results for given source.
*
* @param FeedsSource $source
* Source information for this expiry. Implementers can choose to only clear
* caches pertaining to this source.
*/
public function clear(FeedsSource $source) {
}
/**
* Declare the possible mapping sources that this parser produces.
*
* @ingroup mappingapi
*
* @return
* An array of mapping sources, or FALSE if the sources can be defined by
* typing a value in a text field.
* @code
* array(
* 'title' => t('Title'),
* 'created' => t('Published date'),
* 'url' => t('Feed item URL'),
* 'guid' => t('Feed item GUID'),
* )
* @endcode
*/
public function getMappingSources() {
self::loadMappers();
$sources = array();
$content_type = feeds_importer($this->id)->config['content_type'];
drupal_alter('feeds_parser_sources', $sources, $content_type);
if (!feeds_importer($this->id)->config['content_type']) {
return $sources;
}
$sources['parent:uid'] = array(
'name' => t('Feed node: User ID'),
'description' => t('The feed node author uid.'),
);
$sources['parent:nid'] = array(
'name' => t('Feed node: Node ID'),
'description' => t('The feed node nid.'),
);
return $sources;
}
/**
* Get list of mapped sources.
*
* @return array
* List of mapped source names in an array.
*/
public function getMappingSourceList() {
$mappings = feeds_importer($this->id)->processor->config['mappings'];
$sources = array();
foreach ($mappings as $mapping) {
$sources[] = $mapping['source'];
}
return $sources;
}
/**
* Get an element identified by $element_key of the given item.
* The element key corresponds to the values in the array returned by
* FeedsParser::getMappingSources().
*
* This method is invoked from FeedsProcessor::map() when a concrete item is
* processed.
*
* @ingroup mappingapi
*
* @param $batch
* FeedsImportBatch object containing the sources to be mapped from.
* @param $element_key
* The key identifying the element that should be retrieved from $source
*
* @return
* The source element from $item identified by $element_key.
*
* @see FeedsProcessor::map()
* @see FeedsCSVParser::getSourceElement()
*/
public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $element_key) {
switch ($element_key) {
case 'parent:uid':
if ($source->feed_nid && ($node = node_load($source->feed_nid))) {
return $node->uid;
}
break;
case 'parent:nid':
return $source->feed_nid;
}
$item = $result
->currentItem();
return isset($item[$element_key]) ? $item[$element_key] : '';
}
/**
* Returns if the parsed result can have a title.
*
* Parser classes should override this method in case they support a source
* title.
*
* @return bool
* TRUE if the parsed result can have a title.
* FALSE otherwise.
*/
public function providesSourceTitle() {
return FALSE;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsConfigurable:: |
protected | property | Holds the actual configuration information. | |
FeedsConfigurable:: |
protected | property | CTools export enabled status of this object. | |
FeedsConfigurable:: |
protected | property | CTools export type of this object. | |
FeedsConfigurable:: |
protected | property | An unique identifier for the configuration. | |
FeedsConfigurable:: |
public | function | Similar to setConfig but adds to existing configuration. | |
FeedsConfigurable:: |
public | function | Returns configuration form for this object. | 6 |
FeedsConfigurable:: |
public | function | Submission handler for configForm(). | 2 |
FeedsConfigurable:: |
public | function | Validation handler for configForm(). | 3 |
FeedsConfigurable:: |
public | function | Copy a configuration. | 1 |
FeedsConfigurable:: |
public | function | Determine whether this object is persistent. | 1 |
FeedsConfigurable:: |
public | function | Determines whether this object is persistent and enabled. | 1 |
FeedsConfigurable:: |
public | function | Implements getConfig(). | 1 |
FeedsConfigurable:: |
public | function | Returns whether or not the configurable has a config form. | |
FeedsConfigurable:: |
public | function | Determine whether this object is enabled. | |
FeedsConfigurable:: |
public | function | Set configuration. | |
FeedsConfigurable:: |
public | function | Validates the configuration. | 2 |
FeedsConfigurable:: |
public | function | Overrides magic method __get(). | |
FeedsConfigurable:: |
public | function | Override magic method __isset(). This is needed due to overriding __get(). | |
FeedsParser:: |
public | function | Clear all caches for results for given source. | |
FeedsParser:: |
public | function | Get list of mapped sources. | 1 |
FeedsParser:: |
public | function | Declare the possible mapping sources that this parser produces. | 5 |
FeedsParser:: |
public | function | Get an element identified by $element_key of the given item. The element key corresponds to the values in the array returned by FeedsParser::getMappingSources(). | 1 |
FeedsParser:: |
abstract public | function | Parse content fetched by fetcher. | 5 |
FeedsParser:: |
public | function |
Implements FeedsPlugin::pluginType(). Overrides FeedsPlugin:: |
|
FeedsParser:: |
public | function | Returns if the parsed result can have a title. | 3 |
FeedsPlugin:: |
protected | property | The plugin definition. | |
FeedsPlugin:: |
public static | function | Get all available plugins. | |
FeedsPlugin:: |
public static | function | Gets all available plugins of a particular type. | |
FeedsPlugin:: |
public static | function | Determines whether given plugin is derived from given base plugin. | |
FeedsPlugin:: |
public | function |
Overrides FeedsConfigurable::configDefaults(). Overrides FeedsConfigurable:: |
4 |
FeedsPlugin:: |
public | function |
Implements FeedsConfigurable::dependencies(). Overrides FeedsConfigurable:: |
1 |
FeedsPlugin:: |
public | function |
Returns TRUE if $this->sourceForm() returns a form. Overrides FeedsSourceInterface:: |
|
FeedsPlugin:: |
public static | function |
Instantiates a FeedsPlugin object. Overrides FeedsConfigurable:: |
|
FeedsPlugin:: |
public static | function | Loads on-behalf implementations from mappers/ directory. | |
FeedsPlugin:: |
public | function | Returns the plugin definition. | |
FeedsPlugin:: |
public | function |
Save changes to the configuration of this object.
Delegate saving to parent (= Feed) which will collect
information from this object by way of getConfig() and store it. Overrides FeedsConfigurable:: |
1 |
FeedsPlugin:: |
protected | function | Sets the plugin definition. | |
FeedsPlugin:: |
public | function |
Implements FeedsSourceInterface::sourceDefaults(). Overrides FeedsSourceInterface:: |
1 |
FeedsPlugin:: |
public | function |
A source is being deleted. Overrides FeedsSourceInterface:: |
2 |
FeedsPlugin:: |
public | function |
Callback methods, exposes source form. Overrides FeedsSourceInterface:: |
3 |
FeedsPlugin:: |
public | function |
Validation handler for sourceForm. Overrides FeedsSourceInterface:: |
2 |
FeedsPlugin:: |
public | function |
A source is being saved. Overrides FeedsSourceInterface:: |
2 |
FeedsPlugin:: |
public static | function | Determines the type of a plugin. | |
FeedsPlugin:: |
protected | function |
Constructs a FeedsPlugin object. Overrides FeedsConfigurable:: |