protected function _injectDatatableScript(Response $response, Request $request)
    {
        $content  = $response->getContent();
        $pos_body = strripos($content, '</body>');
        if (!$pos_body)
        {
            return;
        }
        $session       = $request->getSession();
        $dom           = '<script id="alidatatable-scripts" type="text/javascript">';
        $pos_container = strripos($content, 'alidatatable-scripts');
        $sess_dta      = $session->get('datatable',array());
        $dta_script    = null;
        if ($sess_dta)
        {
            array_walk($sess_dta, function(&$part, &$key) {
                $part = trim(preg_replace('/\s\s+/', ' ', $part));
            });
            $dta_script = implode("\n", $sess_dta);
        }
        $session->set('datatable', array());
        if (!$pos_container)
        {
            $dta_container = $dom;
            $content       = substr_replace($content, $dta_container . '</script>', $pos_body, 0);
            $response->setContent($content);
        }
        $pos_dta = strripos($content, $dom);
        $content = substr_replace($content, $dta_script, $pos_dta + strlen($dom), 0);
        $response->setContent($content);
    }
protected function _injectDatatableScript(Response $response, Request $request)
    {
        $content  = $response->getContent();
        $pos_body = strripos($content, '</body>');
        if (!$pos_body)
        {
            return;
        }
        $session       = $request->getSession();
        $dom           = '<script id="alidatatable-scripts" type="text/javascript">';
        $pos_container = strripos($content, 'alidatatable-scripts');
        $sess_dta      = $session->get('datatable',array());
        $dta_script    = null;
        if ($sess_dta)
        {
            array_walk($sess_dta, function(&$part, &$key) {
                $part = trim(preg_replace('/\s\s+/', ' ', $part));
            });
            $dta_script = implode("\n", $sess_dta);
        }
        $session->set('datatable', array());
        if (!$pos_container)
        {
            $dta_container = $dom;
            $content       = substr_replace($content, $dta_container . '</script>', $pos_body, 0);
            $response->setContent($content);
        }
        $pos_dta = strripos($content, $dom);
        $content = substr_replace($content, $dta_script, $pos_dta + strlen($dom), 0);
        $response->setContent($content);
    }
protected function _injectDatatableScript ( Response $ response , Request $ request ) { $ content = $ response -> getContent ( ) ; $ pos_body = strripos ( $ content , '</body>' ) ; if ( ! $ pos_body ) { return ; } $ session = $ request -> getSession ( ) ; $ dom = '<script id="alidatatable-scripts" type="text/javascript">' ; $ pos_container = strripos ( $ content , 'alidatatable-scripts' ) ; $ sess_dta = $ session -> get ( 'datatable' , array ( ) ) ; $ dta_script = null ; if ( $ sess_dta ) { array_walk ( $ sess_dta , function ( & $ part , & $ key ) { $ part = trim ( preg_replace ( '/\s\s+/' , ' ' , $ part ) ) ; } ) ; $ dta_script = implode ( "\n" , $ sess_dta ) ; } $ session -> set ( 'datatable' , array ( ) ) ; if ( ! $ pos_container ) { $ dta_container = $ dom ; $ content = substr_replace ( $ content , $ dta_container . '</script>' , $ pos_body , 0 ) ; $ response -> setContent ( $ content ) ; } $ pos_dta = strripos ( $ content , $ dom ) ; $ content = substr_replace ( $ content , $ dta_script , $ pos_dta + strlen ( $ dom ) , 0 ) ; $ response -> setContent ( $ content ) ; }
Injects the datatable scripts into the given HTTP Response.

@param Response $response A Response instance
Injects the datatable scripts into the given HTTP Response .