EntityDeletedEvent example

$primaryKey = \count($primaryKeys) === 1 ? current($primaryKeys) : $primaryKeys;

            $writeResults[] = new EntityWriteResult(
                empty($primaryKey) ? Uuid::randomHex() : $primaryKey,
                $payload,
                $this->getDummyEntityName(),
                $operation
            );
        }

        if ($operation === EntityWriteResult::OPERATION_DELETE) {
            $event = new EntityDeletedEvent($this->getDummyEntityName()$writeResults$context);
        } else {
            $event = new EntityWrittenEvent($this->getDummyEntityName()$writeResults$context);
        }

        return new NestedEventCollection([$event]);
    }

    /** * @param mixed[] $payload * * @return mixed[] */
$primaryKey = \count($primaryKeys) === 1 ? current($primaryKeys) : $primaryKeys;

            $writeResults[] = new EntityWriteResult(
                empty($primaryKey) ? Uuid::randomHex() : $primaryKey,
                $payload,
                $this->getDummyEntityName(),
                $operation
            );
        }

        if ($operation === EntityWriteResult::OPERATION_DELETE) {
            $event = new EntityDeletedEvent($this->getDummyEntityName()$writeResults$context);
        } else {
            $event = new EntityWrittenEvent($this->getDummyEntityName()$writeResults$context);
        }

        return new NestedEventCollection([$event]);
    }

    /** * @param mixed[] $payload * * @return mixed[] */
$this->productReviewSubscriber->detectChangeset($event);

        foreach ($event->getCommands() as $command) {
            static::assertInstanceOf(ChangeSetAware::class$command);
            static::assertFalse($command->requiresChangeSet());
        }
    }

    public function testOnReviewDeleted(): void
    {
        $event = new EntityDeletedEvent(
            ProductReviewDefinition::ENTITY_NAME,
            [
                new EntityWriteResult(
                    'id',
                    ['id' => 'id'],
                    ProductReviewDefinition::ENTITY_NAME,
                    EntityWriteResult::OPERATION_DELETE,
                    new EntityExistence(ProductReviewDefinition::ENTITY_NAME, ['id' => 'id'], true, false, false, []),
                    new ChangeSet(['customer_id' => 'customer_id'][], true)
                ),
                // should not trigger update as it has empty changeset
Home | Imprint | This part of the site doesn't use cookies.