You are here

function get_uri_to_bynder in Bynder 8.2

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

Returns edit link for Bynder asset.

Parameters

\Drupal\media\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 85
Provides bynder integration.

Code

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