Projet

Général

Profil

Révision 39a181a4

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/link/link.migrate.inc
11 11
 * $this->addFieldMapping('field_my_link', 'source_url');
12 12
 * $this->addFieldMapping('field_my_link:title', 'source_title');
13 13
 * $this->addFieldMapping('field_my_link:attributes', 'source_attributes');
14
 * @endcode
15 14
 *
16
 * With earlier versions of Migrate, you must pass an arguments array:
15
 * # With earlier versions of Migrate, you must pass an arguments array:
17 16
 *
18
 * @code
19 17
 * $link_args = array(
20 18
 *   'title' => array('source_field' => 'source_title'),
21 19
 *   'attributes' => array('source_field' => 'source_attributes'),
......
25 23
 * @endcode
26 24
 */
27 25

  
26
if (!class_exists('MigrateFieldHandler')) {
27
  return;
28
}
29

  
28 30
/**
29 31
 * Implements hook_migrate_api().
30 32
 */
......
35 37
  );
36 38
}
37 39

  
40
// @codingStandardsIgnoreLine
38 41
class MigrateLinkFieldHandler extends MigrateFieldHandler {
42

  
43
  /**
44
   * Construct.
45
   */
39 46
  public function __construct() {
40 47
    $this->registerTypes(array('link_field'));
41 48
  }
42 49

  
43
  static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
50
  /**
51
   * Arguments.
52
   */
53
  public static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
44 54
    $arguments = array();
45 55
    if (!is_null($title)) {
46 56
      $arguments['title'] = $title;
......
57 67
  /**
58 68
   * Implementation of MigrateFieldHandler::fields().
59 69
   *
60
   * @param $type
61
   *  The field type.
62
   * @param $instance
63
   *  Instance info for the field.
70
   * @param array $type
71
   *   The field type.
72
   * @param array $instance
73
   *   Instance info for the field.
64 74
   * @param Migration $migration
65
   *  The migration context for the parent field. We can look at the mappings
66
   *  and determine which subfields are relevant.
75
   *   The migration context for the parent field. We can look at the mappings
76
   *   and determine which subfields are relevant.
77
   *
67 78
   * @return array
79
   *   Array with values.
80
   *
81
   * @codingStandardsIgnoreStart
68 82
   */
69 83
  public function fields($type, $instance, $migration = NULL) {
84
    // @codingStandardsIgnoreEnd
70 85
    return array(
71 86
      'title' => t('Subfield: The link title attribute'),
72 87
      'attributes' => t('Subfield: The attributes for this link'),
......
74 89
    );
75 90
  }
76 91

  
92
  /**
93
   * Prepare.
94
   */
77 95
  public function prepare($entity, array $field_info, array $instance, array $values) {
78 96
    if (isset($values['arguments'])) {
79 97
      $arguments = $values['arguments'];
......
105 123
        }
106 124
      }
107 125
      $item['url'] = $value;
108
      $return[$language][$delta] = $item;
126

  
127
      if (is_array($language)) {
128
        $current_language = $language[$delta];
129
      }
130
      else {
131
        $current_language = $language;
132
      }
133
      $return[$current_language][$delta] = $item;
109 134
    }
110 135

  
111 136
    return isset($return) ? $return : NULL;
112 137
  }
138

  
113 139
}

Formats disponibles : Unified diff