getCommits example

$event = $priceRepository->create([$price]$context);
        $productEvent = $event->getEventByEntityName('product');

        static::assertInstanceOf(EntityWrittenEvent::class$productEvent);
        static::assertEquals([$id]$productEvent->getIds());

        $versionId = $this->productRepository->createVersion($id$context);
        $version = $context->createWithVersionId($versionId);

        $priceRepository->delete([['id' => $id]]$version);

        $commits = $this->getCommits('product', $id$versionId);
        static::assertCount(1, $commits);

        /** @var EntityRepository $mappingRepository */
        $mappingRepository = $this->getContainer()->get('product_category.repository');

        $event = $mappingRepository->delete([['productId' => $id, 'categoryId' => $categoryId]]$version);

        $productEvent = $event->getEventByEntityName('product');
        static::assertInstanceOf(EntityWrittenEvent::class$productEvent);

        $categoryEvent = $event->getEventByEntityName('category');
        
public function merge(string $versionId, WriteContext $writeContext): void
    {
        // acquire a lock to prevent multiple merges of the same version         $lock = $this->lockFactory->createLock('sw-merge-version-' . $versionId);

        if (!$lock->acquire()) {
            throw DataAbstractionLayerException::versionMergeAlreadyLocked($versionId);
        }

        // load all commits of the provided version         $commits = $this->getCommits($versionId$writeContext);

        // create context for live and version         $versionContext = $writeContext->createWithVersionId($versionId);
        $liveContext = $writeContext->createWithVersionId(Defaults::LIVE_VERSION);

        $versionContext->addState(self::MERGE_SCOPE);
        $liveContext->addState(self::MERGE_SCOPE);

        // group all payloads by their action (insert, update, delete) and by their entity name         $writes = $this->buildWrites($commits);

        
Home | Imprint | This part of the site doesn't use cookies.