<?php
namespace ApplicationBundle\Modules\HoneybeeWeb\Controller;
use ApplicationBundle\Controller\GenericController;
use ApplicationBundle\Modules\HoneybeeWeb\Support\WebsiteDiagnosticCore as Core;
use ApplicationBundle\Modules\HoneybeeWeb\Support\PricingBook;
use Symfony\Component\HttpFoundation\Request;
/** Public, read-only wizard. Contact writes use the existing intent endpoint. */
class WebsiteDiagnosticController extends GenericController
{
public function indexAction(Request $request)
{
$catalog=Core::catalog(); $state=null; $step=0; $error=null; $result=null;
try {
$path=$request->query->get('path');
if ($request->isMethod('POST')) {
$state=Core::state($request->request->get('state',''));
$all=$request->request->all();
$progress=Core::advance($state,$request->request->get('step',0),$request->request->get('action','next'),isset($all['answer'])?$all['answer']:array());
$state=$progress['state']; $step=$progress['step']; $result=$progress['result'];
} elseif ($path) { $state=Core::state(array('path'=>$path)); }
} catch(\InvalidArgumentException $e) { $error=$e->getMessage(); if($state){$progress=Core::advance($state,0,'resume');$step=$progress['step'];$result=$progress['result'];} }
$questions=$state?$catalog['questions'][$state['path']]:array();
$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()));
$response->headers->set('Cache-Control','private, no-store');
$response->headers->set('X-Robots-Tag','noindex, nofollow');
return $response;
}
}