connection = $connection; $this->branch = $branch; } public function store(DbObject $object) { if ($this->branch && $this->branch->isBranch()) { $activity = BranchActivity::forDbObject($object, $this->branch); $this->connection->runFailSafeTransaction(function () use ($activity) { $activity->store($this->connection); BranchedObject::withActivity($activity, $this->connection)->store($this->connection); }); return true; } else { return $object->store($this->connection); } } public function delete(DbObject $object) { if ($this->branch && $this->branch->isBranch()) { $activity = BranchActivity::deleteObject($object, $this->branch); $this->connection->runFailSafeTransaction(function () use ($activity) { $activity->store($this->connection); BranchedObject::load( $this->connection, $activity->getObjectTable(), $activity->getObjectUuid(), $this->branch )->delete($this->connection); }); return true; } return $object->delete(); } }