You are here

public function BynderApi::getAssetBankManager in Bynder 4.0.x

Same name and namespace in other branches
  1. 8.3 src/BynderApi.php \Drupal\bynder\BynderApi::getAssetBankManager()
  2. 8 src/BynderApi.php \Drupal\bynder\BynderApi::getAssetBankManager()
  3. 8.2 src/BynderApi.php \Drupal\bynder\BynderApi::getAssetBankManager()

Gets an instance of the asset bank manager to use for DAM queries.

Return value

\Bynder\Api\Impl\AssetBankManager An instance of the asset bank manager using the request handler.

Overrides BynderApiInterface::getAssetBankManager

1 call to BynderApi::getAssetBankManager()
BynderApi::hasUploadPermissions in src/BynderApi.php
Checks if the current user has upload permissions.
1 method overrides BynderApi::getAssetBankManager()
TestBynderApi::getAssetBankManager in tests/src/Unit/BynderApiUnitTest.php
Gets an instance of the asset bank manager to use for DAM queries.

File

src/BynderApi.php, line 281

Class

BynderApi
Bynder API service.

Namespace

Drupal\bynder

Code

public function getAssetBankManager() {
  $bynder_settings = $this->configFactory
    ->get('bynder.settings');
  $request_options = [
    'timeout' => $bynder_settings
      ->get('timeout'),
  ];
  $session_data = \Drupal::service('session')
    ->get('bynder', []);
  if ($this->bynderConfig) {
    $this->bynderConfiguration = new Configuration($this->bynderConfig['baseUrl'], $this->bynderConfig['permanent_token'], $request_options);
  }
  elseif (!empty($session_data['access_token']) && !empty($session_data['config_hash']) && $session_data['config_hash'] == $this->state
    ->get('bynder_config_hash')) {

    // @TODO Re-evaluate where global and where user token is used.
    $this->bynderConfiguration = $this
      ->getOauthConfiguration();
    $this->bynderConfiguration
      ->setToken($session_data['access_token']);
  }
  else {
    $this->bynderConfiguration = new Configuration($bynder_settings
      ->get('account_domain'), $bynder_settings
      ->get('permanent_token'), $request_options);
  }
  $this->bynderApi = new BynderClient($this->bynderConfiguration);
  return $this->bynderApi
    ->getAssetBankManager();
}