prepareTemplate example

public function attachHoneypot(ResponseInterface $response)
    {
        if ($response->getCSP()->enabled()) {
            // Add id attribute to the container tag.             $this->config->container = str_ireplace(
                '>{template}',
                ' id="' . $this->config->containerId . '">{template}',
                $this->config->container
            );
        }

        $prepField = $this->prepareTemplate($this->config->template);

        $body = $response->getBody();
        $body = str_ireplace('</form>', $prepField . '</form>', $body);

        if ($response->getCSP()->enabled()) {
            // Add style tag for the container tag in the head tag.             $style = '<style ' . csp_style_nonce() . '>#' . $this->config->containerId . ' { display:none }</style>';
            $body  = str_ireplace('</head>', $style . '</head>', $body);
        }

        $response->setBody($body);
    }
Home | Imprint | This part of the site doesn't use cookies.