summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexweber2013-02-16 20:28:00 (GMT)
committer Joachim Noreiko2013-02-16 20:28:00 (GMT)
commit61f80040f017407c6a96d70ba2b14848d9ed19d8 (patch)
tree27ef5ee104e2ced8396f500eb32866d493dff5b8
parent3fe0a348391c541d71b68c1b151866f399436d5a (diff)
Issue #1905004 by alexweber: Fixed flag export to Features not finding module that provides the entity as a dependency.
-rw-r--r--includes/flag.features.inc24
1 files changed, 21 insertions, 3 deletions
diff --git a/includes/flag.features.inc b/includes/flag.features.inc
index a3a1064..4017421 100644
--- a/includes/flag.features.inc
+++ b/includes/flag.features.inc
@@ -17,10 +17,28 @@ function flag_features_export($data, &$export, $module_name = '') {
// Ensure the modules that provide the flag are included as dependencies.
$modules = flag_features_providing_module();
foreach ($data as $key => $flag) {
- // Get the module that provided the flag definition.
+ $module = '';
if ($flag = flag_load($flag, TRUE)) {
- $module = $modules[$flag->entity_type];
- $export['dependencies'][$module] = $module;
+ // Try to get the module that provides the entity this flag is on.
+ // First pass: check whether there's a module that implements
+ // hook_flag_type_info() for this entity.
+ if (array_key_exists($flag->entity_type, $modules)) {
+ $module = $modules[$flag->entity_type];
+ }
+ else {
+ // Second pass: check whether this entity is defined using Entity API
+ // and therefore has an extra 'module' property in its information.
+ if ($entity_info = entity_get_info($flag->entity_type)) {
+ if (isset($entity_info['module'])) {
+ $module = $entity_info['module'];
+ }
+ }
+ }
+
+ if (!empty($module)) {
+ $export['dependencies'][$module] = $module;
+ }
+
$export['features']['flag'][$flag->name] = $flag->name;
}
}