You are here

function get_media_restriction in Bynder 8

Same name and namespace in other branches
  1. 8.3 bynder.module \get_media_restriction()
  2. 8.2 bynder.module \get_media_restriction()
  3. 4.0.x bynder.module \get_media_restriction()

Gets media restriction usage info.

Parameters

array|false $property_options: Property options as returned from Bynder API.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup A label for a given restriction level.

2 calls to get_media_restriction()
BynderFormatter::viewElements in src/Plugin/Field/FieldFormatter/BynderFormatter.php
Builds a renderable array for a field value.
BynderMediaUsage::bynderMediaInfo in src/Controller/BynderMediaUsage.php
The Bynder media usage info.

File

./bynder.module, line 180
Provides bynder integration.

Code

function get_media_restriction($property_options) {
  if ($property_options && \Drupal::config('bynder.settings')
    ->get('usage_metaproperty')) {
    $config_restrictions = array_combine([
      t('Royality free'),
      t('Web licence'),
      t('Print licence'),
    ], [
      \Drupal::config('bynder.settings')
        ->get('restrictions.royalty_free'),
      \Drupal::config('bynder.settings')
        ->get('restrictions.web_license'),
      \Drupal::config('bynder.settings')
        ->get('restrictions.print_license'),
    ]);
    $restriction = array_keys(array_intersect($config_restrictions, $property_options));
    return !empty($restriction) ? reset($restriction) : t('N/A');
  }
  else {
    return t('N/A');
  }
}