/**
  * Create a new VersionControl_SVN command object.
  *
  * $switches is an array containing multiple options
  * defined by the following associative keys:
  *
  * <code>
  *
  * array(
  *  'url'           => 'Subversion repository URL',
  *  'username'      => 'Subversion repository login',
  *  'password'      => 'Subversion repository password',
  *  'config_dir'    => 'Path to a Subversion configuration directory',
  *                     // [DEFAULT: null]
  *  'dry_run'       => true/false, 
  *                     // [DEFAULT: false]
  *  'encoding'      => 'Language encoding to use for commit messages', 
  *                     // [DEFAULT: null]
  *  'svn_path'      => 'Path to the svn client binary installed as part of Subversion',
  *                     // [DEFAULT: /usr/local/bin/svn]
  * )
  *
  * </code>
  *
  * Example 1.
  * <code>
  * <?php
  * require_once 'VersionControl/SVN.php';
  *
  * $options = array(
  *      'url'        => 'https://www.example.com/repos',
  *      'path'       => 'your_project',
  *      'username'   => 'your_login',
  *      'password'   => 'your_password',
  * );
  * 
  * // Run a log command
  * $svn = VersionControl_SVN::factory('log', $options);
  *
  * print_r($svn->run());
  * ?>
  * </code>
  *
  * @param   array   $options    An associative array of option names and
  *                              their values
  *
  * @return  mixed   a newly created VersionControl_SVN command object, or PEAR_ErrorStack
  *                  constant on error
  *
  * @access  public
  */
 function &factory($command, $options = array())
 {
     $stack =& PEAR_ErrorStack::singleton('VersionControl_SVN');
     $stack->setErrorMessageTemplate(VersionControl_SVN::declareErrorMessages());
     if (is_string($command) && strtoupper($command) == '__ALL__') {
         unset($command);
         $command = array();
         $command = VersionControl_SVN::fetchCommands();
     }
     if (is_array($command)) {
         $objects = new stdClass();
         foreach ($command as $cmd) {
             $obj = VersionControl_SVN::init($cmd, $options);
             $objects->{$cmd} = $obj;
         }
         return $objects;
     } else {
         $obj = VersionControl_SVN::init($command, $options);
         return $obj;
     }
 }
Ejemplo n.º 2
0
 /**
  * Create a new VersionControl_SVN command object.
  *
  * $options is an array containing multiple options
  * defined by the following associative keys:
  *
  * <code>
  *
  * array(
  *  'username'      => 'Subversion repository login',
  *  'password'      => 'Subversion repository password',
  *  'config-dir'    => 'Path to a Subversion configuration directory',
  *                     // [DEFAULT: null]
  *  'config-option' => 'Set Subversion user configuration',
  *                     // [DEFAULT: null]
  *  'binaryPath'    => 'Path to the svn client binary installed as part of Subversion',
  *                     // [DEFAULT: /usr/local/bin/svn]
  *  'fetchmode'     => Type of returning of run function.
  *                     // [DEFAULT: VERSIONCONTROL_SVN_FETCHMODE_ASSOC]
  * )
  *
  * </code>
  *
  * Example 1.
  * <code>
  * <?php
  * require_once 'VersionControl/SVN.php';
  *
  * $options = array(
  *      'username'   => 'your_login',
  *      'password'   => 'your_password',
  * );
  * 
  * // Run a log command
  * $svn = VersionControl_SVN::factory('log', $options);
  *
  * print_r($svn->run(array('path_to_your_svn'));
  * ?>
  * </code>
  *
  * @param string $command The Subversion command
  * @param array  $options An associative array of option names and
  *                        their values
  *
  * @return mixed A newly created command object or an stdObj with the
  *               command objects set.
  * @throws VersionControl_SVN_Exception Exception if command init fails.
  */
 public static function factory($command, $options = array())
 {
     if (is_string($command) && strtoupper($command) == '__ALL__') {
         unset($command);
         $command = array();
         $command = VersionControl_SVN::fetchCommands();
     }
     if (is_array($command)) {
         $objects = new stdClass();
         foreach ($command as $cmd) {
             $obj = VersionControl_SVN::init($cmd, $options);
             $objects->{$cmd} = $obj;
         }
         return $objects;
     } else {
         $obj = VersionControl_SVN::init($command, $options);
         return $obj;
     }
 }