[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/phpbb/console/command/config/ -> set_atomic.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  namespace phpbb\console\command\config;
  14  
  15  use Symfony\Component\Console\Input\InputArgument;
  16  use Symfony\Component\Console\Input\InputInterface;
  17  use Symfony\Component\Console\Input\InputOption;
  18  use Symfony\Component\Console\Output\OutputInterface;
  19  use Symfony\Component\Console\Style\SymfonyStyle;
  20  
  21  class set_atomic extends command
  22  {
  23      /**
  24      * {@inheritdoc}
  25      */
  26  	protected function configure()
  27      {
  28          $this
  29              ->setName('config:set-atomic')
  30              ->setDescription($this->user->lang('CLI_DESCRIPTION_SET_ATOMIC_CONFIG'))
  31              ->addArgument(
  32                  'key',
  33                  InputArgument::REQUIRED,
  34                  $this->user->lang('CLI_CONFIG_OPTION_NAME')
  35              )
  36              ->addArgument(
  37                  'old',
  38                  InputArgument::REQUIRED,
  39                  $this->user->lang('CLI_CONFIG_CURRENT')
  40              )
  41              ->addArgument(
  42                  'new',
  43                  InputArgument::REQUIRED,
  44                  $this->user->lang('CLI_CONFIG_NEW')
  45              )
  46              ->addOption(
  47                  'dynamic',
  48                  'd',
  49                  InputOption::VALUE_NONE,
  50                  $this->user->lang('CLI_CONFIG_CANNOT_CACHED')
  51              )
  52          ;
  53      }
  54  
  55      /**
  56      * Executes the command config:set-atomic.
  57      *
  58      * Sets a configuration option's value only if the old_value matches the
  59      * current configuration value or the configuration value does not exist yet.
  60      *
  61      * @param InputInterface  $input  An InputInterface instance
  62      * @param OutputInterface $output An OutputInterface instance
  63      *
  64      * @return bool True if the value was changed, false otherwise.
  65      * @see \phpbb\config\config::set_atomic()
  66      */
  67  	protected function execute(InputInterface $input, OutputInterface $output)
  68      {
  69          $io = new SymfonyStyle($input, $output);
  70  
  71          $key = $input->getArgument('key');
  72          $old_value = $input->getArgument('old');
  73          $new_value = $input->getArgument('new');
  74          $use_cache = !$input->getOption('dynamic');
  75  
  76          if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache))
  77          {
  78              $io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
  79              return 0;
  80          }
  81          else
  82          {
  83              $io->error($this->user->lang('CLI_CONFIG_SET_FAILURE', $key));
  84              return 1;
  85          }
  86      }
  87  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1