<commit_before><?php

namespace N98\Magento\Command\Installer\SubCommand;

use N98\Magento\Command\SubCommand\AbstractSubCommand;

class RewriteHtaccessFile extends AbstractSubCommand
{
    /**
     * @return bool
     */
    public function execute()
    {
        if ($this->input->getOption('useDefaultConfigParams') == null
            || $this->input->getOption('replaceHtaccessFile') != null
        ) {
            $this->getCommand()->getApplication()->setAutoExit(false);
            $dialog = $this->getCommand()->getHelper('dialog');

            $args = $this->config->getArray('installation_args');

            $replaceHtaccessFile = false;

            if ($this->getCommand()->parseBoolOption($this->input->getOption('replaceHtaccessFile'))) {
                $replaceHtaccessFile = true;
            } elseif ($dialog->askConfirmation(
                $this->output,
                '<question>Write BaseURL to .htaccess file?</question> <comment>[n]</comment>: ',
                false
            )
            ) {
                $replaceHtaccessFile = true;
            }

            if ($replaceHtaccessFile) {
                $this->replaceHtaccessFile($args['base_url']);
            }
        }
    }

    /**
     * @param string $baseUrl
     */
    protected function replaceHtaccessFile($baseUrl)
    {
        $htaccessFile = $this->config->getString('installationFolder')
                      . DIRECTORY_SEPARATOR
                      . 'pub'
                      . DIRECTORY_SEPARATOR
                      . '.htaccess';

        $this->_backupOriginalFile($htaccessFile);
        $this->_replaceContent($htaccessFile, $baseUrl);
    }

    protected function _backupOriginalFile($htaccesFile)
    {
        copy(
            $htaccesFile,
            $htaccesFile . '.dist'<commit_msg>[TASK] Fixed htaccess base url<commit_after><?php

namespace N98\Magento\Command\Installer\SubCommand;

use N98\Magento\Command\SubCommand\AbstractSubCommand;

class RewriteHtaccessFile extends AbstractSubCommand
{
    /**
     * @return bool
     */
    public function execute()
    {
        if ($this->input->getOption('useDefaultConfigParams') == null
            || $this->input->getOption('replaceHtaccessFile') != null
        ) {
            $this->getCommand()->getApplication()->setAutoExit(false);
            $dialog = $this->getCommand()->getHelper('dialog');

            $args = $this->config->getArray('installation_args');

            $replaceHtaccessFile = false;

            if ($this->getCommand()->parseBoolOption($this->input->getOption('replaceHtaccessFile'))) {
                $replaceHtaccessFile = true;
            } elseif ($dialog->askConfirmation(
                $this->output,
                '<question>Write BaseURL to .htaccess file?</question> <comment>[n]</comment>: ',
                false
            )
            ) {
                $replaceHtaccessFile = true;
            }

            if ($replaceHtaccessFile) {
                $this->replaceHtaccessFile($args['base-url']);
            }
        }
    }

    /**
     * @param string $baseUrl
     */
    protected function replaceHtaccessFile($baseUrl)
    {
        $htaccessFile = $this->config->getString('installationFolder')
                      . DIRECTORY_SEPARATOR
                      . 'pub'
                      . DIRECTORY_SEPARATOR
                      . '.htaccess';

        $this->_backupOriginalFile($htaccessFile);
        $this->_replaceContent($htaccessFile, $baseUrl);
    }

    protected function _backupOriginalFile($htaccesFile)
    {
        copy(
            $htaccesFile,
            $htaccesFile . '.dist'
{'fraction_non_alphanumeric': 0.12905866302864938, 'fraction_numerical': 0.00218281036834925, 'mean_word_length': 1.9141494435612083, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1919106', 'n_tokens_mistral': 1015, 'n_tokens_neox': 976, 'n_words': 137}