You are here

public function DeveloperAppKeysController::developerAppKeys in Apigee Edge 8

Returns app credentials.

Return value

\Symfony\Component\HttpFoundation\JsonResponse The app credentials.

File

src/Controller/DeveloperAppKeysController.php, line 64

Class

DeveloperAppKeysController
Controller for the developer app credentials.

Namespace

Drupal\apigee_edge\Controller

Code

public function developerAppKeys($user, $app) : JsonResponse {
  $payload = [];
  if ($user) {
    if ($developer_id = $user
      ->get('apigee_edge_developer_id')->value) {
      $app_storage = $this->entityTypeManager
        ->getStorage('developer_app');
      $app_ids = $app_storage
        ->getQuery()
        ->condition('developerId', $developer_id)
        ->condition('name', $app
        ->getName())
        ->execute();
      if (!empty($app_ids)) {
        $app_id = reset($app_ids);
        $payload = $this
          ->getAppKeys($app_storage
          ->load($app_id));
      }
    }
  }
  return new JsonResponse($payload);
}