Пример #1
0
 /**
  * Set configuration by key
  */
 public function setAction()
 {
     // check for help mode
     if ($this->requestOptions->getFlagHelp()) {
         return $this->setHelp();
     }
     // output header
     $this->consoleHeader('Setting requested configuration');
     // get needed options to shorten code
     $path = realpath($this->requestOptions->getPath());
     $configName = $this->requestOptions->getConfigName();
     $configValue = $this->requestOptions->getConfigValue();
     $configFile = $path . '/config/autoload/local.php';
     // check for config name
     if (!$configName) {
         return $this->sendError('config get <configName> was not provided');
     }
     // start output
     $this->console->write('       => Reading configuration file ');
     $this->console->writeLine($configFile, Color::GREEN);
     $this->console->write('       => Changing configuration data for key ');
     $this->console->write($configName, Color::GREEN);
     $this->console->write(' to value ');
     $this->console->writeLine($configValue, Color::GREEN);
     $this->console->write('       => Writing configuration file ');
     $this->console->writeLine($configFile, Color::GREEN);
     $this->console->writeLine();
     // check for value
     if ($configValue === 'null') {
         $configValue = null;
     }
     // write local config file
     $configData = new ModuleConfig($configFile);
     $configData->write($configName, $configValue);
     // continue output
     $this->console->write(' Done ', Color::NORMAL, Color::CYAN);
     $this->console->write(' ');
     $this->console->writeLine('Configuration data was changed.');
     // output footer
     $this->consoleFooter('requested configuration was successfully changed');
 }