cvs: pear-core /PEAR/Command Config.php

From: Date: Thu, 02 Mar 2006 13:32:38 +0000
Subject: cvs: pear-core /PEAR/Command Config.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-4586@lists.php.net to get a copy of this message
pajoye Thu Mar 2 13:32:38 2006 UTC Modified files: /pear-core/PEAR/Command Config.php Log: - simplify doConfigGet, and silent notices http://cvs.php.net/viewcvs.cgi/pear-core/PEAR/Command/Config.php?r1=1.50&r2=1.51&diff_format=u Index: pear-core/PEAR/Command/Config.php diff -u pear-core/PEAR/Command/Config.php:1.50 pear-core/PEAR/Command/Config.php:1.51 --- pear-core/PEAR/Command/Config.php:1.50 Thu Mar 2 13:16:19 2006 +++ pear-core/PEAR/Command/Config.php Thu Mar 2 13:32:38 2006 @@ -16,7 +16,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Config.php,v 1.50 2006/03/02 13:16:19 pajoye Exp $ + * @version CVS: $Id: Config.php,v 1.51 2006/03/02 13:32:38 pajoye Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 */ @@ -190,7 +190,7 @@ foreach ($this->config->getLayers() as $layer) { $data['data']['Config Files'][] = array(ucfirst($layer) . ' Configuration File', 'Filename' , $this->config->getConfFile($layer)); } - + $this->ui->outputData($data, $command); return true; } @@ -200,27 +200,38 @@ function doConfigGet($command, $options, $params) { - // $params[0] -> the parameter - // $params[1] -> the layer - if ($error = $this->_checkLayer(@$params[1])) { - return $this->raiseError("config-get:$error"); + if (!is_array($params)) { + $args_cnt = 0; + } else { + $args_cnt = count($params); } - $channel = isset($options['channel']) ? $options['channel'] : - $this->config->get('default_channel'); + + switch ($args_cnt) { + case 1: + $config_key = $params[0]; + $layer = NULL; + break; + case 2: + $config_key = $params[0]; + $layer = $params[1]; + if ($error = $this->_checkLayer($layer)) { + return $this->raiseError("config-get:$error"); + } + break; + case 0: + default: + return $this->raiseError("config-get expects 1 or 2 parameters"); + } + + $channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel'); $reg = &$this->config->getRegistry(); + if (!$reg->channelExists($channel)) { return $this->raiseError('Channel "' . $channel . '" does not exist'); } - if (sizeof($params) < 1 || sizeof($params) > 2) { - return $this->raiseError("config-get expects 1 or 2 parameters"); - } else { - if (count($params) == 1) { - $layer = null; - } else { - $layer = $params[1]; - } - $this->ui->outputData($this->config->get($params[0], $layer, $channel), $command); - } + + $this->ui->outputData($this->config->get($config_key, $layer, $channel), $command); + return true; } @@ -378,7 +389,7 @@ array(ucfirst($layer) . ' Configuration File', 'Filename' , $config->getConfFile($layer)); } - + $this->ui->outputData($data, 'config-show'); return true; }

« previous php.pear.core (#4586) next »