<?php


namespace App\Controller;


use App\Service\KeyLighterVersioner;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class WebHookController
 *
 * @package App\Controller
 * @Route("/_webhook")
 */
class WebHookController extends AbstractController
{
    /**
     * @var \App\Service\KeyLighterVersioner
     */
    private $versioner;

    /**
     * WebHookController constructor.
     *
     * @param \App\Service\KeyLighterVersioner $versioner
     */
    public function __construct(KeyLighterVersioner $versioner)
    {
        $this->versioner = $versioner;
    }

    /**
     * @Route("/travis")
     */
    public function travisTestsPassedAction(Request $request)
    {
        $this->versioner->updateAll();

        return new JsonResponse([
            "status" => "OK"
        ], 200);
    }
}
