Here is a patch that allow you to set file properties before saving it.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | feeds-beta5-hook_feeds_file_alter.patch | 13.09 KB | julien tekrane |
| #10 | feeds-hook_feeds_file_alter.patch | 13.16 KB | julien tekrane |
Here is a patch that allow you to set file properties before saving it.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | feeds-beta5-hook_feeds_file_alter.patch | 13.09 KB | julien tekrane |
| #10 | feeds-hook_feeds_file_alter.patch | 13.16 KB | julien tekrane |
Comments
Comment #2
julien tekrane commentedComment #3
julien tekrane commentedComment #4
julien tekrane commentedComment #5
julien tekrane commentedComment #6
julien tekrane commentedComment #7
megachrizCan you explain why the hook
hook_file_presave()is not sufficient for your use case?Can you also explain what your patches are doing? Your latest patch seems to change a lot of code and I'm curious why so many changes are needed for just invoking a new hook.
Comment #8
julien tekrane commentedComment #9
julien tekrane commentedHello and thank you for your interest.
This patch do 3 things :
hook_feeds_file_alter: It allows you to set properties to files only imported by feeds while thehook_file_presave()deals with every files saved. I needed to contextualize the feeds import so I added this hook.setFileProperties(): It allow you to set properties of a file just by adding the target viahook_feeds_processor_targets_alter. There is no need of additional callback that will be a copy&past of file_feeds_set_target() but with your custom propertyThanks for your attention
Comment #10
julien tekrane commentedFix troubles with same field part of name (exemple "field_document" and "field_documents" was merged together). It is because my test was done with
strpos... now I explode the$mapping['target]and test if my current field isin_arrayof my exploded array.Comment #11
megachrizIt sounds like some nested value in an array is parsed here. Can you give some example data that clarifies why something in a multidimensional array needs to be searched?
What is
$result_item_pathand why is the FeedsParserResult needed here?What happens here and why is access to the parser result important here?
Why is it that this code needed to be moved?
$target!==$field_name. A feeds target is in most cases a field, but not always. It can also be a property on an entity.Changing the method signature here possibly breaks modules that are overriding this method.
Comment #12
julien tekrane commentedComment #13
bluegeek9 commentedUnfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.