Problem/Motivation
This is coming from D7 feeds, but you may already have a plan for this. Currently it doesn't seem like targets can be created that are not going to actually map to a real field on the end.
The reason this is useful is because for example feeds_ex has a JSON fetcher that only maps to real fields and if you want to "tamper" or modify by merging to you end up having to create a new field and dealing with the tamper in a formatter or something on the entity after the processing. If you had a temporary target you could set the mapping to this and capture the source data for use when doing a ParseEvent listener for example.
Steps to reproduce
Proposed resolution
This may go against the pure nature (or I missed something and I'll gladly document if you can point me in the right direction) but D7 seemed to have this ability to have fake sources and fake targets, in this case only fake targets, for the use of manipulating would be needed and would be the scope of this proposal.
Remaining tasks
- Discuss
- Write Fake Field Target
- Add test
User interface changes
New generic temporary target option
API changes
Hopefully not.
Data model changes
Also hopefully not.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3206138-rewrite.png | 136.93 KB | megachriz |
| #18 | 3206138-tamper-list.png | 182.12 KB | megachriz |
| #18 | 3206138-mapping-temp-target.png | 64.57 KB | megachriz |
| #13 | Added_test_for_temporary_target-3206138-13.patch | 3.57 KB | diaodiallo |
| #12 | Added_test_for_temporary_target-3206138-12.patch | 3.8 KB | diaodiallo |
Issue fork feeds-3206138
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
megachriz@joelpittet
Good point. This idea has been discussed on the Feeds meetings a while ago - and it was mentioned on #2938505-10: Add UI for editing and removing custom (CSV) sources, but I think we didn't create an issue for it yet.
Thanks for creating the issue. I make it a beta target.
Comment #4
megachrizI've made a draft, but perhaps it is already good enough.
I did not write any tests for it yet. I think there should only be a Kernel test that checks that an import happens without errors when mapping to this target. I think that the Kernel test should cover the following:
Comment #5
andileco commentedThis worked for me with no issues. Thanks for putting this together!
Comment #6
irinaz commentedThank you!! Tested on DevPanel CloudIDE - works like a charm. I feel comfortable moving it to "Reviewed and tested by community".
I hope this can be pushed to release soon - this is much needed feature!!!
Comment #7
diaodiallo commentedAdded a Kernel test for temporary field import.
- Test if nodes are imported after targeting the temporary_target.
Comment #8
megachriz@diaodiallo
Thanks for creating a test! Good idea to map value 'alpha' to the temporary target.
Here are my remarks:
createFieldWithStorage()calls +setUpBodyField()call) can be left out, including mappings to these fields.setUpFieldDisplay()method can be removed.Comment #9
diaodiallo commentedThanks @MegaChriz
I removed setUpBodyField() call and setUpFieldDisplay() method, however I had to create fields with createFieldWithStorage() to have the assertion works.
Have now:
- Test for map to one temporary_target
- Test for map to two temporary_target
Let me know if these tests are what you except but also if there is still a need for performance specially for the repetitive mappings I did.
Comment #10
megachriz@diaodiallo
I think the field creations can be left out, because we don't expect Feeds to write to these fields.
One thing I noticed that is missing in the patch is the temporary target itself. It is on the issue fork, but not in the patch. I think the easiest way to get that in the patch is by applying the plain diff that is provided next to the issue fork: https://git.drupalcode.org/project/feeds/-/merge_requests/27.diff
Comment #11
diaodiallo commentedThank you @megachriz, I added the temporary target in the patch. However I need to find again how to do this test without these two calls of createFieldWithStorage(). The test fell when I comment it.
Comment #12
diaodiallo commentedThanks for checking this @megachriz, I removed the field creation.
Comment #13
diaodiallo commentedRemoved unnecessary codes.
Comment #14
megachrizThanks @diaodiallo
I've committed #13 with a few small changes in the code comments and fixing the coding standard issues that are mentioned by the bot on https://www.drupal.org/pift-ci-job/2154380.
Comment #17
kopeboySo how can we use Temporary targets with other Tamper plugins? I don't see a [temporary_target] replacement that lets me map that value to another field 🤔
Comment #18
megachriz@kopeboy


You can map a source to the target 'Temporary target (temporary_target)', and then that source becomes available in the Tamper interface:
Then for example using the Rewrite plugin you can use that source:
