You are here

public static function BrightcoveSubscription::loadMultiple in Brightcove Video Connect 8

Same name and namespace in other branches
  1. 8.2 src/Entity/BrightcoveSubscription.php \Drupal\brightcove\Entity\BrightcoveSubscription::loadMultiple()
  2. 3.x src/Entity/BrightcoveSubscription.php \Drupal\brightcove\Entity\BrightcoveSubscription::loadMultiple()

Loads multiple BrightcoveSubscription entities.

Parameters

string[] $order_by: Fields to order by:

  • key: the name of the field.
  • value: the order direction.

Return value

\Drupal\brightcove\Entity\BrightcoveSubscription[] Returns loaded Brightcove Subscription entity objects keyed by ID or an empty array if there are none.

2 calls to BrightcoveSubscription::loadMultiple()
BrightcoveSubscriptionController::listSubscriptions in src/Controller/BrightcoveSubscriptionController.php
Lists available Brightcove Subscriptions.
_brightcove_initiate_sync in ./brightcove.module
Initiates a Brightcove-to-Drupal sync by adding API clients to the queue.

File

src/Entity/BrightcoveSubscription.php, line 290

Class

BrightcoveSubscription
Defines the Brightcove Subscription entity.

Namespace

Drupal\brightcove\Entity

Code

public static function loadMultiple(array $order_by = [
  'is_default' => 'DESC',
  'endpoint' => 'ASC',
]) {

  /** @var \Drupal\Core\Database\Connection $connection */
  $connection = \Drupal::getContainer()
    ->get('database');
  $query = $connection
    ->select('brightcove_subscription', 'bs')
    ->fields('bs');

  // Set orders.
  foreach ($order_by as $field => $direction) {
    $query
      ->orderBy($field, $direction);
  }
  $brightcove_subscriptions = $query
    ->execute()
    ->fetchAllAssoc('id', \PDO::FETCH_ASSOC);
  $loaded_brightcove_subscriptions = [];
  foreach ($brightcove_subscriptions as $id => $brightcove_subscription) {
    $brightcove_subscription['events'] = unserialize($brightcove_subscription['events']);
    $loaded_brightcove_subscriptions[$id] = BrightcoveSubscription::createFromArray($brightcove_subscription);
  }
  return $loaded_brightcove_subscriptions;
}