Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using FeedsSimplePieParser, there is no way to extend the parse() function in a sub-class, for example to add support for "extension" elements (eg: iTunes). Without this, the only way to build upon FeedsSimplePieParser is to copy the entire parse() function and add the couple of extra lines required.
Can FeedsSimplePieParser::parse() be modified to either call a hook to add elements to $item, or even call an object method, allowing sub-classes to override that?
Comment | File | Size | Author |
---|---|---|---|
#2 | FeedsSimplePieParser.extension.patch | 676 bytes | lyricnz |
Comments
Comment #1
lyricnz CreditAttribution: lyricnz commentedObviously, a matching extension would need to be done to ::getMappingSources()
Comment #2
lyricnz CreditAttribution: lyricnz commentedFirst attempt at a patch attached. This uses a protected method on FeedsSimplePieParser for the additional mapping.
Here's an example of an extension using the code from the patch. It overrides getMappingSources() to add the new mapping sources, and implements the new method provided by the patch to add parsing for these items.
Comment #3
alex_b CreditAttribution: alex_b commentedInteresting.... without reviewing your patch closer, have you had a look at this issue: #631104: Extensible XML parser (mapping more sources)?
Comment #4
lyricnz CreditAttribution: lyricnz commentedYes, I had a look - but that's aiming at something different - a completely generic+extensible XML parser. This patch simply aims to make the SimplePieParser extensible, since it already does 90% of what is needed.
Comment #5
alex_b CreditAttribution: alex_b commented#4 - Right.
I think this is a good approach for now. The obvious downside is that only one parser can extend this functionality at a time. If ever we would want to have multiple actors extend parsing we would have to add an API along the lines of the mapping API. But I assume that's too much to bite off at this moment.
RTBC from my point of view. Once this is committed, I'd like to incorporate #2 into the documentation.
Comment #6
alex_b CreditAttribution: alex_b commentedCommitted. Thanks.
http://drupal.org/cvs?commit=336032
Comment #7
alex_b CreditAttribution: alex_b commentedAdded #2 to documentation: http://drupal.org/node/622700