示例#1
0
        }
    }
}
$console->addCommands(array(new Create()));
if (!$console->isInitialized()) {
    return;
}
// $console
// ->register('site:update')
// ->setDescription('Provides one command that performs updading all the packages, running migrations and re-linking all the files')
// ->setDefinition(array())
// ->setCode(function (InputInterface $input, OutputInterface $output) use ($console) {
// });
$console->register('site:configuration')->setDescription('Provides the ability to set some of the site configuration through command line')->setDefinition(array(new InputOption('session-handler', '', InputOption::VALUE_REQUIRED, 'What session handler use'), new InputOption('cache-handler', '', InputOption::VALUE_REQUIRED, 'What cache handler use'), new InputOption('use-apc', '', InputOption::VALUE_NONE, 'If set then both cache handler and session handle will use apc'), new InputOption('offline', '', InputOption::VALUE_REQUIRED, 'set a site offline or online'), new InputOption('enable-debug', '', InputOption::VALUE_NONE, 'Turn on the debug'), new InputOption('disable-debug', '', InputOption::VALUE_NONE, 'Turn off the debug'), new InputOption('new-secret', '', InputOption::VALUE_NONE, 'Generates a new secret'), new InputOption('url-rewrite', '', InputOption::VALUE_REQUIRED, 'Enable or disable url rewrite'), new InputOption('set-value', 's', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Setting key value pair', array())))->setCode(function (InputInterface $input, OutputInterface $output) use($console) {
    $config = new Config(WWW_ROOT);
    if (!$config->isConfigured()) {
        $output->writeLn("<error>You need to initialize the site first by typing php anahita.php site:init</error>");
        exit(1);
    }
    $set = function ($name) use($console, $config, $input) {
        $args = func_get_args();
        foreach ($args as $arg) {
            $value = $input->getOption($arg);
            if (strlen($value) > 0) {
                $arg = str_replace('-', '_', $arg);
                $config->{$arg} = $value;
            }
        }
    };
    $set('session-handler', 'cache-handler', 'offline', 'url-rewrite');
    if ($input->getOption('use-apc')) {