You are here

class MigrateContentTaxonomyFieldHandler in Migrate Extras 6.2

Field handler.

Hierarchy

Expanded class hierarchy of MigrateContentTaxonomyFieldHandler

1 string reference to 'MigrateContentTaxonomyFieldHandler'
migrate_extras_migrate_api in ./migrate_extras.module

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

Namesort descending Modifiers Type Description Overrides
MigrateContentTaxonomyFieldHandler::arguments static function
MigrateContentTaxonomyFieldHandler::prepare public function
MigrateContentTaxonomyFieldHandler::__construct public function Overrides MigrateHandler::__construct
MigrateHandler::$dependencies protected property List of other handler classes which should be invoked before the current one.
MigrateHandler::$typesHandled protected property List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc.
MigrateHandler::getDependencies public function
MigrateHandler::getTypesHandled public function
MigrateHandler::handlesType public function Does this handler handle the given type?
MigrateHandler::registerTypes protected function Register a list of types handled by this class