public function getAjaxBlockAction(Request $request, $_ajaxController)
    {
        $response = new Response();
        $response->headers->set('Content-Type', 'application/json');
        try {
            list($controllerParams, $controllerQuery) = $this->getControllerParams($request, $_ajaxController);
            $controllerResponse = $this->forward($_ajaxController, $controllerParams, $controllerQuery);
            $responseContent = array(
                'block' => $controllerResponse->getContent(),
            );
        } catch (AjaxBlocksException $ex) {
            $responseContent = array(
                'error' => array(
                    'code' => $ex->getCode(),
                    'error' => $ex->getMessage(),
                ),
            );
            $response->setStatusCode(406);
        } catch (\Exception $ex) {
            $responseContent = array(
                'error' => array(
                    'code' => AjaxBlocksErrorCodes::UNKNOWN_EXCEPTION,
                    'error' => get_class($ex).'('.$ex->getCode().'): '.$ex->getMessage(),
                ),
            );
            $response->setStatusCode(500);
        }

        $response->setContent(json_encode($responseContent));

        return $response;
    }
public function getAjaxBlockAction(Request $request, $_ajaxController)
    {
        $response = new Response();
        $response->headers->set('Content-Type', 'application/json');
        try {
            list($controllerParams, $controllerQuery) = $this->getControllerParams($request, $_ajaxController);
            $controllerResponse = $this->forward($_ajaxController, $controllerParams, $controllerQuery);
            $responseContent = array(
                'block' => $controllerResponse->getContent(),
            );
        } catch (AjaxBlocksException $ex) {
            $responseContent = array(
                'error' => array(
                    'code' => $ex->getCode(),
                    'error' => $ex->getMessage(),
                ),
            );
            $response->setStatusCode(406);
        } catch (\Exception $ex) {
            $responseContent = array(
                'error' => array(
                    'code' => AjaxBlocksErrorCodes::UNKNOWN_EXCEPTION,
                    'error' => get_class($ex).'('.$ex->getCode().'): '.$ex->getMessage(),
                ),
            );
            $response->setStatusCode(500);
        }

        $response->setContent(json_encode($responseContent));

        return $response;
    }
public function getAjaxBlockAction ( Request $ request , $ _ajaxController ) { $ response = new Response ( ) ; $ response -> headers -> set ( 'Content-Type' , 'application/json' ) ; try { list ( $ controllerParams , $ controllerQuery ) = $ this -> getControllerParams ( $ request , $ _ajaxController ) ; $ controllerResponse = $ this -> forward ( $ _ajaxController , $ controllerParams , $ controllerQuery ) ; $ responseContent = array ( 'block' => $ controllerResponse -> getContent ( ) , ) ; } catch ( AjaxBlocksException $ ex ) { $ responseContent = array ( 'error' => array ( 'code' => $ ex -> getCode ( ) , 'error' => $ ex -> getMessage ( ) , ) , ) ; $ response -> setStatusCode ( 406 ) ; } catch ( \ Exception $ ex ) { $ responseContent = array ( 'error' => array ( 'code' => AjaxBlocksErrorCodes :: UNKNOWN_EXCEPTION , 'error' => get_class ( $ ex ) . '(' . $ ex -> getCode ( ) . '): ' . $ ex -> getMessage ( ) , ) , ) ; $ response -> setStatusCode ( 500 ) ; } $ response -> setContent ( json_encode ( $ responseContent ) ) ; return $ response ; }
Gets a request for an ajax block and calls the right controller to build it

@param Request $request
@param string $_ajaxController

@return Response
Gets a request for an ajax block and calls the right controller to build it