Skip to content

Commit 4c164af

Browse files
committed
Merge branch 'v2-api-development' of https://github.com/nus-fboa2016-CB/eratosthenes into v2-api-development
2 parents eea5ec8 + 61ead11 commit 4c164af

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

Symfony/src/Codebender/LibraryBundle/Controller/ApiViewsController.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ public function viewLibraryAction()
230230

231231
public function gitUpdatesAction()
232232
{
233-
$handler = $this->get('codebender_library.handler');
233+
$checkGithubUpdatesCommand = $this->get('codebender_api.checkGithubUpdates');
234234

235-
$handlerResponse = $handler->checkGithubUpdates();
235+
$handlerResponse = $checkGithubUpdatesCommand->execute();
236236

237237
if ($handlerResponse['success'] !== true) {
238238
return new JsonResponse(['success' => false, 'message' => 'Invalid authorization key.']);
@@ -274,21 +274,16 @@ public function changeLibraryStatusAction($library)
274274
return new JsonResponse(['success' => false, 'message' => 'POST method required']);
275275
}
276276

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);
279279

280-
if ($exists['success'] === false) {
280+
if (!$exists) {
281281
return new JsonResponse(['success' => false, 'message' => 'Library not found.']);
282282
}
283283

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);
292287

293288
return new JsonResponse(['success' => true]);
294289
}

Symfony/src/Codebender/LibraryBundle/Resources/config/routing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ codebender_library_search_v2:
2828
defaults: { _controller: CodebenderLibraryBundle:ApiViews:search }
2929

3030
codebender_library_status_change_v2:
31-
pattern: /{authorizationKey}/v2/toggleStatus/{library}/{version}
31+
pattern: /{authorizationKey}/v2/toggleStatus/{library}
3232
defaults: {_controller:CodebenderLibraryBundle:ApiViews:changeLibraryStatus}
3333
methods: [POST]
3434

0 commit comments

Comments
 (0)