private function getConfigDumpRightDirectory($baseDir)
    {
        $configDumpDir = $this->app->getBaseRepository();
        if ($this->persistPerContext && ApplicationInterface::DEFAULT_CONTEXT !== $this->app->getContext()) {
            $configDumpDir .= DIRECTORY_SEPARATOR.$this->app->getContext();
        }

        $configDumpDir .= DIRECTORY_SEPARATOR.'Config';
        if ($this->persistPerEnvironment && ApplicationInterface::DEFAULT_ENVIRONMENT !== $this->app->getEnvironment()) {
            $configDumpDir .= DIRECTORY_SEPARATOR.$this->app->getEnvironment();
        }

        $key = $this->app->getContainer()->get('bundle.loader')->getBundleIdByBaseDir($baseDir);
        if (null !== $key) {
            $configDumpDir .= DIRECTORY_SEPARATOR.'bundle'.DIRECTORY_SEPARATOR.$key;
        }

        if (!is_dir($configDumpDir) && false === @mkdir($configDumpDir, 0755, true)) {
            throw new \Exception('Unable to create config dump directory');
        }

        return $configDumpDir;
    }