Closed (fixed)
Project:
Feeds
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
5 Apr 2013 at 04:34 UTC
Updated:
16 Jul 2017 at 09:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
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 commentedI have fixed up this, It was not easy since once the plugin is loaded, the name was being lost.
Comment #3
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 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 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 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 commentedWorked it out.
Comment #8
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
megachrizThis 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
megachrizThanks for the feedback, I make this a target for 7.x-2.0-beta4.
Comment #12
megachrizReroll.
Comment #13
megachrizI'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
megachrizTurns out that
hook_feeds_PLUGIN_TYPE_config_defaults()*can* be detected asPLUGIN_TYPEis 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
megachrizCommitted #14.