You are here

function emapi_media_from_db_result in Embedded Media Field 6.3

Create a new media object from a db result.

Parameters

object $result: The db object returned from the db.

Return value

mixed The media object, or NULL if there's no class available for the scheme.

2 calls to emapi_media_from_db_result()
emapi_media_from_uri in emapi/emapi.module
Loads a media object based on the given URI.
emapi_media_load_multiple in emapi/emapi.module
Load one or more fully populated media objects.

File

emapi/emapi.module, line 276
Provides an API for parsing, storage, and display of third party media.

Code

function emapi_media_from_db_result($result) {
  if (($class = emapi_get_provider_class($result->uri)) && class_exists($class)) {
    $media = new $class($result->uri);
    $media
      ->set_emid($result->emid);
    $media
      ->set_uid($result->uid);
    $media
      ->set_status($result->status);
    $media
      ->set_timestamp($result->timestamp);
    drupal_alter('emapi_media', $media);
  }
  return $media;
}