Projet

Général

Profil

Paste
Télécharger (1,3 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / fivestar / fivestar.migrate.inc @ d50a36e0

1 4853591f Assos Assos
<?php
2 d50a36e0 Assos Assos
3 4853591f Assos Assos
/**
4
 * @file
5
 * Base integration with the Migrate API class.
6
 */
7
8
/**
9
 * Implements hook_migrate_api().
10
 */
11
function fivestar_migrate_api() {
12
  $api = array(
13
    'api' => 2,
14
    'field handlers' => array('MigrateFivestarFieldHandler'),
15
  );
16
  return $api;
17
}
18
19
/**
20
 * Custom extended MigrateFieldHandler class for FiveStar module.
21
 */
22
class MigrateFivestarFieldHandler extends MigrateFieldHandler {
23
24 d50a36e0 Assos Assos
  /**
25
   *
26
   */
27 4853591f Assos Assos
  public function __construct() {
28
    $this->registerTypes(array('fivestar'));
29
  }
30
31 d50a36e0 Assos Assos
  /**
32
   *
33
   */
34 4853591f Assos Assos
  public function fields($type, $parent_field, $migration = NULL) {
35
    $fields = array(
36
      'target' => t('Ratings: The target of the rating.'),
37
    );
38
    return $fields;
39
  }
40
41 d50a36e0 Assos Assos
  /**
42
   *
43
   */
44 4853591f Assos Assos
  public function prepare($entity, array $field_info, array $instance, array $values) {
45
    $arguments = array();
46
    if (isset($values['arguments'])) {
47
      $arguments = array_filter($values['arguments']);
48
      unset($values['arguments']);
49
    }
50
    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
51
52
    // Setup the standard Field API array for saving.
53
    foreach (array_values($values) as $delta => $value) {
54
      $return[$language][$delta] = array('rating' => $value) + array_intersect_key($arguments, $field_info['columns']);
55
    }
56
57
    return isset($return) ? $return : NULL;
58
  }
59 d50a36e0 Assos Assos
60 4853591f Assos Assos
}