private function buildParameters(EntityDTO $entity) { $params = array('entity' => $entity->getType(), 'id' => $entity->getPlainId()); if ($entity->getVersion()) { $params['version'] = $entity->getVersion(); } return $params; }
/** * 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); } }