1818
1919class ApiAccessController
2020{
21- /**
22- * Flextype Application
23- */
24- protected $ flextype ;
2521
2622 /**
2723 * __construct
2824 */
29- public function __construct ($ flextype )
25+ public function __construct ()
3026 {
31- $ this -> flextype = $ flextype ;
27+
3228 }
3329
3430 /**
@@ -50,26 +46,26 @@ public function index(Request $request, Response $response) : Response
5046 }
5147 }
5248
53- return $ this -> flextype -> container ('twig ' )->render (
49+ return flextype ('twig ' )->render (
5450 $ response ,
5551 'plugins/admin/templates/system/api/access/index.html ' ,
5652 [
5753 'menu_item ' => 'api ' ,
5854 'tokens ' => $ tokens ,
5955 'links ' => [
6056 'api ' => [
61- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api.index ' ),
57+ 'link ' => flextype ('router ' )->pathFor ('admin.api.index ' ),
6258 'title ' => __ ('admin_api ' ),
6359 ],
6460 'api_Access ' => [
65- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.index ' ),
61+ 'link ' => flextype ('router ' )->pathFor ('admin.api_access.index ' ),
6662 'title ' => __ ('admin_access ' ),
6763 'active ' => true
6864 ],
6965 ],
7066 'buttons ' => [
7167 'api_access_add ' => [
72- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.add ' ),
68+ 'link ' => flextype ('router ' )->pathFor ('admin.api_access.add ' ),
7369 'title ' => __ ('admin_create_new_token ' )
7470 ],
7571 ],
@@ -85,22 +81,22 @@ public function index(Request $request, Response $response) : Response
8581 */
8682 public function add (Request $ request , Response $ response ) : Response
8783 {
88- return $ this -> flextype -> container ('twig ' )->render (
84+ return flextype ('twig ' )->render (
8985 $ response ,
9086 'plugins/admin/templates/system/api/access/add.html ' ,
9187 [
9288 'menu_item ' => 'api ' ,
9389 'links ' => [
9490 'api ' => [
95- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api.index ' ),
91+ 'link ' => flextype ('router ' )->pathFor ('admin.api.index ' ),
9692 'title ' => __ ('admin_api ' ),
9793 ],
9894 'api_access ' => [
99- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.index ' ),
95+ 'link ' => flextype ('router ' )->pathFor ('admin.api_access.index ' ),
10096 'title ' => __ ('admin_access ' )
10197 ],
10298 'api_access_add ' => [
103- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.add ' ),
99+ 'link ' => flextype ('router ' )->pathFor ('admin.api_access.add ' ),
104100 'title ' => __ ('admin_create_new_token ' ),
105101 'active ' => true
106102 ],
@@ -134,12 +130,12 @@ public function addProcess(Request $request, Response $response) : Response
134130 $ uuid = Uuid::uuid4 ()->toString ();
135131
136132 // Get time
137- $ time = date ($ this -> flextype -> container ('registry ' )->get ('flextype.settings.date_format ' ), time ());
133+ $ time = date (flextype ('registry ' )->get ('flextype.settings.date_format ' ), time ());
138134
139135 // Create API Token account
140136 if (Filesystem::write (
141137 $ api_token_file_path ,
142- $ this -> flextype -> container ('yaml ' )->encode ([
138+ flextype ('yaml ' )->encode ([
143139 'title ' => $ post_data ['title ' ],
144140 'icon ' => $ post_data ['icon ' ],
145141 'limit_calls ' => (int ) $ post_data ['limit_calls ' ],
@@ -152,18 +148,18 @@ public function addProcess(Request $request, Response $response) : Response
152148 'updated_at ' => $ time ,
153149 ])
154150 )) {
155- $ this -> flextype -> container ('flash ' )->addMessage ('success ' , __ ('admin_message_access_api_token_created ' ));
151+ flextype ('flash ' )->addMessage ('success ' , __ ('admin_message_access_api_token_created ' ));
156152 } else {
157- $ this -> flextype -> container ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_created1 ' ));
153+ flextype ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_created1 ' ));
158154 }
159155 } else {
160- $ this -> flextype -> container ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_created2 ' ));
156+ flextype ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_created2 ' ));
161157 }
162158
163159 if (isset ($ post_data ['create-and-edit ' ])) {
164- return $ response ->withRedirect ($ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.edit ' ) . '?token= ' . $ api_token );
160+ return $ response ->withRedirect (flextype ('router ' )->pathFor ('admin.api_access.edit ' ) . '?token= ' . $ api_token );
165161 } else {
166- return $ response ->withRedirect ($ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.index ' ));
162+ return $ response ->withRedirect (flextype ('router ' )->pathFor ('admin.api_access.index ' ));
167163 }
168164 }
169165
@@ -176,9 +172,9 @@ public function addProcess(Request $request, Response $response) : Response
176172 public function edit (Request $ request , Response $ response ) : Response
177173 {
178174 $ token = $ request ->getQueryParams ()['token ' ];
179- $ token_data = $ this -> flextype -> container ('yaml ' )->decode (Filesystem::read (PATH ['project ' ] . '/tokens ' . '/access/ ' . $ token . '/token.yaml ' ));
175+ $ token_data = flextype ('yaml ' )->decode (Filesystem::read (PATH ['project ' ] . '/tokens ' . '/access/ ' . $ token . '/token.yaml ' ));
180176
181- return $ this -> flextype -> container ('twig ' )->render (
177+ return flextype ('twig ' )->render (
182178 $ response ,
183179 'plugins/admin/templates/system/api/access/edit.html ' ,
184180 [
@@ -187,15 +183,15 @@ public function edit(Request $request, Response $response) : Response
187183 'token_data ' => $ token_data ,
188184 'links ' => [
189185 'api ' => [
190- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api.index ' ),
186+ 'link ' => flextype ('router ' )->pathFor ('admin.api.index ' ),
191187 'title ' => __ ('admin_api ' )
192188 ],
193189 'api_access ' => [
194- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.index ' ),
190+ 'link ' => flextype ('router ' )->pathFor ('admin.api_access.index ' ),
195191 'title ' => __ ('admin_access ' )
196192 ],
197193 'api_tokens_edit ' => [
198- 'link ' => $ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.edit ' ),
194+ 'link ' => flextype ('router ' )->pathFor ('admin.api_access.edit ' ),
199195 'title ' => __ ('admin_edit_token ' ),
200196 'active ' => true
201197 ],
@@ -222,7 +218,7 @@ public function editProcess(Request $request, Response $response) : Response
222218 if (Filesystem::has ($ api_token_file_path )) {
223219 if (Filesystem::write (
224220 $ api_token_file_path ,
225- $ this -> flextype -> container ('yaml ' )->encode ([
221+ flextype ('yaml ' )->encode ([
226222 'title ' => $ post_data ['title ' ],
227223 'icon ' => $ post_data ['icon ' ],
228224 'limit_calls ' => (int ) $ post_data ['limit_calls ' ],
@@ -232,16 +228,16 @@ public function editProcess(Request $request, Response $response) : Response
232228 'created_by ' => $ post_data ['created_by ' ],
233229 'created_at ' => $ post_data ['created_at ' ],
234230 'updated_by ' => Session::get ('uuid ' ),
235- 'updated_at ' => date ($ this -> flextype -> container ('registry ' )->get ('flextype.settings.date_format ' ), time ()),
231+ 'updated_at ' => date (flextype ('registry ' )->get ('flextype.settings.date_format ' ), time ()),
236232 ])
237233 )) {
238- $ this -> flextype -> container ('flash ' )->addMessage ('success ' , __ ('admin_message_access_api_token_updated ' ));
234+ flextype ('flash ' )->addMessage ('success ' , __ ('admin_message_access_api_token_updated ' ));
239235 }
240236 } else {
241- $ this -> flextype -> container ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_updated ' ));
237+ flextype ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_updated ' ));
242238 }
243239
244- return $ response ->withRedirect ($ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.index ' ));
240+ return $ response ->withRedirect (flextype ('router ' )->pathFor ('admin.api_access.index ' ));
245241 }
246242
247243 /**
@@ -258,11 +254,11 @@ public function deleteProcess(Request $request, Response $response) : Response
258254 $ api_token_dir_path = PATH ['project ' ] . '/tokens ' . '/access/ ' . $ post_data ['token ' ];
259255
260256 if (Filesystem::deleteDir ($ api_token_dir_path )) {
261- $ this -> flextype -> container ('flash ' )->addMessage ('success ' , __ ('admin_message_access_api_token_deleted ' ));
257+ flextype ('flash ' )->addMessage ('success ' , __ ('admin_message_access_api_token_deleted ' ));
262258 } else {
263- $ this -> flextype -> container ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_deleted ' ));
259+ flextype ('flash ' )->addMessage ('error ' , __ ('admin_message_access_api_token_was_not_deleted ' ));
264260 }
265261
266- return $ response ->withRedirect ($ this -> flextype -> container ('router ' )->pathFor ('admin.api_access.index ' ));
262+ return $ response ->withRedirect (flextype ('router ' )->pathFor ('admin.api_access.index ' ));
267263 }
268264}
0 commit comments