PostWriteValidationEvent example

static::assertEquals($ids$event->getDeletedPrimaryKeys($entity), \sprintf('Deleted primary keys for entity %s not match', $entity));
        }
    }

    public static function getDeletedPrimaryKeysProvider(): \Generator
    {
        $context = WriteContext::createFromContext(Context::createDefaultContext());

        $ids = new IdsCollection();

        yield 'Test single delete' => [
            new PostWriteValidationEvent($context[self::delete('product', ['id' => $ids->get('p1')])]),
            [
                'product' => [['id' => $ids->get('p1')]],
            ],
        ];

        yield 'Test multi insert' => [
            new PostWriteValidationEvent($context[
                self::insert('product', ['id' => $ids->get('p1')]),
                self::delete('product', ['id' => $ids->get('p2')]),
                self::delete('product', ['id' => $ids->get('p3')]),

                
$e = $innerException;
            }
            $context->getExceptions()->add($e);

            $entityDeleteEvent->error();
            Feature::ifNotActive('v6.6.0.0', fn () => $entityDeleteEventLegacy->error());

            throw $e;
        }

        // throws exception on violation and then aborts/rollbacks this transaction         $event = new PostWriteValidationEvent($context$commands);
        $this->eventDispatcher->dispatch($event);
        $context->getExceptions()->tryToThrow();
    }

    /** * @param list<array<string, string>> $pks */
    private function prefetch(EntityDefinition $definition, array $pks, WriteParameterBag $parameters): void
    {
        $pkFields = [];
        $versionField = null;
        
Home | Imprint | This part of the site doesn't use cookies.