<commit_before><?php

namespace Store\FrontBundle\Controller;

use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContext;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\GetResponseUserEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Validator\Constraints\Country;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Store\AddressBundle\Entity\Address;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\Intl\Intl;
use Store\PaymentBundle\Entity\PaymentResult;

class CheckoutController extends Controller
{
    /**
     * @Route("/checkout/step/account", name="checkout_account")
     * @Template()
     */
    public function checkoutAccountAction()
    {
        if($this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            $man = $this->get('store.store_manager');
            $man->setCartAuthStatus();
            $em = $this->getDoctrine()->getManager();
            $cart = $man->getCart();
            if (!$cart->getCustomer()) {
                $cart->setCustomer($this->get('security.context')->getToken()->getUser());
                $em->persist($cart);
                $em->flush();
            }
            return $this->redirect($this->generateUrl('checkout_address'));
        }

        return array();
    }

    /**
     * @Route("/checkout/step/address", name="checkout_address")
     * @Template()
     */
    public function checkoutAddressAction(Request $request)
    {
        if(!$this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            return $this->redirect($this->generateUrl('checkout_account'));
        }
        $man = $this->get('store.store_manager');
        $man->setCartAddressStatus();

        if($request->isMethod('POST')){
            $formData = $request->request->get('form');
            if (isset($formData['both'])) {
                $newForm = array(
                    'firstname' => $formData['firstname'],
                    'lastname'  => $formData['lastname'],
                    'address_line_1' => $formData['address_line_1'],
                    'address_line_2' => $formData['address_line_2'],
                    'zip_code' => $formData['zip_code'],
                    'city' => $formData['city'],
                    'country' => $formData['country'],
                    'both' => $formData['both'],
                    '_token' => $formData['_token']
                );
                $request->request->replace(array('form' => $newForm));
        }}
        $dat = $request->request->get('form');
        if(isset($dat['both']) && $dat['both'] == 1) {
            $billing_form = $this->createMiniBillingAddressForm();
        } else {
            $billing_form = $this->createBillingAddressForm();
        }

        $billing_form->handleRequest($request);

        if ($billing_form->isValid()) {
            $data = $billing_form->getData();
            $this->createAddress($data);



            return $this->redirect($this->generateUrl('checkout_shipping'));
        }
        $cart = $man->getCart();
        $addrSet = false;
        if ($cart->getBillingAddress() && $cart->getShippingAddress()) {
            $addrSet = true;
        }
        var_dump($addrSet);

        return array('form' => $billing_form->createView(), 'isSet' => $addrSet);
    }

    /**
     * @Route("/checkout/step/confirmation", name="checkout_confirm")
     * @Template()
     */
    public function checkoutConfirmAction()
    {
        $em = $this->getDoctrine()->getManager();
        $req = $this->getRequest();
        $em->getRepository('StoreProductBundle:Product')->findAllByLocaleForTrans($req->getLocale());
        $man = $this->get('store.store_manager');
        $cart = $man->getCart();
        if (count($cart->getItems()) <= 0) {
            return $this->redirect($this->generateUrl('homeweb'));
        }
        if (!$cart->getBillingAddress() || !$cart->getShippingAddress()) {<commit_msg>removed dump<commit_after><?php

namespace Store\FrontBundle\Controller;

use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContext;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\GetResponseUserEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Validator\Constraints\Country;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Store\AddressBundle\Entity\Address;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\Intl\Intl;
use Store\PaymentBundle\Entity\PaymentResult;

class CheckoutController extends Controller
{
    /**
     * @Route("/checkout/step/account", name="checkout_account")
     * @Template()
     */
    public function checkoutAccountAction()
    {
        if($this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            $man = $this->get('store.store_manager');
            $man->setCartAuthStatus();
            $em = $this->getDoctrine()->getManager();
            $cart = $man->getCart();
            if (!$cart->getCustomer()) {
                $cart->setCustomer($this->get('security.context')->getToken()->getUser());
                $em->persist($cart);
                $em->flush();
            }
            return $this->redirect($this->generateUrl('checkout_address'));
        }

        return array();
    }

    /**
     * @Route("/checkout/step/address", name="checkout_address")
     * @Template()
     */
    public function checkoutAddressAction(Request $request)
    {
        if(!$this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            return $this->redirect($this->generateUrl('checkout_account'));
        }
        $man = $this->get('store.store_manager');
        $man->setCartAddressStatus();

        if($request->isMethod('POST')){
            $formData = $request->request->get('form');
            if (isset($formData['both'])) {
                $newForm = array(
                    'firstname' => $formData['firstname'],
                    'lastname'  => $formData['lastname'],
                    'address_line_1' => $formData['address_line_1'],
                    'address_line_2' => $formData['address_line_2'],
                    'zip_code' => $formData['zip_code'],
                    'city' => $formData['city'],
                    'country' => $formData['country'],
                    'both' => $formData['both'],
                    '_token' => $formData['_token']
                );
                $request->request->replace(array('form' => $newForm));
        }}
        $dat = $request->request->get('form');
        if(isset($dat['both']) && $dat['both'] == 1) {
            $billing_form = $this->createMiniBillingAddressForm();
        } else {
            $billing_form = $this->createBillingAddressForm();
        }

        $billing_form->handleRequest($request);

        if ($billing_form->isValid()) {
            $data = $billing_form->getData();
            $this->createAddress($data);



            return $this->redirect($this->generateUrl('checkout_shipping'));
        }
        $cart = $man->getCart();
        $addrSet = false;
        if ($cart->getBillingAddress() && $cart->getShippingAddress()) {
            $addrSet = true;
        }

        return array('form' => $billing_form->createView(), 'isSet' => $addrSet);
    }

    /**
     * @Route("/checkout/step/confirmation", name="checkout_confirm")
     * @Template()
     */
    public function checkoutConfirmAction()
    {
        $em = $this->getDoctrine()->getManager();
        $req = $this->getRequest();
        $em->getRepository('StoreProductBundle:Product')->findAllByLocaleForTrans($req->getLocale());
        $man = $this->get('store.store_manager');
        $cart = $man->getCart();
        if (count($cart->getItems()) <= 0) {
            return $this->redirect($this->generateUrl('homeweb'));
        }
        if (!$cart->getBillingAddress() || !$cart->getShippingAddress()) {
{'fraction_non_alphanumeric': 0.1582258236485766, 'fraction_numerical': 0.0012794540995841775, 'mean_word_length': 2.8458384583845837, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 135, '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': '1689133', 'n_tokens_mistral': 2665, 'n_tokens_neox': 2609, 'n_words': 344}