You are here

public function KalturaHelpers::getMetadataFieldList in Kaltura 7.3

Retrieves the list of metadata structure (custom fields).

Return value

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

  • field_info: Array with fields structure, where each key is the field's system name and each value is a SimpleXMLElement object describing the field as returned from the service.
  • metadata_profile: KalturaMetadataProfile object as returned from the service.

File

kaltura_client/kaltura_helpers.php, line 412

Class

KalturaHelpers
Class KalturaHelpers.

Code

public function getMetadataFieldList() {
  $data = array();
  try {
    $client = $this
      ->getKalturaClient(TRUE);
    $plugin = KalturaMetadataClientPlugin::get($client);
    $filter = new KalturaMetadataProfileFilter();
    $filter->metadataObjectTypeEqual = KalturaMetadataObjectType::ENTRY;
    $response = $plugin->metadataProfile
      ->listAction($filter);
    foreach ($response->objects as $profile) {
      $fields = array();
      $xml = simplexml_load_string($profile->xsd, NULL, 0, 'xsd', TRUE);
      foreach ($xml->element->complexType->sequence->element as $element) {
        $name = (string) $element
          ->attributes()->name;
        $fields[$name] = $element;
      }
      $data[$profile->id] = array(
        'field_info' => $fields,
        'metadata_profile' => $profile,
      );

      // Refresh cached profiles.
      cache_set('kaltura:metadata_profile:' . $profile->id, $profile);
    }
  } catch (Exception $e) {
    watchdog_exception('kaltura', $e);
  }
  return $data;
}