class MigrateBrightcoveFieldHandler in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.5 brightcove_field/brightcove_field.migrate.inc \MigrateBrightcoveFieldHandler
- 7.6 brightcove_field.migrate.inc \MigrateBrightcoveFieldHandler
Primary value passed to this field is the entity id.
Subfields are used to specify all the other values: 'brightcove id' - the brightcove asset id 'player' - the brightcove player machine name
$this
->addFieldMapping('field_brightcove_field:brightcove_id', '');
$this
->addFieldMapping('field_brightcove_field:player', '');
Hierarchy
- class \MigrateHandler
- class \MigrateFieldHandler
Expanded class hierarchy of MigrateBrightcoveFieldHandler
1 string reference to 'MigrateBrightcoveFieldHandler'
- brightcove_migrate_api in ./
brightcove.module - Implements hook_migrate_api().
File
- ./
brightcove_field.migrate.inc, line 15
View source
class MigrateBrightcoveFieldHandler extends MigrateFieldHandler {
public function __construct() {
$this
->registerTypes([
'brightcove_field',
]);
}
public function fields($type, $instance, $migration = NULL) {
$fields['brightcove_id'] = t('Subfield: The brightcove asset id');
$fields['player'] = t('Subfield: The brightcove player machine name');
return $fields;
}
public function prepare($entity, array $field_info, array $instance, array $values) {
$arguments = [];
$language = $this
->getFieldLanguage($entity, $field_info, $arguments);
// Setup the standard Field API array for saving.
$delta = 0;
$return = array();
foreach ($values as $value) {
if (isset($value['brightcove_id'])) {
if (is_array($value['brightcove_id'])) {
$item['brightcove_id'] = $value['brightcove_id'][$delta];
}
else {
$item['brightcove_id'] = $value['brightcove_id'];
}
}
else {
$item['brightcove_id'] = 0;
}
if (isset($value['player'])) {
if (is_array($value['player'])) {
$item['player'] = $value['player'][$delta];
}
else {
$item['player'] = $value['player'];
}
}
else {
$item['player'] = 0;
}
if (isset($value['bcid'])) {
if (is_array($value['bcid'])) {
$item['bcid'] = $value['bcid'][$delta];
}
else {
$item['bcid'] = $value['bcid'];
}
}
else {
$item['bcid'] = 0;
}
$item['choice'] = $value;
if (is_array($language)) {
$current_language = $language[$delta];
}
else {
$current_language = $language;
}
$return[$current_language][] = $item;
$delta++;
}
return isset($return) ? $return : NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateBrightcoveFieldHandler:: |
public | function | ||
MigrateBrightcoveFieldHandler:: |
public | function | ||
MigrateBrightcoveFieldHandler:: |
public | function |
Overrides MigrateHandler:: |
|
MigrateFieldHandler:: |
function | Determine the language of the field. | ||
MigrateHandler:: |
protected | property | List of other handler classes which should be invoked before the current one. | |
MigrateHandler:: |
protected | property | List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc. | |
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | Does this handler handle the given type? | 1 |
MigrateHandler:: |
protected | function | Register a list of types handled by this class |