-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvideo_embed_field.migrate.inc
57 lines (50 loc) · 1.3 KB
/
video_embed_field.migrate.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @file
* Migrate support for Video Embed Field module.
*/
/**
* Implements hook_migrate_api().
*/
function video_embed_field_migrate_api() {
$api = array(
'api' => 2,
'field handlers' => array('MigrateVideoEmbedFieldFieldHandler'),
);
return $api;
}
/**
* Custom extended MigrateFieldHandler class for Video Embed Field module.
*/
class MigrateVideoEmbedFieldFieldHandler extends MigrateFieldHandler {
public function __construct() {
$this->registerTypes(array('video_embed_field'));
}
/**
* {@inheritdoc}
*/
public function fields($type, $parent_field, $migration = NULL) {
$fields = array(
'video_url' => t('Video: The video URL.'),
);
return $fields;
}
/**
* {@inheritdoc}
*/
public function prepare($entity, array $field_info, array $instance, array $values) {
$arguments = array();
if (isset($values['arguments'])) {
$arguments = array_filter($values['arguments']);
unset($values['arguments']);
}
$language = $this->getFieldLanguage($entity, $field_info, $arguments);
// Setup the standard Field API array for saving.
$delta = 0;
foreach ($values as $value) {
$return[$language][$delta] = array('video_url' => $value);
$delta++;
}
return isset($return) ? $return : NULL;
}
}