/**
  * @param Repository $repository
  * @param string $commit
  * @param array $context
  * @throws \Github\Exception\MissingArgumentException
  */
 public function createStatus(Repository $repository, $commit, $context)
 {
     $statusesApi = $this->getStatusesApi($repository->getOwner()->getAccessToken());
     $repositoryOwnerName = $repository->getOwner()->getUsername();
     $repositoryName = $repository->getName();
     $statusesApi->create($repositoryOwnerName, $repositoryName, $commit, ['state' => isset($context['state']) ? $context['state'] : null, 'description' => $context['description'], 'context' => $this->statusContext]);
 }
 /**
  * @param Repository $repository
  * @return JsonResponse
  */
 public function toggleAction(Repository $repository)
 {
     if ($repository->getOwner()->getId() !== $this->getUser()->getId()) {
         $this->createAccessDeniedException();
     }
     $webhookManager = $this->get('ac.webhook.manager.webhook_manager');
     $webhookManager->toggleRepositoryWebhook($repository);
     return new JsonResponse(['success' => true]);
 }
 /**
  * @param Repository $repository
  */
 public function toggleRepositoryWebhook(Repository $repository)
 {
     /** @var User $user */
     $user = $this->tokenStorage->getToken()->getUser();
     if ($repository->getEnabled()) {
         $this->githubManager->removeWebhook($user->getUsername(), $repository->getName(), $repository->getWebhookId());
         $webhookId = null;
     } else {
         $webhookId = $this->githubManager->createWebhook($user->getUsername(), $repository->getName());
     }
     // Update state of repository webhook
     $repository->setWebhookId($webhookId);
     $repositoryManager = $this->doctrine->getManagerForClass(ClassUtils::getClass($repository));
     $repositoryManager->flush();
 }