oauth2_client-8.x-3.x-dev/src/PluginManager/Oauth2ClientPluginManager.php

src/PluginManager/Oauth2ClientPluginManager.php
<?php

declare(strict_types=1);

namespace Drupal\oauth2_client\PluginManager;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\oauth2_client\Attribute\Oauth2Client;
use Drupal\oauth2_client\Plugin\Discovery\Oauth2ClientDiscoveryDecorator;
use Drupal\oauth2_client\Plugin\Oauth2Client\Oauth2ClientPluginInterface;

/**
 * The OAuth 2 Client plugin manager.
 */
class Oauth2ClientPluginManager extends DefaultPluginManager {

  /**
   * Constructs an Oauth2ClientPluginManager object.
   *
   * @param \Traversable $namespaces
   *   Namespaces to be searched for the plugin.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cacheBackend
   *   The cache backend.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
   *   The module handler service.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager service.
   */
  public function __construct(
    \Traversable $namespaces,
    CacheBackendInterface $cacheBackend,
    ModuleHandlerInterface $moduleHandler,
    protected EntityTypeManagerInterface $entityTypeManager,
  ) {
    parent::__construct('Plugin/Oauth2Client', $namespaces, $moduleHandler, Oauth2ClientPluginInterface::class, Oauth2Client::class, 'Drupal\oauth2_client\Annotation\Oauth2Client');

    $this->alterInfo('oauth2_client_info');
    $this->setCacheBackend($cacheBackend, 'oauth2_client');
  }

  /**
   * {@inheritdoc}
   */
  protected function getDiscovery() {
    if (!($this->discovery instanceof Oauth2ClientDiscoveryDecorator)) {
      $discovery = parent::getDiscovery();
      $this->discovery = new Oauth2ClientDiscoveryDecorator($discovery, $this->entityTypeManager);
    }
    return $this->discovery;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc