Skip to content

Commit

Permalink
add additional options to revertTo
Browse files Browse the repository at this point in the history
  • Loading branch information
Gladhon committed Jul 16, 2015
1 parent 6a9a037 commit 945e68c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Repository/LogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,18 @@ protected function revertObjectBySingleLog(Log $log, EntityWrapper $wrapped)
return true;
}

public function revertTo(Log $log)
/**
* Revert a Entity identified by specific $log
* @param Log $log
* @param bool $deleteHistory if true, the revert will also delete all log entries since the reverted one
* @param bool $logRevert if logRevert is true, the revert will be logged
* @return object
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
* @throws \Exception
*/
public function revertTo(Log $log, $deleteHistory = true, $logRevert = false)
{
$softconfig = $this->getSoftDeletableListener()->getConfiguration($this->_em, $log->getObjectClass());
if (sizeof($softconfig) == 0) {
Expand All @@ -219,7 +230,7 @@ public function revertTo(Log $log)
$this->_em->getFilters()->enable('softdeleteable');

$wrapped = new EntityWrapper($entity, $this->_em);
$this->revertBy($log->getObjectId(), $log->getObjectClass(), $log->getVersion(), $wrapped, $softconfig['fieldName']);
$this->revertBy($log->getObjectId(), $log->getObjectClass(), $log->getVersion(), $wrapped, $softconfig['fieldName'],$deleteHistory,$logRevert);


return $wrapped->getObject();
Expand Down

0 comments on commit 945e68c

Please sign in to comment.