factory() public method

Attempts to return a concrete Horde_SyncMl_Backend instance based on $driver.
public factory ( string $driver, array $params = null ) : Horde_SyncMl_Backend
$driver string The type of concrete Backend subclass to return. The code is dynamically included from Backend/$driver.php if no path is given or directly with "include_once $driver . '.php'" if a path is included. So make sure this parameter is "safe" and not directly taken from web input. The class in the file must be named 'Horde_SyncMl_Backend_' . basename($driver) and extend Horde_SyncMl_Backend.
$params array A hash containing any additional configuration or connection parameters a subclass might need.
return Horde_SyncMl_Backend The newly created concrete Horde_SyncMl_Backend instance, or false on an error.
Beispiel #1
0
 /**
  * Sends an RPC request to the server and returns the result.
  *
  * @param string $request  The raw request string.
  *
  * @return string  The XML encoded response from the server.
  */
 function getResponse($request)
 {
     $backendparms = array('debug_dir' => Horde::getTempDir() . '/sync', 'debug_files' => true, 'log_level' => 'DEBUG');
     /* Create the backend. */
     $GLOBALS['backend'] = Horde_SyncMl_Backend::factory('Horde', $backendparms);
     /* Handle request. */
     $h = new Horde_SyncMl_ContentHandler();
     $response = $h->process($request, $this->getResponseContentType(), Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/rpc.php', true, -1));
     /* Close the backend. */
     $GLOBALS['backend']->close();
     return $response;
 }
Beispiel #2
0
 /**
  */
 public function update(Horde_Core_Prefs_Ui $ui)
 {
     global $notification, $registry;
     $auth = $registry->getAuth();
     $backend = Horde_SyncMl_Backend::factory('Horde');
     if ($ui->vars->removedb && $ui->vars->removedevice) {
         try {
             $backend->removeAnchor($auth, $ui->vars->removedevice, $ui->vars->removedb);
             $backend->removeMaps($auth, $ui->vars->removedevice, $ui->vars->removedb);
             $notification->push(sprintf(_("Deleted synchronization session for device \"%s\" and database \"%s\"."), $ui->vars->deviceid, $ui->vars->db), 'horde.success');
         } catch (Horde_Exception $e) {
             $notification->push(_("Error deleting synchronization session:") . ' ' . $e->getMessage(), 'horde.error');
         }
     } elseif ($ui->vars->deleteall) {
         try {
             $backend->removeAnchor($auth);
             $backend->removeMaps($auth);
             $notification->push(_("All synchronization sessions deleted."), 'horde.success');
         } catch (Horde_Exception $e) {
             $notification->push(_("Error deleting synchronization sessions:") . ' ' . $e->getMessage(), 'horde.error');
         }
     }
     return false;
 }
Beispiel #3
0
/**
 * Executes one test case.
 *
 * A test cases consists of various pre-recorded .xml packets in directory
 * $name.
 */
function test($name)
{
    system($GLOBALS['this_script'] . ' --setup');
    $GLOBALS['testbackend'] = Horde_SyncMl_Backend::factory($GLOBALS['syncml_backend_driver'], $GLOBALS['syncml_backend_parms']);
    $GLOBALS['testbackend']->testStart(SYNCMLTEST_USERNAME, 'syncmltest');
    $packetNum = 10;
    $anchor = '';
    while (testsession($name, $packetNum, $anchor) === true) {
        $packetNum += 10;
    }
    /* Cleanup */
    if (!$GLOBALS['skipcleanup']) {
        $GLOBALS['testbackend']->testTearDown();
    }
    echo "testcase {$name}: passed\n";
}