Skip to content

Commit

Permalink
force the backend to inherit operation class
Browse files Browse the repository at this point in the history
- 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 b83beff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions includes/VersioncontrolOperation.php
Expand Up @@ -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)
Expand Down Expand Up @@ -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';
}
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions tests/versioncontrol_test.module
Expand Up @@ -31,6 +31,7 @@ class VersioncontrolTestBackend extends VersioncontrolBackend {
$this->classes = array(
'repo' => 'VersioncontrolTestRepository',
'account' => 'VersioncontrolTestAccount',
'operation' => 'VersioncontrolTestOperation',
);
}
}
Expand All @@ -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.