<commit_before><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\ProductBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Form\FormView;

use Sonata\Component\Basket\BasketElementInterface;
use Sonata\Component\Order\OrderElementInterface;
use Sonata\Component\Basket\BasketInterface;

abstract class BaseProductController extends Controller
{
    /**
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     * @param $product
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function viewAction($product)
    {
        if (!is_object($product)) {
            throw new NotFoundHttpException('invalid product instance');
        }

        $form     = $this->get('session')->getFlashBag()->get('sonata.product.form');
        $provider = $this->get('sonata.product.pool')->getProvider($product);

        if (!$form) {
            $formBuilder = $this->get('form.factory')->createNamedBuilder('add_basket', 'form', null, array('data_class' => $this->container->getParameter('sonata.basket.basket_element.class')));
            $provider->defineAddBasketForm($product, $formBuilder);

            $form = $formBuilder->getForm()->createView();
        }

        return $this->render(sprintf('%s:view.html.twig', $provider->getBaseControllerName()), array(
           'product' => $product,
           'form'    => $form,
        ));
    }

    /**
     * @param  \Symfony\Component\Form\FormView                    $formView
     * @param  \Sonata\Component\Basket\BasketElementInterface     $basketElement
     * @param  \Sonata\Component\Basket\BasketInterface            $basket
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function renderFormBasketElementAction(FormView $formView, BasketElementInterface $basketElement, BasketInterface $basket)
    {
        $provider = $this->get('sonata.product.pool')->getProvider($basketElement->getProduct());

        return $this->render(sprintf('%s:form_basket_element.html.twig', $provider->getBaseControllerName()), array(
            'formView'      => $formView,
            'basketElement' => $basketElement,
            'basket'        => $basket
        ));
    }

    /**
     * @param  \Sonata\Component\Basket\BasketElementInterface     $basketElement
     * @param  \Sonata\Component\Basket\BasketInterface            $basket
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function renderFinalReviewBasketElementAction(BasketElementInterface $basketElement, BasketInterface $basket)
    {
        $provider = $this->get('sonata.product.pool')->getProvider($basketElement->getProduct());

        return $this->render(sprintf('%s:final_review_basket_element.html.twig', $provider->getBaseControllerName()), array(
            'basketElement' => $basketElement,
            'basket'        => $basket
        ));
    }

    /**
     * @param string $productId
     * @param string $slug
     */
    abstract public function viewVariationsAction($productId, $slug)
    {

    }

    /**
     * @param BasketElementInterface $basketElement
     */
    abstract public function viewBasketElement(BasketElementInterface $basketElement)
    {

    }

    /**
     * @param BasketElementInterface $basketElement
     */
    abstract public function viewBasketElementConfirmation(BasketElementInterface $basketElement)
    {

    }

    /**
     * @param OrderElementInterface $orderElement
     */
    abstract public function viewOrderElement(OrderElementInterface $orderElement)
    {

    }

    /**
     * @param OrderElementInterface $orderElement
     */
    abstract public function viewEditOrderElement(OrderElementInterface $orderElement)
    {

    }
}<commit_msg>Fixed PHP issue<commit_after><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\ProductBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Form\FormView;

use Sonata\Component\Basket\BasketElementInterface;
use Sonata\Component\Order\OrderElementInterface;
use Sonata\Component\Basket\BasketInterface;

abstract class BaseProductController extends Controller
{
    /**
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     * @param $product
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function viewAction($product)
    {
        if (!is_object($product)) {
            throw new NotFoundHttpException('invalid product instance');
        }

        $form     = $this->get('session')->getFlashBag()->get('sonata.product.form');
        $provider = $this->get('sonata.product.pool')->getProvider($product);

        if (!$form) {
            $formBuilder = $this->get('form.factory')->createNamedBuilder('add_basket', 'form', null, array('data_class' => $this->container->getParameter('sonata.basket.basket_element.class')));
            $provider->defineAddBasketForm($product, $formBuilder);

            $form = $formBuilder->getForm()->createView();
        }

        return $this->render(sprintf('%s:view.html.twig', $provider->getBaseControllerName()), array(
           'product' => $product,
           'form'    => $form,
        ));
    }

    /**
     * @param  \Symfony\Component\Form\FormView                    $formView
     * @param  \Sonata\Component\Basket\BasketElementInterface     $basketElement
     * @param  \Sonata\Component\Basket\BasketInterface            $basket
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function renderFormBasketElementAction(FormView $formView, BasketElementInterface $basketElement, BasketInterface $basket)
    {
        $provider = $this->get('sonata.product.pool')->getProvider($basketElement->getProduct());

        return $this->render(sprintf('%s:form_basket_element.html.twig', $provider->getBaseControllerName()), array(
            'formView'      => $formView,
            'basketElement' => $basketElement,
            'basket'        => $basket
        ));
    }

    /**
     * @param  \Sonata\Component\Basket\BasketElementInterface     $basketElement
     * @param  \Sonata\Component\Basket\BasketInterface            $basket
     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
     */
    public function renderFinalReviewBasketElementAction(BasketElementInterface $basketElement, BasketInterface $basket)
    {
        $provider = $this->get('sonata.product.pool')->getProvider($basketElement->getProduct());

        return $this->render(sprintf('%s:final_review_basket_element.html.twig', $provider->getBaseControllerName()), array(
            'basketElement' => $basketElement,
            'basket'        => $basket
        ));
    }

    /**
     * @param string $productId
     * @param string $slug
     */
    public function viewVariationsAction($productId, $slug)
    {

    }

    /**
     * @param BasketElementInterface $basketElement
     */
    public function viewBasketElement(BasketElementInterface $basketElement)
    {

    }

    /**
     * @param BasketElementInterface $basketElement
     */
    public function viewBasketElementConfirmation(BasketElementInterface $basketElement)
    {

    }

    /**
     * @param OrderElementInterface $orderElement
     */
    public function viewOrderElement(OrderElementInterface $orderElement)
    {

    }

    /**
     * @param OrderElementInterface $orderElement
     */
    public function viewEditOrderElement(OrderElementInterface $orderElement)
    {

    }
}
{'fraction_non_alphanumeric': 0.12340793866699641, 'fraction_numerical': 0.0, 'mean_word_length': 3.088978766430738, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 73, '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': '676761', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2220, 'n_words': 373}