protected function doFlush()
    {
        // Clear Doctrine's folder.
        $result = parent::doFlush();

        if ($this->filesystem instanceof CompositeFilesystemInterface) {
            $cacheFs = $this->filesystem->getFilesystem('cache');
            // Clear our cached configuration
            if ($cacheFs->has('config-cache.json')) {
                $cacheFs->delete('config-cache.json');
            }

            // Clear our own cache folder.
            $this->flushDirectory($cacheFs->getDir('/development'));
            $this->flushDirectory($cacheFs->getDir('/exception'));
            $this->flushDirectory($cacheFs->getDir('/production'));
            $this->flushDirectory($cacheFs->getDir('/profiler'));
            $this->flushDirectory($cacheFs->getDir('/trans'));

            // Clear the thumbs folder.
            $this->flushDirectory($this->filesystem->getFilesystem('web')->getDir('/thumbs'));

            // We need to recreate our base Doctrine cache directory, as it
            // will be a subdirectory of one of the ones we just wiped.
            $this->createPathIfNeeded();
        }

        return $result;
    }