Commit 8baf4948fb493d4d3f5e0948e506a6c8a266deb2

Authored by Alex Savenko
1 parent 4d5d538f

UserResource prettify

Showing 1 changed file with 36 additions and 29 deletions   Show diff stats
app/library/App/Resources/UserResource.php
@@ -22,27 +22,26 @@ class UserResource extends ApiResource { @@ -22,27 +22,26 @@ class UserResource extends ApiResource {
22 ->itemKey('user') 22 ->itemKey('user')
23 ->collectionKey('users') 23 ->collectionKey('users')
24 ->deny(AclRoles::UNAUTHORIZED, AclRoles::USER) 24 ->deny(AclRoles::UNAUTHORIZED, AclRoles::USER)
25 - ->handler(UserController::class); 25 + ->handler(UserController::class)
26 26
27 - $this  
28 - ->endpoint(ApiEndpoint::all()  
29 - ->allow(AclRoles::USER)  
30 - ->name('all')  
31 - ->description('Возвращает всех зарегистрированных пользователей')  
32 - ); 27 + /** -------------------- [GET] users -------------------------------- **/
  28 + ->endpoint(ApiEndpoint::all()
  29 + ->allow(AclRoles::USER)
  30 + ->name('all')
  31 + ->description('Возвращает всех зарегистрированных пользователей')
  32 + )
  33 + /** ----------------------------------------------------------------- **/
33 34
34 - $this  
35 - ->endpoint(ApiEndpoint::remove()  
36 - ->name('remove')  
37 - ->description('Удаление пользователя') 35 + /** -------------------- [GET] users/me ----------------------------- **/
  36 + ->endpoint(ApiEndpoint::factory('/me', HttpMethods::GET, 'meAction')
  37 + ->name('me')
  38 + ->description('Возвращает текущего залогиненного пользователя')
38 ->allow(AclRoles::USER) 39 ->allow(AclRoles::USER)
39 - ->exampleResponse([  
40 - "result" => "OK"  
41 - ])  
42 ) 40 )
43 - ;  
44 - $this  
45 - ->endpoint(ApiEndpoint::update() 41 + /** ----------------------------------------------------------------- **/
  42 +
  43 + /** -------------------- [PUT] users/{id} -------------------------- **/
  44 + ->endpoint(ApiEndpoint::update()
46 ->name('update') 45 ->name('update')
47 ->description('Изменение данных пользователя') 46 ->description('Изменение данных пользователя')
48 ->allow(AclRoles::ADMINISTRATOR) 47 ->allow(AclRoles::ADMINISTRATOR)
@@ -62,17 +61,21 @@ class UserResource extends ApiResource { @@ -62,17 +61,21 @@ class UserResource extends ApiResource {
62 ] 61 ]
63 ]) 62 ])
64 ) 63 )
65 - ; 64 + /** ----------------------------------------------------------------- **/
66 65
67 - $this  
68 - ->endpoint(ApiEndpoint::factory('/me', HttpMethods::GET, 'meAction')  
69 - ->name('me')  
70 - ->description('Возвращает текущего залогиненного пользователя') 66 + /** -------------------- [DELETE] users/{id} ------------------------ **/
  67 + ->endpoint(ApiEndpoint::remove()
  68 + ->name('remove')
  69 + ->description('Удаление пользователя')
71 ->allow(AclRoles::USER) 70 ->allow(AclRoles::USER)
72 - ); 71 + ->exampleResponse([
  72 + "result" => "OK"
  73 + ])
  74 + )
  75 + /** ----------------------------------------------------------------- **/
73 76
74 - $this  
75 - ->endpoint(ApiEndpoint::factory('/authenticate', HttpMethods::POST, 'authenticateAction') 77 + /** -------------------- [POST] users/authenticate ------------------ **/
  78 + ->endpoint(ApiEndpoint::factory('/authenticate', HttpMethods::POST, 'authenticateAction')
76 ->name('authenticate') 79 ->name('authenticate')
77 ->description('Авторизация пользователя через BasicAuth и возвращает токен доступа') 80 ->description('Авторизация пользователя через BasicAuth и возвращает токен доступа')
78 ->allow(AclRoles::UNAUTHORIZED) 81 ->allow(AclRoles::UNAUTHORIZED)
@@ -93,9 +96,11 @@ class UserResource extends ApiResource { @@ -93,9 +96,11 @@ class UserResource extends ApiResource {
93 ] 96 ]
94 97
95 ]) 98 ])
96 - );  
97 - $this  
98 - ->endpoint(ApiEndpoint::factory('/', HttpMethods::POST, 'registerAction') 99 + )
  100 + /** ----------------------------------------------------------------- **/
  101 +
  102 + /** -------------------- [POST] users -------------------------------- **/
  103 + ->endpoint(ApiEndpoint::factory('/', HttpMethods::POST, 'registerAction')
99 ->name('register') 104 ->name('register')
100 ->description('Регистрация нового пользователя') 105 ->description('Регистрация нового пользователя')
101 ->allow(AclRoles::UNAUTHORIZED) 106 ->allow(AclRoles::UNAUTHORIZED)
@@ -111,6 +116,8 @@ class UserResource extends ApiResource { @@ -111,6 +116,8 @@ class UserResource extends ApiResource {
111 "updatedAt" => "2017-02-16 17:57:52" 116 "updatedAt" => "2017-02-16 17:57:52"
112 ] 117 ]
113 ]) 118 ])
114 - ); 119 + )
  120 + /** ----------------------------------------------------------------- **/
  121 + ;
115 } 122 }
116 } 123 }
117 \ No newline at end of file 124 \ No newline at end of file