Newer
Older
Alex Barth
committed
<?php
// $Id$
/**
* Abstract class, defines interface for parsers.
*
* @todo: make implement FeedsSourceInterface
*/
abstract class FeedsParser extends FeedsPlugin {
/**
* Parse content fetched by fetcher.
*
* Stub method. Extending classes must implement this method.
*
* @param $batch
* FeedsImportBatch returned by fetcher.
Alex Barth
committed
* @param FeedsSource $source
* Source information.
* @return
* A parsed array.
* @todo: define this array (object?).
*
* @todo: Should it be execute() ?
*/
public abstract function parse(FeedsImportBatch $batch, FeedsSource $source);
Alex Barth
committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* 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.
*
* @return
* An array of mapping sources, or FALSE if the sources can be defined by
* typing a value in a text field.
*
* Example:
* array(
* 'title' => t('Title'),
* 'created' => t('Published date'),
* 'url' => t('Feed item URL'),
* 'guid' => t('Feed item GUID'),
* )
*/
public function getMappingSources() {
return FALSE;
}
/**
* 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().
*/
public function getSourceElement($item, $element_key) {
return isset($item[$element_key]) ? $item[$element_key] : '';
}
}