You are here

public function Remote::getAuthPlugin in Entity Share 8.3

Helper method to instantiate auth plugin from this entity.

Return value

\Drupal\entity_share_client\ClientAuthorization\ClientAuthorizationInterface|null The plugin if it is defined.

Throws

\Drupal\Component\Plugin\Exception\PluginException

Overrides RemoteInterface::getAuthPlugin

1 call to Remote::getAuthPlugin()
Remote::getHttpClient in modules/entity_share_client/src/Entity/Remote.php
Prepares a client object with options pulled from the auth plugin.

File

modules/entity_share_client/src/Entity/Remote.php, line 97

Class

Remote
Defines the Remote entity.

Namespace

Drupal\entity_share_client\Entity

Code

public function getAuthPlugin() {
  $pluginData = $this->auth;
  if (!empty($pluginData['pid'])) {

    // DI not available in entities:
    // https://www.drupal.org/project/drupal/issues/2142515.

    /** @var \Drupal\entity_share_client\ClientAuthorization\ClientAuthorizationPluginManager $manager */
    $manager = \Drupal::service('plugin.manager.entity_share_client_authorization');
    $pluginId = $pluginData['pid'];
    unset($pluginData['pid']);
    return $manager
      ->createInstance($pluginId, $pluginData);
  }
  return NULL;
}