Пример #1
0
 private function buildParameters(EntityDTO $entity)
 {
     $params = array('entity' => $entity->getType(), 'id' => $entity->getPlainId());
     if ($entity->getVersion()) {
         $params['version'] = $entity->getVersion();
     }
     return $params;
 }
Пример #2
0
 /**
  * Compares aggregate's current version with the stored version. If thery are out os sync throws exception
  *
  * @param EntityDTO $entity 
  * @return nothing or ConflictingVersion Exception
  * @author Francisco Iglesias Gómez
  */
 protected function checkVersion(EntityDTO $entity)
 {
     $newVersion = $entity->getVersion();
     $storedVersion = $this->getStoredVersion($entity);
     if ($newVersion <= $storedVersion) {
         throw new Exception\ConflictingVersion(sprintf('Stored version for %s found to be %s, trying to save version %s', $entity, $storedVersion, $newVersion), 1);
     }
 }