N98\Magento\Command\Developer\Log\DbCommand::_replaceVariable PHP Method

_replaceVariable() protected method

protected _replaceVariable ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output, string $variable ) : void
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
$variable string
return void
    protected function _replaceVariable($input, $output, $variable)
    {
        $varienAdapterPhpFile = $this->_getVarienAdapterPhpFile();
        $contents = file_get_contents($varienAdapterPhpFile);
        $debugLinePattern = "/protected\\s" . '\\' . $variable . "\\s*?=\\s(false|true)/m";
        preg_match($debugLinePattern, $contents, $matches);
        if (!isset($matches[1])) {
            throw new RuntimeException("Problem finding the \$_debug parameter");
        }
        $currentValue = $matches[1];
        if ($input->getOption('off')) {
            $newValue = 'false';
        } elseif ($input->getOption('on')) {
            $newValue = 'true';
        } else {
            $newValue = $currentValue == 'false' ? 'true' : 'false';
        }
        $output->writeln("<info>Changed <comment>" . $variable . "</comment> to <comment>" . $newValue . "</comment></info>");
        $contents = preg_replace($debugLinePattern, "protected " . $variable . " = " . $newValue, $contents);
        file_put_contents($varienAdapterPhpFile, $contents);
    }