From 054a397a198922286e3edefb6124eb17cb27e79b Mon Sep 17 00:00:00 2001 From: Chris Leppanen <chris.leppanen@gmail.com> Date: Wed, 27 Jun 2012 14:07:58 -0700 Subject: [PATCH] Issue #1424992 by stevector: Added implementation of hook_entity_info_alter() so that ->feed_nid() is available to Rules. --- feeds.module | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/feeds.module b/feeds.module index fb01a960..2743bcce 100644 --- a/feeds.module +++ b/feeds.module @@ -1088,3 +1088,29 @@ function feeds_set_subscription_job(array $job = NULL) { function feeds_get_subscription_jobs() { return feeds_set_subscription_job(); } + +/** + * Implements hook_entity_property_info_alter(). + */ +function feeds_entity_property_info_alter(&$info) { + // Gather entities supported by Feeds processors. + $processors = FeedsPlugin::byType('processor'); + $supported_entities = array(); + foreach ($processors as $processor) { + $instance = feeds_plugin($processor['handler']['class'], '__none__'); + if (method_exists($instance, 'entityType')) { + $supported_entities[] = $instance->entityType(); + } + } + // Feeds processors can fake the entity info. Only set the property for + // defined entities. + $supported_entities = array_intersect(array_keys($info), $supported_entities); + + foreach ($supported_entities as $entity_type) { + $info[$entity_type]['properties']['feed_nid'] = array( + 'label' => 'Feed NID', + 'type' => 'integer', + 'description' => t('Nid of the Feed Node that imported this entity.'), + ); + } +} -- GitLab