Пример #1
0
 /**
  * @param Log $childLog
  */
 public function setChildLog(Log $childLog = null)
 {
     $this->childLog = $childLog;
     if ($childLog == null) {
         $this->setChildClass(null);
         $this->setChildId(null);
         $this->setLoggedAt();
     } else {
         $this->setChildClass($childLog->getObjectClass());
         $this->setChildId($childLog->getObjectId());
         $this->loggedAt = $childLog->getLoggedAt();
     }
 }
 /**
  * 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) {
         throw new \Exception('use softdeleteable Filter');
     }
     $this->_em->getFilters()->disable('softdeleteable');
     $entity = $this->_em->find($log->getObjectClass(), $log->getObjectId());
     $this->_em->getFilters()->enable('softdeleteable');
     $wrapped = new EntityWrapper($entity, $this->_em);
     $this->revertBy($log->getObjectId(), $log->getObjectClass(), $log->getVersion(), $wrapped, $softconfig['fieldName'], $deleteHistory, $logRevert);
     return $wrapped->getObject();
 }
 /**
  * @param LoggableAdapter $ea
  * @param Log             $logEntry
  * @param                 $object
  * @param                 $message
  * @return LogParent
  */
 protected function addLogParent(LoggableAdapter $ea, Log $logEntry, $object, $message, $childObject, $fieldName)
 {
     $om = $ea->getObjectManager();
     $parentLogEntry = new LogParent();
     $parentLogEntry->setAction($message);
     $parentLogEntry->setUsername($this->username);
     $parentLogEntry->setSourceUsername($this->sourceUsername);
     $wrappedParent = AbstractWrapper::wrap($object, $om);
     $parentLogEntry->setObjectClass($wrappedParent->getMetadata()->name);
     $parentLogEntry->setObjectId($wrappedParent->getIdentifier());
     $parentLogEntry->setFieldName($fieldName);
     $logEntry->addParent($parentLogEntry);
     $this->pendingParents[spl_object_hash($object)][] = array('log' => $parentLogEntry, 'field' => 'objectId');
     $this->pendingParents[spl_object_hash($childObject)][] = array('log' => $parentLogEntry, 'field' => 'childId');
     return $parentLogEntry;
 }