You are here

link.migrate.inc in Link 6.2

Same filename and directory in other branches
  1. 7 link.migrate.inc

Support for migrate module

File

link.migrate.inc
View source
<?php

/**
 * @file
 * Support for migrate module
 */
class MigrateLinkFieldHandler extends MigrateFieldHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'link',
    ));
  }
  static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
    $arguments = array();
    if (!is_null($title)) {
      $arguments['title'] = $title;
    }
    if (!is_null($attributes)) {
      $arguments['attributes'] = $attributes;
    }
    if (!is_null($language)) {
      $arguments['language'] = $language;
    }
    return $arguments;
  }
  public function prepare($entity, array $instance, array $values) {
    if (isset($values['arguments'])) {
      $arguments = $values['arguments'];
      unset($values['arguments']);
    }
    else {
      $arguments = array();
    }
    $delta = 0;
    foreach ($values as $value) {
      $item = array();
      if (isset($arguments['title'])) {
        $item['title'] = $arguments['title'];
      }
      if (isset($arguments['attributes'])) {
        $item['attributes'] = $arguments['attributes'];
      }
      $item['url'] = $value;
      $return[$delta] = $item;
      $delta++;
    }
    return isset($return) ? $return : NULL;
  }

}

Classes

Namesort descending Description
MigrateLinkFieldHandler @file Support for migrate module