Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function saveAction()
- {
- $user = $this->get('security.context')->getToken()->getUser();
- if (false === $this->get('security.context')->isGranted('ROLE_USER')) {
- throw new AccessDeniedException('This user does not have access to this section.');
- }
- $request = $this->getRequest();
- if (!$request->isXmlHttpRequest()) {
- return $this->redirect('/');
- }
- // load the serivce
- $themeDesigner = $this->get('themedesigner');
- // get the current variant for that user \ or null if there is none
- $variant = $themeDesigner->getVariantByUser($user);
- $form = $this->get('qiip_design.form.variant');
- $form->bindRequest($request);
- if($form->isValid()){
- $logger->info("Valid");
- }else{
- $logger->info("Not Valid");
- }
- $logger->info($form->getData()->getCssParams());
- /*
- // add some other data to the request
- // $request->request->css_generated = $this->CssFormatter($request->request->get('cssParams'));
- // load the serivce
- $themeDesigner = $this->get('themedesigner');
- // get the current variant for that user \ or null if there is none
- $variant = $themeDesigner->getVariantByUser($user);
- //$form = $this->get('qiip_design.form.variant');
- $form = $this->createForm(new VariantType(), $variant);
- $form->bindRequest($request);
- // $varDump = var_export($request->request->all(), true);
- $varDump = var_export($variant, true);
- $logger = $this->get('logger');
- $logger->info($varDump);
- */
- /*
- // grab the data
- $themeData = $request->request->get('themeData');
- $advancedCss = $request->request->get('advancedCss');
- $generated = $this->CssFormatter($themeData);
- $styleId = $request->request->get('styleId');
- // if no style Id has been passed we choose the default style
- $styleId = (!$styleId) ? $this->container->getParameter('style.default_layout') : $styleId;
- // get the relevant style
- $style = $themeDesigner->getStyleById($styleId);
- // prepare the form
- $form = $this->createForm(new VariantType(), $variant);
- */
- /*
- $variant = new Variant();
- $variant->setStyle($style);
- $variant->setUser($user);
- $variant->setCssParams($themeData);
- $variant->setAdvancedCss($advancedCss);
- $variant->setGeneratedCss($generated);
- */
- //$this->get('service_id')->persist($data, $variant);
- // $em = $this->getDoctrine()->getEntityManager();
- // check it's an ajax request
- // if ( $request->isXmlHttpRequest() ) {
- /*
- // grab the data
- $themeData = $request->request->get('themeData');
- $advancedCss = $request->request->get('advancedCss');
- $generated = $this->CssFormatter($themeData);
- $styleId = $request->request->get('styleId');
- // if no style Id has been passed we choose the default style
- $styleId = (!$styleId) ? $this->container->getParameter('style.default_layout') : $styleId;
- // get the relevant style
- $style = $themeDesigner->getStyleById($styleId);
- // load the service
- $themeDesigner = $this->get('themedesigner');
- */
- /*
- $variant = $themeDesigner->getVariantByUser($user);
- if (!$variant instanceof Entity\Variant) {
- // update
- $variant = $themeDesigner->getVariantByUser($user);
- $variant->setStyle($style);
- $variant->setUser($user);
- $variant->setCssParams($themeData);
- $variant->setAdvancedCss($advancedCss);
- $variant->setGeneratedCss($generated);
- $em->flush();
- }else{
- // create new
- $variant = new Variant();
- $variant->setStyle($style);
- $variant->setUser($user);
- $variant->setCssParams($themeData);
- $variant->setAdvancedCss($advancedCss);
- $variant->setGeneratedCss($generated);
- $em->persist($variant);
- $em->flush();
- }
- */
- /*
- // } else {
- throw new AccessDeniedException('Request type not permitted');
- }
- */
- $response = new Response(json_encode(array( "message" => "Your changes have been saved")));
- $response->headers->set('Content-Type', 'application/json');
- return $response;
- }
Advertisement
Add Comment
Please, Sign In to add comment