You are here

public static function BrightcoveVideo::profileAllowedValues in Brightcove Video Connect 8

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

Implements callback_allowed_values_function().

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $definition: The field storage definition.

\Drupal\Core\Entity\FieldableEntityInterface|null $entity: (optional) The entity context if known, or NULL if the allowed values are being collected without the context of a specific entity.

bool &$cacheable: (optional) If an $entity is provided, the $cacheable parameter should be modified by reference and set to FALSE if the set of allowed values returned was specifically adjusted for that entity and cannot not be reused for other entities. Defaults to TRUE.

Return value

array The array of allowed values. Keys of the array are the raw stored values (number or text), values of the array are the display labels. If $entity is NULL, you should return the list of all the possible allowed values in any context so that other code (e.g. Views filters) can support the allowed values for all possible entities and bundles.

File

src/Entity/BrightcoveVideo.php, line 1722

Class

BrightcoveVideo
Defines the Brightcove Video entity.

Namespace

Drupal\brightcove\Entity

Code

public static function profileAllowedValues(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = TRUE) {
  $profiles = [];
  if ($entity instanceof BrightcoveVideo) {

    // Collect profiles for all of the api clients if the ID is not set.
    if (empty($entity
      ->id())) {
      $api_clients = \Drupal::entityQuery('brightcove_api_client')
        ->execute();
      foreach ($api_clients as $api_client_id) {
        $profiles[$api_client_id] = self::getProfileAllowedValues($api_client_id);
      }
    }
    else {
      $profiles = self::getProfileAllowedValues($entity
        ->getApiClient());
    }
  }
  return $profiles;
}