@@ -1299,49 +1299,33 @@ function conditional_fields_load_dependencies($entity_type = NULL, $bundle = NUL
1299
1299
$select = db_select('conditional_fields', 'cf')
1300
1300
->fields('cf', array('id', 'options', 'dependee', 'dependent'))
1301
1301
->orderBy('cf.dependent');
1302
- //$fci_depende = $select->join('field_config_instance', 'fci_dependee', 'cf.dependee = fci_dependee.id');
1303
- //$fci_dependent = $select->join('field_config_instance', 'fci_dependent', 'cf.dependent = fci_dependent.id');
1304
- //$select->addField($fci_depende, 'field_name', 'dependee');
1305
- //$select->addField($fci_dependent, 'field_name', 'dependent');
1306
- //$select->addField($fci_depende, 'entity_type');
1307
- //$select->addField($fci_depende, 'bundle');
1308
-
1309
- if (0 && $entity_type) {
1310
- $select->condition(
1311
- db_and()
1312
- ->condition('fci_dependee.entity_type', $entity_type)
1313
- ->condition('fci_dependent.entity_type', $entity_type)
1314
- );
1315
- }
1316
-
1317
- if (0 && $bundle) {
1318
- $select->condition(
1319
- db_and()
1320
- ->condition('fci_dependee.bundle', $bundle)
1321
- ->condition('fci_dependent.bundle', $bundle)
1322
- );
1323
- }
1324
- //$instance_settings = config_get("field.instance.$entity_type.$bundle.$field_name");
1325
1302
1326
1303
$result = $select->execute();
1327
1304
1328
1305
foreach ($result as $dependency) {
1329
1306
$dependent_parts = explode('.', $dependency->dependent);
1330
- $result_entity_type = $entity_type ? $entity_type : $dependent_parts[0];
1331
- $result_bundle = $bundle ? $bundle : $dependent_parts[1];
1332
-
1333
- $options = unserialize($dependency->options);
1334
- $options += $default_options;
1335
-
1336
- $dependencies[$result_entity_type][$result_bundle]['dependents'][$dependency->dependent][$dependency->id] = array(
1337
- 'dependee' => $dependency->dependee,
1338
- 'options' => $options,
1339
- );
1340
-
1341
- $dependencies[$result_entity_type][$result_bundle]['dependees'][$dependency->dependee][$dependency->id] = array(
1342
- 'dependent' => $dependency->dependent,
1343
- 'options' => $options,
1344
- );
1307
+ $entity_type_match = (!$entity_type || ($entity_type && $dependent_parts[0] == $entity_type));
1308
+ $bundle_match = (!$bundle || ($bundle && $dependent_parts[1] == $bundle));
1309
+ if ($entity_type_match && $bundle_match) {
1310
+ // Make sure there is no Entity type or Bundle specified, or that the
1311
+ // specified Entity type or Bundle match the one that is returned
1312
+ // in this instance.
1313
+ $result_entity_type = $entity_type ? $entity_type : $dependent_parts[0];
1314
+ $result_bundle = $bundle ? $bundle : $dependent_parts[1];
1315
+
1316
+ $options = unserialize($dependency->options);
1317
+ $options += $default_options;
1318
+
1319
+ $dependencies[$result_entity_type][$result_bundle]['dependents'][$dependency->dependent][$dependency->id] = array(
1320
+ 'dependee' => $dependency->dependee,
1321
+ 'options' => $options,
1322
+ );
1323
+
1324
+ $dependencies[$result_entity_type][$result_bundle]['dependees'][$dependency->dependee][$dependency->id] = array(
1325
+ 'dependent' => $dependency->dependent,
1326
+ 'options' => $options,
1327
+ );
1328
+ }
1345
1329
}
1346
1330
}
1347
1331
0 commit comments