/** * @param ContextInterface $firstContext * @param ContextInterface $context */ public static function mergeContextCounters(ContextInterface $firstContext, ContextInterface $context) { $firstContext->incrementReadCount($context->getReadCount()); $firstContext->incrementAddCount($context->getAddCount()); $firstContext->incrementUpdateCount($context->getUpdateCount()); $firstContext->incrementReplaceCount($context->getReplaceCount()); $firstContext->incrementDeleteCount($context->getDeleteCount()); $firstContext->incrementErrorEntriesCount($context->getErrorEntriesCount()); }
/** * @param object $entity * * @return null|object */ protected function validateAndUpdateContext($entity) { // validate entity $validationErrors = $this->strategyHelper->validateEntity($entity); if ($validationErrors) { $this->context->incrementErrorEntriesCount(); $errorPrefix = ValidationUtils::guessValidationMessagePrefix($entity); $this->strategyHelper->addValidationErrors($validationErrors, $this->context, $errorPrefix); return null; } // increment context counter if ($entity->getId()) { $this->context->incrementUpdateCount(); } else { $this->context->incrementAddCount(); } return $entity; }