protected function runLegacyKernelCallback($callback)
    {
        $this->persistenceCacheClearer->switchOff();
        $this->httpCacheClearer->switchOff();

        // Initialize legacy kernel if not already done
        if ($this->legacyKernel instanceof Closure) {
            $legacyKernelClosure = $this->legacyKernel;
            $this->legacyKernel = $legacyKernelClosure();
        }

        $return = $this->legacyKernel->runCallback(
            $callback,
            false,
            false
        );

        $this->persistenceCacheClearer->switchOn();
        $this->httpCacheClearer->switchOn();

        return $return;
    }