Skip to content

Commit

Permalink
starting with backend class
Browse files Browse the repository at this point in the history
  • Loading branch information
marvil07 committed Jul 19, 2009
1 parent aded0c9 commit 17d07b2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 35 deletions.
77 changes: 47 additions & 30 deletions includes/VersioncontrolBackend.php
Expand Up @@ -6,38 +6,55 @@
*
* @abstract
*/
abstract class VersioncontrolBackend {
// Attributes
/**
* simple name
*
* @var string
*/
public $name;
abstract class VersioncontrolBackend implements ArrayAccess {
// Attributes
/**
* simple name
*
* @var string
*/
public $name;

/**
* simple description
*
* @var string
*/
public $description;
/**
* simple description
*
* @var string
*/
public $description;

/**
* what the backend can do, probably deprecated after interfaces approach
*
* @var array
*/
public $capabilities;
/**
* what the backend can do, probably deprecated after interfaces approach
*
* @var array
*/
public $capabilities;

/**
* XXX
*
* @var array
*/
public $flags;
/**
* XXX
*
* @var array
*/
public $flags;

// Associations
// Operations
}
// Operations
public function __construct($name, $description, $capabilities=array(), $flags=array()) {
$this->name = $name;
$this->description = $description;
$this->capabilities = $capabilities;
$this->flags = $flags;
}

?>
//ArrayAccess interface implementation
public function offsetExists($offset) {
return isset($this->$offset);
}
public function offsetGet($offset) {
return $this->$offset;
}
public function offsetSet($offset, $value) {
$this->$offset = $value;
}
public function offsetUnset($offset) {
unset($this->$offset);
}
}
13 changes: 8 additions & 5 deletions tests/versioncontrol_test.module
Expand Up @@ -6,16 +6,19 @@
* Helper for testing Version Control core
*/

require_once drupal_get_path('module', 'versioncontrol') . '/includes/VersioncontrolBackend.php';

/**
* Implementation of hook_versioncontrol_backends().
*/
function versioncontrol_test_versioncontrol_backends() {
return array(
'test' => array(
'name' => 'TestVCS',
'description' => t('TestVCS backend for Version Control API.'),
'capabilities' => array(),
'flags' => array(),
'test' => new VersioncontrolTestBackend(
'TestVCS',
t('TestVCS backend for Version Control API.')
),
);
}

class VersioncontrolTestBackend extends VersioncontrolBackend {
}
1 change: 1 addition & 0 deletions versioncontrol.module
Expand Up @@ -444,6 +444,7 @@ function versioncontrol_user_accounts_load($uid, $include_unauthorized = FALSE)
*
* A real-life example of such a result array can be found
* in the FakeVCS example module.
* TODO make me static on VersioncontrolBackend
*/
function versioncontrol_get_backends() {
static $backends;
Expand Down

0 comments on commit 17d07b2

Please sign in to comment.