You are here

function migrate_example_beer_tags in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 migrate_example/beer.install.inc \migrate_example_beer_tags()
1 call to migrate_example_beer_tags()
migrate_example_beer_install in migrate_example/beer.install.inc

File

migrate_example/beer.install.inc, line 348
Set up for the beer (basic) example.

Code

function migrate_example_beer_tags() {

  // Create a vocabulary named "Migrate Example Beer Styles", enabled for the 'migrate_example_beer' content type.
  $description = st('Use tags to group beers on similar topics into categories.');
  $help = st('Enter a comma-separated list of words to describe your content.');
  $vocabulary = (object) array(
    'name' => 'Migrate Example Beer Styles',
    'description' => $description,
    'machine_name' => 'migrate_example_beer_styles',
    'help' => $help,
  );
  taxonomy_vocabulary_save($vocabulary);
  if (!field_info_field('migrate_example_beer_styles')) {
    $field = array(
      'field_name' => $vocabulary->machine_name,
      'type' => 'taxonomy_term_reference',
      // Set cardinality to unlimited for tagging.
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
      'settings' => array(
        'allowed_values' => array(
          array(
            'vocabulary' => $vocabulary->machine_name,
            'vid' => $vocabulary->vid,
            'parent' => 0,
          ),
        ),
      ),
    );
    field_create_field($field);
  }
  if (!field_info_instance('node', 'migrate_example_beer_styles', 'migrate_example_beer')) {
    $instance = array(
      'field_name' => $vocabulary->machine_name,
      'entity_type' => 'node',
      'label' => $vocabulary->name,
      'bundle' => 'migrate_example_beer',
      'description' => $vocabulary->help,
      'widget' => array(
        'type' => 'taxonomy_autocomplete',
      ),
    );
    field_create_instance($instance);
  }
}