2323use Phalcon \Api \Domain \Components \Middleware \NotFoundMiddleware ;
2424use Phalcon \Api \Domain \Components \Middleware \ValidateTokenClaimsMiddleware ;
2525use Phalcon \Api \Domain \Components \Middleware \ValidateTokenPresenceMiddleware ;
26+ use Phalcon \Api \Domain \Components \Middleware \ValidateTokenRevokedMiddleware ;
2627use Phalcon \Api \Domain \Components \Middleware \ValidateTokenStructureMiddleware ;
2728use Phalcon \Api \Domain \Components \Middleware \ValidateTokenUserMiddleware ;
2829use Phalcon \Api \Domain \Services \Auth \LoginPostService ;
30+ use Phalcon \Api \Domain \Services \Auth \LogoutPostService ;
31+ use Phalcon \Api \Domain \Services \Auth \RefreshPostService ;
32+ use Phalcon \Api \Domain \Services \User \UserDeleteService ;
2933use Phalcon \Api \Domain \Services \User \UserGetService ;
34+ use Phalcon \Api \Domain \Services \User \UserPostService ;
35+ use Phalcon \Api \Domain \Services \User \UserPutService ;
3036use Phalcon \Api \Responder \JsonResponder ;
3137use Phalcon \Cache \AdapterFactory ;
3238use Phalcon \DataMapper \Pdo \Connection ;
@@ -45,10 +51,6 @@ class Container extends Di
4551{
4652 /** @var string */
4753 public const APPLICATION = 'application ' ;
48- /**
49- * Services
50- */
51- public const AUTH_LOGIN_POST_SERVICE = 'service.auth.login.post ' ;
5254 /** @var string */
5355 public const CACHE = 'cache ' ;
5456 /** @var string */
@@ -63,36 +65,45 @@ class Container extends Di
6365 public const JWT_TOKEN = 'jwt.token ' ;
6466 /** @var string */
6567 public const LOGGER = 'logger ' ;
68+ /** @var string */
69+ public const REQUEST = 'request ' ;
70+ /** @var string */
71+ public const RESPONSE = 'response ' ;
72+ /** @var string */
73+ public const ROUTER = 'router ' ;
74+ /** @var string */
75+ public const SECURITY = Security::class;
76+ /** @var string */
77+ public const TIME = 'time ' ;
78+ /**
79+ * Services
80+ */
81+ public const AUTH_LOGIN_POST_SERVICE = 'service.auth.login.post ' ;
82+ public const AUTH_LOGOUT_POST_SERVICE = 'service.auth.logout.post ' ;
83+ public const AUTH_REFRESH_POST_SERVICE = 'service.auth.refresh.post ' ;
84+ public const USER_DELETE_SERVICE = 'service.user.delete ' ;
85+ public const USER_GET_SERVICE = 'service.user.get ' ;
86+ public const USER_POST_SERVICE = 'service.user.post ' ;
87+ public const USER_PUT_SERVICE = 'service.user.put ' ;
6688 /**
6789 * Middleware
6890 */
69- public const MIDDLEWARE_HEALTH = HealthMiddleware::class;
70- public const MIDDLEWARE_NOT_FOUND = NotFoundMiddleware::class;
71- public const MIDDLEWARE_VALIDATE_TOKEN_CLAIMS = ValidateTokenClaimsMiddleware::class;
72- public const MIDDLEWARE_VALIDATE_TOKEN_PRESENCE = ValidateTokenPresenceMiddleware::class;
91+ public const MIDDLEWARE_HEALTH = HealthMiddleware::class;
92+ public const MIDDLEWARE_NOT_FOUND = NotFoundMiddleware::class;
93+ public const MIDDLEWARE_VALIDATE_TOKEN_CLAIMS = ValidateTokenClaimsMiddleware::class;
94+ public const MIDDLEWARE_VALIDATE_TOKEN_PRESENCE = ValidateTokenPresenceMiddleware::class;
95+ public const MIDDLEWARE_VALIDATE_TOKEN_REVOKED = ValidateTokenRevokedMiddleware::class;
7396 public const MIDDLEWARE_VALIDATE_TOKEN_STRUCTURE = ValidateTokenStructureMiddleware::class;
7497 public const MIDDLEWARE_VALIDATE_TOKEN_USER = ValidateTokenUserMiddleware::class;
7598 /**
7699 * Repositories
77100 */
78101 public const REPOSITORY = 'repository ' ;
79102 public const REPOSITORY_TRANSPORT = TransportRepository::class;
80- /** @var string */
81- public const REQUEST = 'request ' ;
82103 /**
83104 * Responders
84105 */
85106 public const RESPONDER_JSON = JsonResponder::class;
86- // public const MIDDLEWARE_VALIDATE_TOKEN_REVOKED = ValidateTokenRevokedMiddleware::class;
87- /** @var string */
88- public const RESPONSE = 'response ' ;
89- /** @var string */
90- public const ROUTER = 'router ' ;
91- /** @var string */
92- public const SECURITY = Security::class;
93- /** @var string */
94- public const TIME = 'time ' ;
95- public const USER_GET_SERVICE = 'service.user.get ' ;
96107
97108 public function __construct ()
98109 {
@@ -110,21 +121,28 @@ public function __construct()
110121
111122 self ::REPOSITORY => $ this ->getServiceRepository (),
112123
113- self ::AUTH_LOGIN_POST_SERVICE => $ this ->getServiceAuthLoginPost (),
114- self ::USER_GET_SERVICE => $ this ->getServiceUserGet (),
124+ self ::AUTH_LOGIN_POST_SERVICE => $ this ->getServiceAuthPost (LoginPostService::class),
125+ self ::AUTH_LOGOUT_POST_SERVICE => $ this ->getServiceAuthPost (LogoutPostService::class),
126+ self ::AUTH_REFRESH_POST_SERVICE => $ this ->getServiceAuthPost (RefreshPostService::class),
127+ self ::USER_DELETE_SERVICE => $ this ->getServiceUser (UserDeleteService::class),
128+ self ::USER_GET_SERVICE => $ this ->getServiceUser (UserGetService::class),
129+ self ::USER_POST_SERVICE => $ this ->getServiceUser (UserPostService::class),
130+ self ::USER_PUT_SERVICE => $ this ->getServiceUser (UserPutService::class),
115131 ];
116132
117133 parent ::__construct ();
118134 }
119135
120136 /**
137+ * @param class-string $className
138+ *
121139 * @return Service
122140 */
123- private function getServiceAuthLoginPost ( ): Service
141+ private function getServiceAuthPost ( string $ className ): Service
124142 {
125143 return new Service (
126144 [
127- 'className ' => LoginPostService::class ,
145+ 'className ' => $ className ,
128146 'arguments ' => [
129147 [
130148 'type ' => 'service ' ,
@@ -368,13 +386,15 @@ private function getServiceRouter(): Service
368386 }
369387
370388 /**
389+ * @param class-string $className
390+ *
371391 * @return Service
372392 */
373- private function getServiceUserGet ( ): Service
393+ private function getServiceUser ( string $ className ): Service
374394 {
375395 return new Service (
376396 [
377- 'className ' => UserGetService::class ,
397+ 'className ' => $ className ,
378398 'arguments ' => [
379399 [
380400 'type ' => 'service ' ,
@@ -388,6 +408,10 @@ private function getServiceUserGet(): Service
388408 'type ' => 'service ' ,
389409 'name ' => self ::FILTER ,
390410 ],
411+ [
412+ 'type ' => 'service ' ,
413+ 'name ' => self ::SECURITY ,
414+ ],
391415 ],
392416 ]
393417 );
0 commit comments