Skip to content

Commit

Permalink
make operation backend interaction through inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
marvil07 committed Jul 28, 2009
1 parent db6c81d commit 8701a65
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions includes/VersioncontrolOperation.php
Expand Up @@ -547,7 +547,7 @@ public function updateLabels($labels) {
* versioncontrol_get_operations() and versioncontrol_get_operation_items().)
* In case of an error, NULL is returned instead of the operation array.
*/
public function insert(&$operation_items) {
public final function insert(&$operation_items) {
$this->_fill(TRUE);

if (!isset($this->repository)) {
Expand Down Expand Up @@ -627,11 +627,8 @@ public function insert(&$operation_items) {
}

// Notify the backend first.
if (versioncontrol_backend_implements($vcs, 'operation')) {
_versioncontrol_call_backend($vcs, 'operation', array(
'insert', $this, $operation_items
));
}
$this->_insert($operation_items);

// Everything's done, let the world know about it!
module_invoke_all('versioncontrol_operation',
'insert', $this, $operation_items
Expand Down Expand Up @@ -659,6 +656,14 @@ public function insert(&$operation_items) {
return $this;
}

/**
* Let child backend repo classes add information that _is not_ in
* VersioncontrolRepository::data without modifying general flow if
* necessary.
*/
protected function _insert($operation_items) {
}

/**
* Delete a commit, a branch operation or a tag operation from the database,
* and call the necessary hooks.
Expand All @@ -667,7 +672,7 @@ public function insert(&$operation_items) {
* The commit, branch operation or tag operation array containing
* the operation that should be deleted.
*/
public function delete() {
public final function delete() {
$operation_items = $this->getItems();

// As versioncontrol_update_operation_labels() provides an update hook for
Expand All @@ -680,14 +685,8 @@ public function delete() {
module_invoke_all('versioncontrol_operation',
'delete', $this, $operation_items);

$vcs = $this->repository->vcs;

// Provide an opportunity for the backend to delete its own stuff.
if (versioncontrol_backend_implements($vcs, 'operation')) {
_versioncontrol_call_backend($vcs, 'operation', array(
'delete', $this, $operation_items
));
}
$this->_delete($operation_items);

db_query('DELETE FROM {versioncontrol_operation_labels}
WHERE vc_op_id = %d', $this->vc_op_id);
Expand All @@ -697,6 +696,14 @@ public function delete() {
WHERE vc_op_id = %d', $this->vc_op_id);
}

/**
* Let child backend repo classes add information that _is not_ in
* VersioncontrolRepository::data without modifying general flow if
* necessary.
*/
protected function _delete($operation_items) {
}

/**
* Assemble a list of query constraints from the given @p $constraints and
* @p $tables arrays. Both of these are likely to be altered to match the
Expand Down

0 comments on commit 8701a65

Please sign in to comment.