You are here

public static function BrightcovePlayer::getList in Brightcove Video Connect 8.2

Same name and namespace in other branches
  1. 8 src/Entity/BrightcovePlayer.php \Drupal\brightcove\Entity\BrightcovePlayer::getList()
  2. 3.x src/Entity/BrightcovePlayer.php \Drupal\brightcove\Entity\BrightcovePlayer::getList()

Returns a list of players.

Parameters

null|array $api_client: The API Client for which the players should be returned. If it's NULL, then only the default player will be returned.

bool $use_entity_id: Whether to use the Entity's ID or Brightcove's ID for the player's key.

Return value

array A list of player names keyed by their Brightcove ID or by the Entity ID if $use_entity_id is set.

3 calls to BrightcovePlayer::getList()
BrightcoveAPIClientForm::form in src/Form/BrightcoveAPIClientForm.php
Gets the actual form array to be built.
BrightcoveClientQueueWorker::processItem in src/Plugin/QueueWorker/BrightcoveClientQueueWorker.php
Works on a single queue item.
BrightcoveVideoPlaylistForm::getPlayerOptions in src/Form/BrightcoveVideoPlaylistForm.php
Get the player options for the given api client.

File

src/Entity/BrightcovePlayer.php, line 404

Class

BrightcovePlayer
Defines the Brightcove Player.

Namespace

Drupal\brightcove\Entity

Code

public static function getList($api_client, $use_entity_id = FALSE) {

  // If use entity IDs set to true then don't add the default player
  // to the list, because it could be a non-existing Entity.
  if ($use_entity_id) {
    $players = [];
  }
  else {
    $players = [
      BrightcoveAPIClient::DEFAULT_PLAYER => t('Brightcove Default Player'),
    ];
  }
  if (!$api_client) {
    return $players;
  }

  // Collect players referencing a given api client.
  $eq = \Drupal::entityQuery('brightcove_player');
  $eq
    ->condition('api_client', $api_client);
  $player_ids = $eq
    ->execute();

  /** @var \Drupal\brightcove\Entity\BrightcovePlayer $player */
  foreach (self::loadMultiple($player_ids) as $player) {
    $players[$use_entity_id ? $player
      ->id() : $player
      ->getPlayerId()] = $player
      ->getName();
  }
  return $players;
}