You are here

function get_uri_to_bynder in Bynder 8

Same name and namespace in other branches
  1. 8.3 bynder.module \get_uri_to_bynder()
  2. 8.2 bynder.module \get_uri_to_bynder()

Returns edit link for Bynder asset.

Parameters

\Drupal\media_entity\MediaInterface $media: The media entity with bynder as type provider.

Return value

bool|string Returns edit link for Bynder asset or FALSE.

1 call to get_uri_to_bynder()
bynder_form_alter in ./bynder.module
Implements hook_form_alter().

File

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

Code

function get_uri_to_bynder(MediaInterface $media) {
  if (!$media
    ->getType() instanceof Bynder) {
    return FALSE;
  }
  if (!($account_domain = \Drupal::config('bynder.settings')
    ->get('account_domain'))) {
    return FALSE;
  }
  $bynder_id = $media->{$media
    ->getType()
    ->getConfiguration()['source_field']}->value;
  return Url::fromUri($account_domain . '/media', [
    'query' => [
      'mediaId' => $bynder_id,
    ],
  ])
    ->toString();
}