Permalink
Browse files

force the backend to inherit operation class

- Now each backend have to define an operation class like repository case
because the name of the class is declared on the backend class, and now base
account class is abstract.
  • Loading branch information...
marvil07 committed Jul 28, 2009
1 parent 8701a65 commit b83beff68bd4080c508cec64da758aa3687dda45
Showing with 14 additions and 10 deletions.
  1. +10 −10 includes/VersioncontrolOperation.php
  2. +4 −0 tests/versioncontrol_test.module
@@ -23,7 +23,7 @@
* Stuff that happened in a repository at a specific time
*
*/
-class VersioncontrolOperation implements ArrayAccess {
+abstract class VersioncontrolOperation implements ArrayAccess {
// Attributes
/**
* db identifier (before vc_op_id)
@@ -313,14 +313,9 @@ public static function getOperations($constraints = array(), $options = array())
$repo_ids[] = $row->repo_id;
}
- // Construct the operation array - nearly done already.
- $operations[$row->vc_op_id] = new VersioncontrolOperation($row->type,
- $row->committer, $row->date, $row->revision, $row->message,
- $row->author, NULL, $row->vc_op_id);
+ // Construct an operation array - nearly done already.
// 'repo_id' is replaced by 'repository' further down
- $operations[$row->vc_op_id]->repo_id = $row->repo_id;
- $operations[$row->vc_op_id]->labels = array();
- $operations[$row->vc_op_id]->uid = $row->uid;
+ $operations[$row->vc_op_id] = $row;
$op_ids[] = $row->vc_op_id;
$op_id_placeholders[] = '%d';
}
@@ -331,8 +326,13 @@ public static function getOperations($constraints = array(), $options = array())
// Add the corresponding repository array to each operation.
$repositories = VersioncontrolRepositoryCache::getInstance()->getRepositories(array('repo_ids' => $repo_ids));
foreach ($operations as $vc_op_id => $operation) {
- $operations[$vc_op_id]->repository = $repositories[$operation->repo_id];
- unset($operations[$vc_op_id]->repo_id);
+ $repo = $repositories[$operation->repo_id];
+ $operationObj = new $repo->backend->classes['operation']($operation->type,
+ $operation->committer, $operation->date, $operation->revision, $operation->message,
+ $operation->author, $repo, $operation->vc_op_id);
+ $operationObj->labels = array();
+ $operationObj->uid = $operation->uid;
+ $operations[$operation->vc_op_id] = $operationObj;
}
// Add the corresponding labels to each operation.
@@ -31,6 +31,7 @@ class VersioncontrolTestBackend extends VersioncontrolBackend {
$this->classes = array(
'repo' => 'VersioncontrolTestRepository',
'account' => 'VersioncontrolTestAccount',
+ 'operation' => 'VersioncontrolTestOperation',
);
}
}
@@ -40,3 +41,6 @@ class VersioncontrolTestRepository extends VersioncontrolRepository {
class VersioncontrolTestAccount extends VersioncontrolAccount {
}
+
+class VersioncontrolTestOperation extends VersioncontrolOperation {
+}

0 comments on commit b83beff

Please sign in to comment.