<commit_before><?php

namespace Owner\Bundle\SiteBundle\Controller;

// Symfony includes
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
// Sensio includes
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

class HelpController extends ContainerAware {

    /**
     * @Route("/{contact}")
     * @Method("GET")
     * @Template
     */
    public function contactAction() {
        $form = $this->container->get('form.factory')->create(new \Owner\Bundle\SiteBundle\Form\ContactType);
        return array('edit_form' => $form->createView());
    }

    /**
     * @Route("/{contact}")
     * @Method("POST")
     * @Template
     */
    public function performContactAction() {
        $edit_form = $this->container->get('form.factory')->create(new \Owner\Bundle\SiteBundle\Form\ContactType);
        $edit_form->bind($this->container->get('Request'));


        if ($edit_form->isValid()) {

            $notifier = $this->container->get('notifier');
            $notifier->createContactMail($edit_form->getData());
            $notifier->send();

            $this->container->get("session")->getFlashBag()->add("success", "message.sended");

//            return $this->redirectContactAction();
        }

        $this->container->get("session")->getFlashBag()->add("error", "form.error.message.not.sended");

        $template = str_replace(":performContact.html.twig", ":contact.html.twig", $this->container->get("request")->get('_template'));
        $params = array(
            'edit_form' => $edit_form->createView()
        );

        return new Response($this->container->get('templating')->render($template, $params));
    }

    protected function redirectContactAction() {
        return $this->redirectAction('owner_site_help_contact', array('contact'));
    }

    protected function redirectAction($route, $wordsToTranslate, $parameters = array()) {
        foreach ($translate as $word) {
            $parameters[$word] = $this->container->get('translator')->trans($word, array(), "routes");
        }

        return new RedirectResponse($this->container->get('router')->generate($route, $parameters));
    }

}

?><commit_msg>Fix redirection<commit_after><?php

namespace Owner\Bundle\SiteBundle\Controller;

// Symfony includes
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
// Sensio includes
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

class HelpController extends ContainerAware {

    /**
     * @Route("/{contact}")
     * @Method("GET")
     * @Template
     */
    public function contactAction() {
        $form = $this->container->get('form.factory')->create(new \Owner\Bundle\SiteBundle\Form\ContactType);
        return array('edit_form' => $form->createView());
    }

    /**
     * @Route("/{contact}")
     * @Method("POST")
     * @Template
     */
    public function performContactAction() {
        $edit_form = $this->container->get('form.factory')->create(new \Owner\Bundle\SiteBundle\Form\ContactType);
        $edit_form->bind($this->container->get('Request'));


        if ($edit_form->isValid()) {

            $notifier = $this->container->get('notifier');
            $notifier->createContactMail($edit_form->getData());
            $notifier->send();

            $this->container->get("session")->getFlashBag()->add("success", "message.sended");

//            return $this->redirectContactAction();
        }

        $this->container->get("session")->getFlashBag()->add("error", "form.error.message.not.sended");

        $template = str_replace(":performContact.html.twig", ":contact.html.twig", $this->container->get("request")->get('_template'));
        $params = array(
            'edit_form' => $edit_form->createView()
        );

        return new Response($this->container->get('templating')->render($template, $params));
    }

    protected function redirectContactAction() {
        return $this->redirectAction('owner_site_help_contact', array('contact'));
    }

    protected function redirectAction($route, $translate, $parameters = array()) {
        foreach ($translate as $word) {
            $parameters[$word] = $this->container->get('translator')->trans($word, array(), "routes");
        }

        return new RedirectResponse($this->container->get('router')->generate($route, $parameters));
    }

}

?>
{'fraction_non_alphanumeric': 0.1683953630262355, 'fraction_numerical': 0.0, 'mean_word_length': 3.6048689138576777, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 87, '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': '4227219', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1341, 'n_words': 191}