Bolt\Asset\Snippet\Queue::process PHP Method

process() public method

public process ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response
    public function process(Request $request, Response $response)
    {
        // First, gather all html <!-- comments -->, because they shouldn't be
        // considered for replacements. We use a callback, so we can fill our
        // $this->matchedComments array
        preg_replace_callback('/<!--(.*)-->/Uis', [$this, 'pregCallback'], $response->getContent());
        /** @var Snippet $asset */
        foreach ($this->queue as $key => $asset) {
            if ($asset->getZone() === Zone::get($request)) {
                $this->injector->inject($asset, $asset->getLocation(), $response);
            }
            unset($this->queue[$key]);
        }
        // Conditionally add jQuery
        $this->addJquery($request, $response);
        // Finally, replace back ###comment### with its original comment.
        if (!empty($this->matchedComments)) {
            $html = preg_replace(array_keys($this->matchedComments), $this->matchedComments, $response->getContent(), 1);
            $response->setContent($html);
        }
    }