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.
Problem/Motivation
There are several use cases where the need arises to alter an imported entity based on the parser result.
HOOK_feeds_presave is great for doing alterations, but parser results are not passed down to this hook.
Proposed resolution
Make the FeedsParserResult $item the third argument for HOOK_feeds_presave().
The signature would change to function hook_feeds_presave(FeedsSource $source, $entity, $parser_item)
I would feel more "right" to me to have $item be argument number 2,
but by adding it as third bakckwards compatability is guaranteed, no one needs to alter the hook.
I will attach a patch soon.
Comment | File | Size | Author |
---|---|---|---|
#1 | feeds-presave-parseresult-1703074-1.patch | 1.6 KB | theduke |
Comments
Comment #1
theduke CreditAttribution: theduke commentedPatch for 7.x-2.x.
Comment #2
theduke CreditAttribution: theduke commentedComment #3
stylesuxx CreditAttribution: stylesuxx commentedThanks for the patch, works like a charm.
I'd like to see this implemented too.
Cheers
Chris
Comment #4
twistor CreditAttribution: twistor commentedLooks good to me.
7.x http://drupalcode.org/project/feeds.git/commit/32846d4
There is no hook_feeds_presave is 6.x.
Comment #5.0
(not verified) CreditAttribution: commentedSmall change to signature