1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8namespace Tiki\Command; 9 10use Symfony\Component\Console\Command\Command; 11use Symfony\Component\Console\Input\InputArgument; 12use Symfony\Component\Console\Input\InputInterface; 13use Symfony\Component\Console\Output\OutputInterface; 14use TikiLib; 15 16class PreferencesGetCommand extends Command 17{ 18 protected function configure() 19 { 20 $this 21 ->setName('preferences:get') 22 ->setDescription('Get a preference') 23 ->addArgument( 24 'name', 25 InputArgument::REQUIRED, 26 'Preference name' 27 ); 28 } 29 30 protected function execute(InputInterface $input, OutputInterface $output) 31 { 32 $preference = $input->getArgument('name'); 33 34 $tikilib = TikiLib::lib('tiki'); 35 $prefslib = TikiLib::lib('prefs'); 36 37 $preferenceInfo = $prefslib->getPreference($preference); 38 39 if (empty($preferenceInfo)) { 40 $output->write('<error>Preference not found.</error>'); 41 return; 42 } 43 44 $value = $tikilib->get_preference($preference); 45 46 if (! empty($preferenceInfo['separator']) && is_array($value)) { 47 $value = implode($preferenceInfo['separator'], $value); 48 } 49 50 $output->writeln(sprintf('Preference %s has value %s', $preference, $value)); 51 } 52} 53