public function generate(InputInterface $input, OutputInterface $output)
    {
        $fileSystem = $this->container->get('filesystem');
        $legacyRootDir = $this->container->getParameter('ezpublish_legacy.root_dir');

        $siteAccessName = $input->getOption('site-access-name');
        $languageCode = $input->getOption('language-code');
        $siteAccessLocation = $legacyRootDir . '/settings/siteaccess/' . $siteAccessName;
        $skeletonDir = __DIR__ . '/../_templates/legacy_siteaccess';

        if ($fileSystem->exists($siteAccessLocation)) {
            if (
                !$this->questionHelper->ask(
                    $input,
                    $output,
                    new ConfirmationQuestion(
                        '<info><comment>' . $siteAccessName . '</comment> legacy siteaccess already exists. Do you want to overwrite it?</info> [<comment>no</comment>] ',
                        false
                    )
                )
            ) {
                return;
            }
        }

        $fileSystem->remove($siteAccessLocation);

        // Template variables

        $languageService = $this->container->get('ezpublish.api.repository')->getContentLanguageService();

        $relatedSiteAccessList = $this->container->getParameter('ezpublish.siteaccess.list');
        $relatedSiteAccessList[] = $siteAccessName;

        $availableLocales = array_map(
            function (Language $language) {
                return $language->languageCode;
            },
            $languageService->loadLanguages()
        );

        $availableLocales = array_values(array_diff($availableLocales, array($languageCode)));

        // Place siteaccess locale at the top of site language list
        $siteLanguageList = array_merge(array($languageCode), $availableLocales);
        $translationList = implode(';', $availableLocales);

        // Generating admin siteaccess

        $fileSystem->mirror($skeletonDir, $siteAccessLocation);

        $this->setSkeletonDirs($siteAccessLocation);

        $this->renderFile(
            'site.ini.append.php',
            $siteAccessLocation . '/site.ini.append.php',
            array(
                'relatedSiteAccessList' => $relatedSiteAccessList,
                'siteAccessLocale' => $languageCode,
                'siteLanguageList' => $siteLanguageList,
                'translationList' => $translationList,
            )
        );

        $output->writeln(
            array(
                '',
                'Generated <comment>' . $siteAccessName . '</comment> legacy siteaccess!',
                '',
            )
        );
    }