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.
This hooks allow configurable objects to be altered and have additions default values added to the configuration by another module.
This is used by feeds delete to allow altering of the default values to add new parameters to the configurable.
Example of implementation see http://drupal.org/sandbox/gordon/1939256
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff-1962006-13-14.txt | 4.15 KB | MegaChriz |
#14 | feeds-hook-feeds-defaults-1962006-14.patch | 15.24 KB | MegaChriz |
| |||
#13 | interdiff-1962006-12-13.txt | 1.5 KB | MegaChriz |
#13 | feeds-hook-feeds-defaults-1962006-13.patch | 15.09 KB | MegaChriz |
| |||
#12 | feeds-hook-feeds-defaults-1962006-12.patch | 14.73 KB | MegaChriz |
|
Comments
Comment #1
twistor CreditAttribution: twistor commentedThis is a nice idea. I have tried your approach before, creating a module that works with all plugins, it's not easy.
This should use the plugin id, not the class. I know they are usually the same, but not always.
Comment #2
gordon CreditAttribution: gordon commentedI have fixed up this, It was not easy since once the plugin is loaded, the name was being lost.
Comment #3
twistor CreditAttribution: twistor commentedErrr... No.
This needs to be moved to FeedsPlugin. FeedsConfigurables are not necessarily plugins.
So, you can get the plugin_key in a rather convoluted way without touching feeds_plugin(). Either way, that's the wrong place to do it. I will open up a followup issue about adding a pluginKey() method, which I've been meaning to do already. But I want to do a bit more.
Until then, from FeedsPlugin::configDefaults():
feeds_importer($this->id)->config[$this->pluginType()]['plugin_key']
Comment #4
gordon CreditAttribution: gordon commentedThis is why the hook_feeds_PLUGINNAME_defaults() now only gets called for plugins and not for the primary classes.
this only happens in the feed processing, and not in the admin screens. Which is why I changed feeds_plugin() to record the plugin_key.
Any ideas most welcome.
Comment #5
twistor CreditAttribution: twistor commentedI don't understand:
The changes in feeds_plugin() are unnecessary and wrong.
Wouldn't it make more sense to have the hook name be hook_feeds_PLUGIN_TYPE_defaults()?
Comment #6
gordon CreditAttribution: gordon commentedI like the option of implement the hook as plugin type, but I can't find a method of getting the current plugin type for the current plugin.
If you can give me some clues on how to do this.
Thanks
Comment #7
gordon CreditAttribution: gordon commentedWorked it out.
Comment #8
twistor CreditAttribution: twistor commentedThe hook name is wrong.
Use instanceof rather than is_a().
The array being returned should be something more generic.
This should be moved to FeedsPlugin.
Needs spaces.
This also needs a test to ensure it works.
Comment #9
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThis is also useful for the Feeds Import Preview module to bundle additional configuration along with the importer. See #2735141-3: Extending to Preview All . .
So I took a step at this and did the following:
hook_feeds_config_defaults()
andhook_feeds_PLUGIN_TYPE_config_defaults()
FeedsPlugin::configDefaults()
.Still need to check if this implementation helps Feeds Import Preview enough.
Comment #10
mattjones86This patch work's great for my usecase :)
#2822831: Allow other modules to add other options for dealing with non-existent items
Comment #11
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThanks for the feedback, I make this a target for 7.x-2.0-beta4.
Comment #12
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedReroll.
Comment #13
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI'm testing the patch now with Feeds Import Preview module. It appears that the only thing to add is that the hook
hook_feeds_config_defaults()
may live in modulename.feeds.inc. For the hookhook_feeds_PLUGIN_TYPE_config_defaults()
I don't think this is possible, as it is a dynamic hook.Comment #14
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedTurns out that
hook_feeds_PLUGIN_TYPE_config_defaults()
*can* be detected asPLUGIN_TYPE
is either 'fetcher', 'parser' or 'processor', so I added these three variations tofeeds_hook_info()
. Also moved hook implementations for the tests to feeds_tests.feeds.inc.Comment #16
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedCommitted #14.