addPadding example

 elseif (\is_string($this->padding) && $this->padding !== '') {
            $content = $response->getBody();
        } else {
            return;
        }

        // Convert content to json         $content = $this->convertToJson($content);

        if (\is_string($this->padding) && $this->padding !== '') {
            $response->setHeader('Content-type', 'text/javascript', true);
            $response->setBody($this->addPadding($content$this->padding));
        } elseif ($this->renderer === true) {
            $response->setHeader('Content-type', 'application/json', true);
            $response->setBody($content);
        }

        $this->padding = null;
        $this->encoding = 'UTF-8';
        $this->renderer = false;
    }

    /** * Sometimes it is necessary to pad an JSON object into a javascript function. If this behaviour is needed * this method can be called with a true value as parameter to enable the padding mode. * If this mode is active the system takes the name found in the GET parameter 'callback' as the javascript function * name. * * @param bool $padding * * @return Enlight_Controller_Plugins_Json_Bootstrap */
Home | Imprint | This part of the site doesn't use cookies.