You are here

class FarmClientRepository in farmOS 2.x

Decorates the simple_oauth ClientRepository.

Load OAuth clients by the consumer.client_id field rather than UUID.

Hierarchy

  • class \Drupal\simple_oauth\Repositories\ClientRepository implements \League\OAuth2\Server\Repositories\ClientRepositoryInterface

Expanded class hierarchy of FarmClientRepository

1 string reference to 'FarmClientRepository'
farm_api.services.yml in modules/core/api/farm_api.services.yml
modules/core/api/farm_api.services.yml
1 service uses FarmClientRepository
farm_api.repositories.client in modules/core/api/farm_api.services.yml
Drupal\farm_api\Repositories\FarmClientRepository

File

modules/core/api/src/Repositories/FarmClientRepository.php, line 13

Namespace

Drupal\farm_api\Repositories
View source
class FarmClientRepository extends ClientRepository {

  /**
   * {@inheritdoc}
   */
  public function getClientEntity($client_identifier) {
    $client_drupal_entity = parent::getClientEntity($client_identifier);
    if (!empty($client_drupal_entity)) {
      return $client_drupal_entity;
    }
    $client_drupal_entities = $this->entityTypeManager
      ->getStorage('consumer')
      ->loadByProperties([
      'client_id' => $client_identifier,
    ]);

    // Check if the client is registered.
    if (empty($client_drupal_entities)) {
      return NULL;
    }

    /** @var \Drupal\consumers\Entity\Consumer $client_drupal_entity */
    $client_drupal_entity = reset($client_drupal_entities);
    return new ClientEntity($client_drupal_entity);
  }

}

Members