You are here

function hook_kaltura_save_entry_metadata in Kaltura 7.3

Acts on a Kaltura Media Entry given the custom metadata.

Modules implementing this hook may attach fields to the Kaltura Media Entry object based on provided metadata before the object is saved to the database.

Parameters

Entity $entity: The Kaltura Media Entry that is being inserted or updated.

array $metadata: Each array's element corresponds to metadata from one profile: key is the profile ID and value is an array with the following elements:

  • fields: Array with metadata fields, where each key is the field's system name and each value is an indexed array of field's values.
  • metadata: KalturaMetadata object as returned from the service.
  • metadata_profile: KalturaMetadataProfile object as returned from the service.

See also

kaltura_save_entry_metadata()

kaltura_kaltura_save_entry_metadata()

1 function implements hook_kaltura_save_entry_metadata()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

kaltura_kaltura_save_entry_metadata in ./kaltura.module
Implements hook_kaltura_save_entry_metadata().
1 invocation of hook_kaltura_save_entry_metadata()
kaltura_save_entry_metadata in ./kaltura.module
Retrieves custom fields of media entry.

File

./kaltura.api.php, line 150
Hooks provided by Kaltura module.

Code

function hook_kaltura_save_entry_metadata(Entity $entity, array $metadata) {

  // Remove previously set field values so if they were removed at KMC then
  // the changes will be reflected locally.
  $entity->field_mymodule_data = array();
  foreach ($metadata as $profile_id => $profile_meta) {
    $profile = $profile_meta['metadata_profile'];
    $fields = $profile_meta['fields'];

    // Check the profile because fields with the same name may exist in multiple
    // profiles.
    if ($profile->systemName === 'SomeEntryInfo') {

      // Attach metadata field 'LoremIpsum' as field_mymodule_data to the
      // entity.
      if (!empty($fields['LoremIpsum'])) {
        foreach ($fields['LoremIpsum'] as $item) {

          // Kaltura Media Entry entity is not language-aware so it is safe and
          // rational to use LANGUAGE_NONE for its fields.
          $entity->field_mymodule_data[LANGUAGE_NONE][]['value'] = $item;
        }
      }
    }
  }
}