You are here

function _commons_create_demo_taxonomy_terms in Drupal Commons 7.3

BatchAPI callback.

See also

commons_demo_content()

1 string reference to '_commons_create_demo_taxonomy_terms'
commons_install_additional_modules in ./commons.install
Task callback: uses Batch API to enable modules based on user selection.

File

./commons.install_callbacks.inc, line 66
Contains Batch API callbacks used during installation.

Code

function _commons_create_demo_taxonomy_terms($operation, &$context) {
  $context['message'] = t('@operation', array(
    '@operation' => $operation,
  ));

  // Create an array of topic names.
  $demo_topic_names = array(
    'brunch',
    'Cambridge',
    'dining out',
    'vegetarian',
    'casual',
    'meal',
    'recipe',
    'bbq',
    'music',
    'festival',
  );

  // Create a taxonomy term for each topic.
  foreach ($demo_topic_names as $topic) {
    $term = new stdClass();
    $term->name = $topic;
    $term->vid = 1;
    taxonomy_term_save($term);
    $context['results']['taxonomy_terms'][$topic] = $term;
  }
}