metadataPool = $metadataPool; $this->typeResolver = $typeResolver; $this->resourceConnection = $resourceConnection; } /** * Save all operations from the list in one query. * * @param object $entity * @param array $arguments * @return object * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute($entity, $arguments = []) { $entityType = $this->typeResolver->resolve($entity); $metadata = $this->metadataPool->getMetadata($entityType); $connection = $this->resourceConnection->getConnection($metadata->getEntityConnectionName()); try { $connection->beginTransaction(); $data = []; foreach ($entity->getItems() as $operation) { $data[] = $operation->getData(); } $connection->insertOnDuplicate( $metadata->getEntityTable(), $data, [ 'status', 'error_code', 'result_message', ] ); $connection->commit(); } catch (\Exception $e) { $connection->rollBack(); throw $e; } return $entity; } }