You are here

countries.devel_generate.inc in Countries 8

Same filename and directory in other branches
  1. 7.2 countries.devel_generate.inc

Devel Generate module integration.

File

countries.devel_generate.inc
View source
<?php

/**
 * @file
 * Devel Generate module integration.
 */

/**
 * Implements hook_devel_generate().
 */
function countries_devel_generate($object, $field, $instance, $bundle) {
  if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
    return devel_generate_multiple('_countries_devel_generate', $object, $field, $instance, $bundle);
  }
  else {
    return _countries_devel_generate($object, $field, $instance, $bundle);
  }
}

/**
 * Implements hook_devel_generate().
 */
function _countries_devel_generate($object, $field, $instance, $bundle) {
  $cache =& drupal_static(__FUNCTION__, array());
  if (!isset($cache[$field['field_name']])) {
    $countries = array();
    foreach (countries_options_list($field) as $iso2 => $name) {
      $countries[$iso2]['iso2'] = $iso2;
    }
    $cache[$field['field_name']] = $countries;
  }
  return $cache[$field['field_name']][array_rand($cache[$field['field_name']])];
}

Functions

Namesort descending Description
countries_devel_generate Implements hook_devel_generate().
_countries_devel_generate Implements hook_devel_generate().