class MigrateContentTaxonomyFieldHandler in Migrate Extras 6.2
Field handler.
Hierarchy
- class \MigrateHandler
- class \MigrateFieldHandler
 
 
Expanded class hierarchy of MigrateContentTaxonomyFieldHandler
1 string reference to 'MigrateContentTaxonomyFieldHandler'
File
- ./
content_taxonomy.inc, line 31  - Migrate plugin for the Content Taxonomy module as a destination.
 
View source
class MigrateContentTaxonomyFieldHandler extends MigrateFieldHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'content_taxonomy',
    ));
  }
  static function arguments($mode = 'tid', $vid = 0) {
    return array(
      'mode' => $mode,
      'vid' => $vid,
    );
  }
  public function prepare($entity, array $instance, array $values) {
    $mode = $values['arguments']['mode'];
    $vid = $values['arguments']['vid'];
    //remove arguments or they will be searched too
    unset($values['arguments']);
    $values = array_values($values);
    $return = array();
    // Setup the standard Field API array for saving.
    $delta = 0;
    foreach ($values as $value) {
      if ($mode == 'name') {
        if ($vid > 0) {
          $query = db_select('term_data', 'td')
            ->fields('td', array(
            'tid',
          ))
            ->condition('name', $value, '=')
            ->condition('vid', $vid, '=');
        }
        else {
          $query = db_select('term_data', 'td')
            ->fields('td', array(
            'tid',
          ))
            ->condition('name', $value, '=');
        }
        $result = $query
          ->execute();
        $record = $result
          ->fetchAssoc();
        if ($record['tid'] == 0) {
          //dvm('Term not found: '.$value);
          continue;
        }
        $value = $record['tid'];
      }
      $item = array();
      $item['value'] = $value;
      $return[$delta] = $item;
      $delta++;
    }
    return empty($return) ? NULL : $return;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            MigrateContentTaxonomyFieldHandler:: | 
                  static | function | ||
| 
            MigrateContentTaxonomyFieldHandler:: | 
                  public | function | ||
| 
            MigrateContentTaxonomyFieldHandler:: | 
                  public | function | 
            Overrides MigrateHandler:: | 
                  |
| 
            MigrateHandler:: | 
                  protected | property | List of other handler classes which should be invoked before the current one. | |
| 
            MigrateHandler:: | 
                  protected | property | List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc. | |
| 
            MigrateHandler:: | 
                  public | function | ||
| 
            MigrateHandler:: | 
                  public | function | ||
| 
            MigrateHandler:: | 
                  public | function | Does this handler handle the given type? | |
| 
            MigrateHandler:: | 
                  protected | function | Register a list of types handled by this class |