コード例 #1
0
ファイル: ServiceController.php プロジェクト: yched/meteor
 /**
  * The controller for the meteor.whoami route.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *   A JSON response.
  */
 public function whoami()
 {
     $account = $this->accountProxy->getAccount();
     $uid = $account->id();
     $name = $account->getAccountName();
     $display_name = $account->getDisplayName();
     $roles = $this->accountProxy->getRoles();
     $result = $this->serializer->serialize(['uid' => $uid, 'name' => $name, 'displayName' => $display_name, 'roles' => $roles], 'json');
     $response = new Response($result, Response::HTTP_OK);
     $response->headers->set('Content-type', 'application/json');
     return $response;
 }