@@ -230,9 +230,9 @@ public function viewLibraryAction()
230
230
231
231
public function gitUpdatesAction ()
232
232
{
233
- $ handler = $ this ->get ('codebender_library.handler ' );
233
+ $ checkGithubUpdatesCommand = $ this ->get ('codebender_api.checkGithubUpdates ' );
234
234
235
- $ handlerResponse = $ handler -> checkGithubUpdates ();
235
+ $ handlerResponse = $ checkGithubUpdatesCommand -> execute ();
236
236
237
237
if ($ handlerResponse ['success ' ] !== true ) {
238
238
return new JsonResponse (['success ' => false , 'message ' => 'Invalid authorization key. ' ]);
@@ -274,21 +274,16 @@ public function changeLibraryStatusAction($library)
274
274
return new JsonResponse (['success ' => false , 'message ' => 'POST method required ' ]);
275
275
}
276
276
277
- $ handler = $ this ->get ('codebender_library.handler ' );
278
- $ exists = json_decode ( $ handler -> checkIfExternalExists ($ library, true ), true );
277
+ $ apiHandler = $ this ->get ('codebender_library.apiHandler ' );
278
+ $ exists = $ apiHandler -> isExternalLibrary ($ library );
279
279
280
- if ($ exists[ ' success ' ] === false ) {
280
+ if (! $ exists ) {
281
281
return new JsonResponse (['success ' => false , 'message ' => 'Library not found. ' ]);
282
282
}
283
283
284
- $ em = $ this ->getDoctrine ()->getManager ();
285
- $ lib = $ em ->getRepository ('CodebenderLibraryBundle:ExternalLibrary ' )->findBy (array ('machineName ' => $ library ));
286
- if ($ lib [0 ]->getActive ())
287
- $ lib [0 ]->setActive (0 );
288
- else
289
- $ lib [0 ]->setActive (1 );
290
- $ em ->persist ($ lib [0 ]);
291
- $ em ->flush ();
284
+ $ checkGithubUpdatesCommand = $ this ->get ('codebender_api.checkGithubUpdates ' );
285
+
286
+ $ checkGithubUpdatesCommand ->toggleLibraryStatus ($ library );
292
287
293
288
return new JsonResponse (['success ' => true ]);
294
289
}
0 commit comments