PEAR Manual
Prev |  | Next

# PEAR_ChannelFile::addFunction()

PEAR_ChannelFile::addFunction() -- Add a protocol to the provides section

## Synopsis

    require_once '/ChannelFile.php';

``bool PEAR_ChannelFile::addFunction` (string $type, string $version, string [$name = ''], string [$mirror = false])`

## Description

Adds a supported xml-rpc or SOAP function to a channel definition file. The type should be `xmlrpc` or `soap` in lower-cased letters. No validation is performed on insert. For example:

    <?php
    require_once 'PEAR/ChannelFile.php';
    $chan = new PEAR_ChannelFile;
    $chan->setName('foo.example.com');
    $chan->setSummary('demonstrate addFunction');
    $chan->addFunction('xmlrpc', '1.0', 'people.list');
    $chan->addFunction('oops', '1.0', 'bad.type');
    ?>

The `oops` protocol will be successfully created, but will fail upon validation.

Adding a function to a mirror simply validated to ensure that the mirror already exists.

    <?php
    require_once 'PEAR/ChannelFile.php';
    $chan = new PEAR_ChannelFile;
    $chan->setName('foo.example.com');
    $chan->setSummary('demonstrate addFunction');
    // fails: mirror not found
    $chan->addFunction('soap', '1.0', 'people.list', 'mirror.example.com');
    $chan->addMirror('mirror.example.com');
    // succeeds
    $chan->addFunction('soap', '1.0', 'people.list', 'mirror.example.com');
    ?>

## Parameter

string `$type`

  protocol type

string `$version`

  protocol version

string `$name`

  protocol name, if any

string `$mirror`

  mirror name, if this is a mirror's protocol

## Throws

throws no exceptions thrown

## Note

This function can not be called statically.

Prev | Home | Next
constructor PEAR_ChannelFile::PEAR_ChannelFile() | Up | PEAR_ChannelFile::addMirror()