Пример #1
0
 /**
  * @param HttpFoundation\Request $request
  * @return HttpFoundation\Response
  */
 public function postGitHub(HttpFoundation\Request $request)
 {
     $rawContent = $request->getContent();
     $repoContent = json_decode($rawContent, true);
     $watchedRepo = $this->watchedReposRepository->createNew($repoContent['name']);
     //This should come from the OAuth token.
     $user = $request->get('user');
     $success = $this->githubRepo->installHook($user, $watchedRepo, $this->baseUrl);
     if ($success) {
         return $this->watchedReposRepository->save($watchedRepo) ? new HttpFoundation\JsonResponse($watchedRepo, 201) : new HttpFoundation\Response('Failed to Save', 507);
     }
     return new HttpFoundation\Response('GitHub Request Failed', 502);
 }