-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvideo_embed_field.install
92 lines (84 loc) · 2.37 KB
/
video_embed_field.install
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* @file
* Install, update and uninstall functions for the video_embed_field module.
*/
/**
* Implements hook_field_schema().
*/
function video_embed_field_field_schema($field) {
switch ($field['type']) {
case 'video_embed_field':
$columns = array(
'video_url' => array(
'type' => 'varchar',
'length' => 512,
'default' => '',
),
'thumbnail_path' => array(
'type' => 'varchar',
'length' => 512,
'default' => '',
),
'video_data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
'embed_code' => array(
'type' => 'varchar',
'length' => 1024,
'default' => '',
),
'description' => array(
'type' => 'text',
'not null' => FALSE,
),
);
$indexes = array();
break;
}
return array(
'columns' => $columns,
'indexes' => $indexes,
);
}
/**
* Implements hook_update_last_removed().
*/
function video_embed_field_update_last_removed() {
return 7010;
}
/**
* Move video_embed_field settings from variables to config.
*/
function video_embed_field_update_1000() {
// Migrate variables to config.
$config = config('video_embed_field.settings');
$config->set('youtube_v3_api_key', update_variable_get('video_embed_field_youtube_v3_api_key', ''));
$config->set('vimeo_access_token', update_variable_get('video_embed_field_vimeo_access_token', ''));
$config->save();
// Delete variables.
update_variable_del('video_embed_field_youtube_v3_api_key');
// Convert existing styles to CMI.
$settings = db_query('SELECT name, title, data FROM {vef_video_styles}');
foreach ($settings as $setting) {
$setting_array = unserialize($setting->data);
$config = config('video_embed_field.video_style.' . $setting->name);
$config->set('module', 'video_embed_field');
$config->set('preset_type', 'video_style');
$config->set('title', $setting->title);
$config->set('machine_name', $setting->name);
$config->set('data', $setting_array);
$config->save();
}
}
/**
* Remove database table for VEF styles since it is in config now.
*/
function video_embed_field_update_1001() {
if (db_table_exists('vef_video_styles')) {
db_drop_table('vef_video_styles');
}
}