$codeEntries =
$this->
prepareCodeEntities($promotionId,
$newCodes);
$this->individualCodesRepository->
upsert($codeEntries,
$context);
} /**
* @throws PatternAlreadyInUseException
*/
public function replaceIndividualCodes(string
$promotionId, string
$pattern, int
$amount, Context
$context): void
{ if ($this->
isCodePatternAlreadyInUse($pattern,
$promotionId,
$context)) { throw PromotionException::
patternAlreadyInUse();
} $codes =
$this->
generateIndividualCodes($pattern,
$amount);
$codeEntries =
$this->
prepareCodeEntities($promotionId,
$codes);
$this->
resetPromotionCodes($promotionId,
$context);
$this->individualCodesRepository->
upsert($codeEntries,
$context);
}