src/ApplicationBundle/Modules/HoneybeeWeb/Controller/WebsiteDiagnosticController.php line 25

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Modules\HoneybeeWeb\Controller;
  3. use ApplicationBundle\Controller\GenericController;
  4. use ApplicationBundle\Modules\HoneybeeWeb\Support\WebsiteDiagnosticCore as Core;
  5. use ApplicationBundle\Modules\HoneybeeWeb\Support\PricingBook;
  6. use Symfony\Component\HttpFoundation\Request;
  7. /** Public, read-only wizard. Contact writes use the existing intent endpoint. */
  8. class WebsiteDiagnosticController extends GenericController
  9. {
  10.     public function indexAction(Request $request)
  11.     {
  12.         $catalog=Core::catalog(); $state=null$step=0$error=null$result=null;
  13.         try {
  14.             $path=$request->query->get('path');
  15.             if ($request->isMethod('POST')) {
  16.                 $state=Core::state($request->request->get('state',''));
  17.                 $all=$request->request->all();
  18.                 $progress=Core::advance($state,$request->request->get('step',0),$request->request->get('action','next'),isset($all['answer'])?$all['answer']:array());
  19.                 $state=$progress['state']; $step=$progress['step']; $result=$progress['result'];
  20.             } elseif ($path) { $state=Core::state(array('path'=>$path)); }
  21.         } catch(\InvalidArgumentException $e) { $error=$e->getMessage(); if($state){$progress=Core::advance($state,0,'resume');$step=$progress['step'];$result=$progress['result'];} }
  22.         $questions=$state?$catalog['questions'][$state['path']]:array();
  23.         $response=$this->render('@HoneybeeWeb/pages/diagnostic.html.twig',array('catalog'=>$catalog,'state'=>$state,'step'=>$step,'question'=>isset($questions[$step])?$questions[$step]:null,'total'=>count($questions),'result'=>$result,'diagnostic_error'=>$error,'prices'=>PricingBook::publicBook()));
  24.         $response->headers->set('Cache-Control','private, no-store');
  25.         $response->headers->set('X-Robots-Tag','noindex, nofollow');
  26.         return $response;
  27.     }
  28. }