<commit_before><?php

namespace Assmat\Controllers\Admin;

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Form\FormFactoryInterface;
use Assmat\DataSource\Repositories;
use Assmat\DataSource\Domains;
use Assmat\DataSource\Forms;
use Symfony\Component\HttpFoundation\Request;
use Assmat\DataSource\DataTransferObjects as DTO;
use Assmat\Iterators\Filters as FilterIterators;
use Symfony\Component\Security\Core\SecurityContextInterface;

class Evenement
{
    private
        $twig,
        $request,
        $security,
        $formFactory,
        $evenementRepository,
        $evenementTypeRepository,
        $bulletinRepository,
        $contratRepository;

    public function __construct(\Twig_Environment $twig, Request $request, SecurityContextInterface $security, FormFactoryInterface $formFactory, Repositories\Evenement $evenementRepository, Repositories\EvenementType $evenementTypeRepository, Repositories\Bulletin $bulletinRepository, Repositories\Contrat $contratRepository)
    {
        $this->twig = $twig;
        $this->request = $request;
        $this->security = $security;
        $this->formFactory = $formFactory;
        $this->evenementRepository = $evenementRepository;
        $this->evenementTypeRepository = $evenementTypeRepository;
        $this->bulletinRepository = $bulletinRepository;
        $this->contratRepository = $contratRepository;
    }

    public function listAction($contratId)
    {
        $contrat = $this->contratRepository->find($contratId);
        $contrat->validateContactAutorisation($this->getContact());

        $mois = $this->request->get('mois') ? $this->request->get('mois') : date('m');
        $annee = $this->request->get('annee') ? $this->request->get('annee') : date('Y');
        $this->validateRangeDateParams($mois, $annee);

        $evenements = $this->evenementRepository->findAllFromContrat($contratId, new \DateTime(sprintf('%s-%s', $annee, $mois)));

        $bulletinId = null;
        $bulletin = $this->bulletinRepository->findOneFromContratAndDate($contratId, $annee, $mois);
        if($bulletin instanceof Domains\Bulletin)
        {
            $bulletinId = $bulletin->getId();
        }

        return new Response($this->twig->render('admin/evenements/contrat.html.twig', array(
            'contrat' => $contrat,
            'evenements' => $evenements,
            'evenementsType' => new FilterIterators\Evenements\Types\DureeFixe(new \ArrayIterator($this->evenementTypeRepository->findAll())),
            'mois' => $mois,
            'annee' => $annee,
            'bulletinId' => $bulletinId,
        )));
    }

    public function ContactListAction()
    {
        $mois = $this->request->get('mois') ? $this->request->get('mois') : date('m');
        $annee = $this->request->get('annee') ? $this->request->get('annee') : date('Y');
        $this->validateRangeDateParams($mois, $annee);

        $contactId = $this->getContact()->getId();
        $evenements = $this->evenementRepository->findAllFromContact($contactId, new \DateTime(sprintf('%s-%s', $annee, $mois)));
        $contrats = $this->contratRepository->findFromContact($contactId);

        return new Response($this->twig->render('admin/evenements/contact.html.twig', array(
            'contrats' => $contrats,<commit_msg>fix: set controller method as camelcase<commit_after><?php

namespace Assmat\Controllers\Admin;

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Form\FormFactoryInterface;
use Assmat\DataSource\Repositories;
use Assmat\DataSource\Domains;
use Assmat\DataSource\Forms;
use Symfony\Component\HttpFoundation\Request;
use Assmat\DataSource\DataTransferObjects as DTO;
use Assmat\Iterators\Filters as FilterIterators;
use Symfony\Component\Security\Core\SecurityContextInterface;

class Evenement
{
    private
        $twig,
        $request,
        $security,
        $formFactory,
        $evenementRepository,
        $evenementTypeRepository,
        $bulletinRepository,
        $contratRepository;

    public function __construct(\Twig_Environment $twig, Request $request, SecurityContextInterface $security, FormFactoryInterface $formFactory, Repositories\Evenement $evenementRepository, Repositories\EvenementType $evenementTypeRepository, Repositories\Bulletin $bulletinRepository, Repositories\Contrat $contratRepository)
    {
        $this->twig = $twig;
        $this->request = $request;
        $this->security = $security;
        $this->formFactory = $formFactory;
        $this->evenementRepository = $evenementRepository;
        $this->evenementTypeRepository = $evenementTypeRepository;
        $this->bulletinRepository = $bulletinRepository;
        $this->contratRepository = $contratRepository;
    }

    public function listAction($contratId)
    {
        $contrat = $this->contratRepository->find($contratId);
        $contrat->validateContactAutorisation($this->getContact());

        $mois = $this->request->get('mois') ? $this->request->get('mois') : date('m');
        $annee = $this->request->get('annee') ? $this->request->get('annee') : date('Y');
        $this->validateRangeDateParams($mois, $annee);

        $evenements = $this->evenementRepository->findAllFromContrat($contratId, new \DateTime(sprintf('%s-%s', $annee, $mois)));

        $bulletinId = null;
        $bulletin = $this->bulletinRepository->findOneFromContratAndDate($contratId, $annee, $mois);
        if($bulletin instanceof Domains\Bulletin)
        {
            $bulletinId = $bulletin->getId();
        }

        return new Response($this->twig->render('admin/evenements/contrat.html.twig', array(
            'contrat' => $contrat,
            'evenements' => $evenements,
            'evenementsType' => new FilterIterators\Evenements\Types\DureeFixe(new \ArrayIterator($this->evenementTypeRepository->findAll())),
            'mois' => $mois,
            'annee' => $annee,
            'bulletinId' => $bulletinId,
        )));
    }

    public function contactListAction()
    {
        $mois = $this->request->get('mois') ? $this->request->get('mois') : date('m');
        $annee = $this->request->get('annee') ? $this->request->get('annee') : date('Y');
        $this->validateRangeDateParams($mois, $annee);

        $contactId = $this->getContact()->getId();
        $evenements = $this->evenementRepository->findAllFromContact($contactId, new \DateTime(sprintf('%s-%s', $annee, $mois)));
        $contrats = $this->contratRepository->findFromContact($contactId);

        return new Response($this->twig->render('admin/evenements/contact.html.twig', array(
            'contrats' => $contrats,
{'fraction_non_alphanumeric': 0.14423361992291728, 'fraction_numerical': 0.0, 'mean_word_length': 3.640302613480055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2252988', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1969, 'n_words': 308}