Project

General

Profile

Revision 56aebcb7

Added by Assos Assos about 8 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/entityreference/entityreference.devel_generate.inc
19 19
  // Get all the entity that are referencable here.
20 20
  $referencable_entity = entityreference_get_selection_handler($field, $instance)->getReferencableEntities();
21 21
  if (is_array($referencable_entity) && !empty($referencable_entity)) {
22
    // Get a random key.
23
    foreach ($referencable_entity as $type => $eids) {
24
      $object_field['target_id'] = array_rand($eids);
22
    // $referencable_entity is keyed by bundle type.
23
    $random_bundle = array_rand($referencable_entity);
24
    if (!empty($random_bundle)) {
25
      $target_id = array_rand($referencable_entity[$random_bundle]);
26
      if (!empty($referencable_entity[$random_bundle][$target_id])) {
27
        $object_field['target_id'] = $target_id;
28
      }
25 29
    }
26 30
  }
27 31
  return $object_field;

Also available in: Unified diff