<commit_before><?php

namespace WBB\BarBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use WBB\BarBundle\Entity\Tip;
use WBB\BarBundle\Form\TipType;

/**
 * TipsController
 */
class TipsController extends Controller
{
    /**
     * addAction
     *
     * @param \Symfony\Component\HttpFoundation\Request $request
     *
     * @return JsonResponse
     */
    public function addAction(Request $request)
    {
//        $idUser = $this->getUser()->getId();
        $user = $this->container->get('user.repository')->findOneById(1);

        $tip = new Tip();
        $tip
            ->setUser($user)
            ->setStatus(0);

        $form = $this->createForm(new TipType(), $tip, array('em' => $this->container->get('doctrine.orm.entity_manager')));

        if ('POST' === $request->getMethod()) {
            $form->submit($request);

            if ($form->isValid()) {
                $em = $this->getDoctrine()->getManager();
                $em->persist($tip);
                $em->flush();

                $tipHTML = $this->renderView('WBBBarBundle:Bar:tip.html.twig', array('tip' => $tip));

                return new JsonResponse(array(
                    'code'=>200,
                    'message'=>'Tip submitted!',
                    'tip' => $tipHTML
                ));
            }
            else
            {
                return new JsonResponse(array('code'=>500, 'message'=>'Unknown Error!'));
            }
        }
    }

    public function loadTipsAction($barID, $offset = 3, $limit = 8)
    {
        $bar    = $this->container->get('bar.repository')->findOneById($barID);
        $tips   = $this->container->get('tip.repository')->findLatestTips($bar, $offset, $limit);


        return $this->render('WBBBarBundle:Bar:wbbTips.html.twig', array(
                'bar'       => $bar,
                'tips'      => $tips,
                'offset'    => $offset,
                'limit'      => $limit
            )
        );
    }
}
<commit_msg>Fixed Tips errors on add<commit_after><?php

namespace WBB\BarBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use WBB\BarBundle\Entity\Tip;
use WBB\BarBundle\Form\TipType;

/**
 * TipsController
 */
class TipsController extends Controller
{
    /**
     * addAction
     *
     * @param \Symfony\Component\HttpFoundation\Request $request
     *
     * @return JsonResponse
     */
    public function addAction(Request $request)
    {
//        $idUser = $this->getUser()->getId();
        $user = $this->container->get('user.repository')->findOneById(1);

        $tip = new Tip();
        $tip
            ->setUser($user)
            ->setStatus(0);

        $form = $this->createForm(new TipType(), $tip, array('em' => $this->container->get('doctrine.orm.entity_manager')));

        if ('POST' === $request->getMethod()) {
            $form->submit($request);

            if ($form->isValid()) {
                $em = $this->getDoctrine()->getManager();
                $em->persist($tip);
                $em->flush();

                $tipHTML = $this->renderView('WBBBarBundle:Bar:tip.html.twig', array('tip' => $tip));

                return new JsonResponse(array(
                    'code'=>200,
                    'message'=>'Tip submitted!',
                    'tip' => $tipHTML
                ));
            }
            else
            {
                return new JsonResponse(array('code'=>500, 'message'=>'Unknown Error!'));
            }
        }
    }

    public function loadTipsAction($barID, $offset = 3, $limit = 8)
    {
        $bar    = $this->container->get('bar.repository')->findOneById($barID);
        $tips   = $this->container->get('tip.repository')->findLatestTips($bar, $offset, $limit);


        return $this->render('WBBBarBundle:Bar:wbbTips.html.twig', array(
                'bar'       => $bar,
                'tips'      => $tips,
                'offset'    => $offset,
                'limit'      => $limit
            )
        );
    }
}

{'fraction_non_alphanumeric': 0.16160672582905183, 'fraction_numerical': 0.004670714619336758, 'mean_word_length': 1.917574931880109, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '6880888', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1215, 'n_words': 198}