[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/PEAR/ -> Command.php (sommaire)

PEAR_Command, command pattern class PHP versions 4 and 5

Author: Stig Bakken <ssb@php.net>
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: Command.php,v 1.38 2006/10/31 02:54:40 cellog Exp $
Poids: 416 lignes (13 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 3 fichiers
 PEAR/XMLParser.php
 PEAR/Frontend.php
 PEAR.php

Définit 1 class

PEAR_Command:: (11 méthodes):
  factory()
  getObject()
  getFrontendObject()
  setFrontendClass()
  setFrontendType()
  registerCommands()
  getCommands()
  getShortcuts()
  getGetoptArgs()
  getDescription()
  getHelp()


Classe: PEAR_Command  - X-Ref

PEAR command class, a simple factory class for administrative
commands.

How to implement command classes:

- The class must be called PEAR_Command_Nnn, installed in the
"PEAR/Common" subdir, with a method called getCommands() that
returns an array of the commands implemented by the class (see
PEAR/Command/Install.php for an example).

- The class must implement a run() function that is called with three
params:

(string) command name
(array)  assoc array with options, freely defined by each
command, for example:
array('force' => true)
(array)  list of the other parameters

The run() function returns a PEAR_CommandResponse object.  Use
these methods to get information:

int getStatus()   Returns PEAR_COMMAND_(SUCCESS|FAILURE|PARTIAL)
*_PARTIAL means that you need to issue at least
one more command to complete the operation
(used for example for validation steps).

string getMessage()  Returns a message for the user.  Remember,
no HTML or other interface-specific markup.

If something unexpected happens, run() returns a PEAR error.

- DON'T OUTPUT ANYTHING! Return text for output instead.

- DON'T USE HTML! The text you return will be used from both Gtk,
web and command-line interfaces, so for now, keep everything to
plain text.

- DON'T USE EXIT OR DIE! Always use pear errors.  From static
classes do PEAR::raiseError(), from other classes do
$this->raiseError().
factory($command, &$config)   X-Ref
Get the right object for executing a command.

param: string $command The name of the command
param: object $config  Instance of PEAR_Config object
return: object the command object or a PEAR error

getObject($command)   X-Ref
Pas de description

getFrontendObject()   X-Ref
Get instance of frontend object.

return: object|PEAR_Error

setFrontendClass($uiclass)   X-Ref
Load current frontend class.

param: string $uiclass Name of class implementing the frontend
return: object the frontend object, or a PEAR error

setFrontendType($uitype)   X-Ref
Set current frontend.

param: string $uitype Name of the frontend type (for example "CLI")
return: object the frontend object, or a PEAR error

registerCommands($merge = false, $dir = null)   X-Ref
Scan through the Command directory looking for classes
and see what commands they implement.

param: bool   (optional) if FALSE (default), the new list of
param: string (optional) where (what directory) to look for
return: bool TRUE on success, a PEAR error on failure

getCommands()   X-Ref
Get the list of currently supported commands, and what
classes implement them.

return: array command => implementing class

getShortcuts()   X-Ref
Get the list of command shortcuts.

return: array shortcut => command

getGetoptArgs($command, &$short_args, &$long_args)   X-Ref
Compiles arguments for getopt.

param: string $command     command to get optstring for
param: string $short_args  (reference) short getopt format
param: array  $long_args   (reference) long getopt format
return: void

getDescription($command)   X-Ref
Get description for a command.

param: string $command Name of the command
return: string command description

getHelp($command)   X-Ref
Get help for command.

param: string $command Name of the command to return help for



Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7