Components_Pear_Environment::addChannel PHP Method

addChannel() public method

Add a channel within the install location.
public addChannel ( string $channel, array $options = [], string $reason = '' ) : null
$channel string The channel name.
$options array Install options.
$reason string Optional reason for adding the channel.
return null
    public function addChannel($channel, $options = array(), $reason = '')
    {
        $static = $this->_channel_directory . '/' . $channel . '.channel.xml';
        if (!file_exists($static)) {
            if (empty($options['allow_remote'])) {
                throw new Components_Exception(sprintf('Cannot add channel "%s". Remote access has been disabled (activate with --allow-remote)!', $channel));
            }
            if (!empty($this->_channel_directory)) {
                $remote = new Horde_Pear_Remote($channel);
                file_put_contents($static, $remote->getChannel());
                $this->_output->warn(sprintf('Downloaded channel %s via network to %s.', $channel, $static));
            }
        }
        $channel_handler = new PEAR_Command_Channels(new PEAR_Frontend_CLI(), $this->getPearConfig());
        $this->_output->ok(sprintf('About to add channel %s%s', $channel, $reason));
        if (file_exists($static)) {
            ob_start();
            Components_Exception_Pear::catchError($channel_handler->doAdd('channel-add', array(), array($static)));
            $this->_output->pear(ob_get_clean());
        } else {
            $this->_output->warn(sprintf('Adding channel %s via network.', $channel));
            ob_start();
            Components_Exception_Pear::catchError($channel_handler->doDiscover('channel-discover', array(), array($channel)));
            $this->_output->pear(ob_get_clean());
        }
        $this->_output->ok(sprintf('Successfully added channel %s%s', $channel, $reason));
    }