PEAR_Config::setChannels PHP Method

setChannels() public method

This should be set via a call to {@link PEAR_Registry::listChannels()}
public setChannels ( $channels, $merge = false ) : boolean
return boolean success of operation
    function setChannels($channels, $merge = false)
    {
        if (!is_array($channels)) {
            return false;
        }
        if ($merge) {
            $this->_channels = array_merge($this->_channels, $channels);
        } else {
            $this->_channels = $channels;
        }
        foreach ($channels as $channel) {
            $channel = strtolower($channel);
            if ($channel == 'pear.php.net') {
                continue;
            }
            foreach ($this->layers as $layer) {
                if (!isset($this->configuration[$layer]['__channels'])) {
                    $this->configuration[$layer]['__channels'] = array();
                }
                if (!isset($this->configuration[$layer]['__channels'][$channel]) || !is_array($this->configuration[$layer]['__channels'][$channel])) {
                    $this->configuration[$layer]['__channels'][$channel] = array();
                }
            }
        }
        return true;
    }

Usage Example

コード例 #1
0
ファイル: Registry.php プロジェクト: adisonc/MaineLearning
 /**
  * @param PEAR_ChannelFile Channel object
  * @param string Last-Modified header from HTTP for caching
  * @return boolean|PEAR_Error True on creation, false if it already exists
  */
 function addChannel($channel, $lastmodified = false, $update = false)
 {
     if (!is_a($channel, 'PEAR_ChannelFile') || !$channel->validate()) {
         return false;
     }
     if (PEAR::isError($e = $this->_lock(LOCK_EX))) {
         return $e;
     }
     $ret = $this->_addChannel($channel, $update, $lastmodified);
     $this->_unlock();
     if (!$update && $ret && is_a($this->_config, 'PEAR_Config')) {
         $this->_config->setChannels($this->listChannels());
     }
     return $ret;
 }
All Usage Examples Of PEAR_Config::setChannels