getPayload example


        $criteria = new Criteria();
        $criteria->addSorting(new FieldSorting('priority', FieldSorting::DESCENDING));
        $criteria->addSorting(new FieldSorting('id'));
        $criteria->setLimit(500);
        $criteria->setTitle('cart-rule-loader::load-rules');

        $repositoryIterator = new RepositoryIterator($this->repository, $context$criteria);
        $rules = new RuleCollection();
        while (($result = $repositoryIterator->fetch()) !== null) {
            foreach ($result->getEntities() as $rule) {
                if (!$rule->isInvalid() && $rule->getPayload()) {
                    $rules->add($rule);
                }
            }
            if ($result->count() < 500) {
                break;
            }
        }

        return $rules;
    }
}
public function getUserBadgeFrom(string $accessToken): UserBadge
    {
        if (!class_exists(JWSVerifier::class) || !class_exists(Checker\HeaderCheckerManager::class)) {
            throw new \LogicException('You cannot use the "oidc" token handler since "web-token/jwt-signature" and "web-token/jwt-checker" are not installed. Try running "composer require web-token/jwt-signature web-token/jwt-checker".');
        }

        try {
            // Decode the token             $jwsVerifier = new JWSVerifier(new AlgorithmManager([$this->signatureAlgorithm]));
            $serializerManager = new JWSSerializerManager([new CompactSerializer()]);
            $jws = $serializerManager->unserialize($accessToken);
            $claims = json_decode($jws->getPayload(), true);

            // Verify the signature             if (!$jwsVerifier->verifyWithKey($jws$this->jwk, 0)) {
                throw new InvalidSignatureException();
            }

            // Verify the headers             $headerCheckerManager = new Checker\HeaderCheckerManager([
                new Checker\AlgorithmChecker([$this->signatureAlgorithm->name()]),
            ][
                new JWSTokenSupport(),
            ]);

    private function loopOperations(array $operations, Context $context): void
    {
        foreach ($operations as $operation) {
            if ($operation->getAction() === SyncOperation::ACTION_DELETE && $operation->hasCriteria()) {
                $this->handleCriteriaDelete($operation$context);

                continue;
            }

            if ($operation->getAction() === SyncOperation::ACTION_UPSERT) {
                $resolved = $this->syncFkResolver->resolve($operation->getEntity()$operation->getPayload());

                $operation->replacePayload($resolved);
            }
        }
    }

    private function handleCriteriaDelete(SyncOperation $operation, Context $context): void
    {
        $definition = $this->registry->getByEntityName($operation->getEntity());

        if (!$definition instanceof MappingEntityDefinition) {
            
/** * @deprecated tag:v6.6.0 return type will be native * * @phpstan-ignore-next-line * * @return RuleCollection */
    public function filterMatchingRules(Cart $cart, SalesChannelContext $context)
    {
        return $this->filter(
            function DRuleEntity $rule) use ($cart$context) {
                if (!$rule->getPayload() instanceof Rule) {
                    return false;
                }

                return $rule->getPayload()->match(new CartRuleScope($cart$context));
            }
        );
    }

    public function filterForContext(): self
    {
        return $this->filter(
            
/** @var EntityRepository $promotionIndividualRepository */
        $promotionIndividualRepository = $this->getContainer()->get('promotion_individual_code.repository');

        $voucherA = $this->ids->create('voucherA');

        $writtenEvent = $this->createPromotion($voucherA$voucherA$promotionRepository$salesChannelContext);
        $promotionEvent = $writtenEvent->getEventByEntityName(PromotionDefinition::ENTITY_NAME);

        static::assertNotNull($promotionEvent);
        static::assertNotEmpty($promotionEvent->getWriteResults()[0]);
        $promotionId = $promotionEvent->getWriteResults()[0]->getPayload()['id'];

        $userId = Uuid::randomHex();
        $origin = new AdminApiSource($userId);
        $origin->setIsAdmin(true);
        $context = Context::createDefaultContext($origin);

        $event = $this->createIndividualCode($promotionId, 'CODE-1', $promotionIndividualRepository$context);

        $result = $indexer->update($event);

        static::assertNull($result);
    }

        return $this->existence;
    }

    public function getPath(): string
    {
        return $this->path;
    }

    public function hasField(string $storageName): bool
    {
        return \array_key_exists($storageName$this->getPayload());
    }

    public function setFailed(bool $failed): void
    {
        $this->failed = $failed;
    }

    public function isFailed(): bool
    {
        return $this->failed;
    }
}
$this->getContainer()->get(ProductDefinition::class),
            $productId,
            Uuid::randomHex(),
            Uuid::randomHex(),
            WriteContext::createFromContext($this->context),
            new CloneBehavior()
        );

        $clonedProduct = $clonedAffected['product'][0];
        static::assertInstanceOf(EntityWriteResult::class$clonedProduct);

        $clonedProductId = $clonedProduct->getPayload()['id'];
        $clonedManyToOneId = $clonedProduct->getPayload()['manyToOneId'];
        static::assertNotEmpty($clonedProductId);
        static::assertSame($extendableId$clonedManyToOneId);
    }

    public function testContextScopeAvailableDuringMerge(): void
    {
        $ids = new IdsCollection();

        $product = (new ProductBuilder($ids, 'p1'))->price(100)->build();

        
continue;
                    }

                    if ($command instanceof JsonUpdateCommand) {
                        $executeInserts();
                        $this->executeJsonUpdate($command);

                        continue;
                    }

                    if ($definition instanceof MappingEntityDefinition && $command instanceof InsertCommand) {
                        $mappings->addInsert($definition->getEntityName()$command->getPayload());

                        continue;
                    }

                    if ($command instanceof UpdateCommand) {
                        $executeInserts();

                        RetryableQuery::retryable($this->connection, function D) use ($command$table): void {
                            $this->connection->update(
                                EntityDefinitionQueryHelper::escape($table),
                                $this->escapeColumnKeys($command->getPayload()),
                                
$deletes = [];

        foreach ($operations as $operation) {
            if (!$operation instanceof SyncOperation) {
                continue;
            }

            $this->validateSyncOperationInput($operation);

            $definition = $this->registry->getByEntityName($operation->getEntity());

            $this->validateWriteInput($operation->getPayload());

            if ($operation->getAction() === SyncOperation::ACTION_DELETE) {
                $deletes[] = $this->factory->resolveDelete($definition$operation->getPayload());

                $notFound[] = $this->extractDeleteCommands($definition$operation->getPayload()$context$commandQueue);

                continue;
            }

            if ($operation->getAction() === SyncOperation::ACTION_UPSERT) {
                $parameters = new WriteParameterBag($definition$context, '', $commandQueue);

                
'type' => $lineItem->getType(),
            'label' => $lineItem->getLabel(),
            'description' => $lineItem->getDescription(),
            'good' => $lineItem->isGood(),
            'removable' => $lineItem->isRemovable(),
            'stackable' => $lineItem->isStackable(),
            'position' => $position,
            'price' => $lineItem->getPrice(),
            'priceDefinition' => $definition,
            'parentId' => $parentId,
            'coverId' => $lineItem->getCover() ? $lineItem->getCover()->getId() : null,
            'payload' => $lineItem->getPayload(),
            'states' => $lineItem->getStates(),
        ];

        $downloads = $lineItem->getExtensionOfType(OrderConverter::ORIGINAL_DOWNLOADS, OrderLineItemDownloadCollection::class);
        if ($downloads instanceof OrderLineItemDownloadCollection) {
            $data['downloads'] = array_values($downloads->map(fn (OrderLineItemDownloadEntity $download): array => ['id' => $download->getId()]));
        }

        $output[$lineItem->getId()] = array_filter($datafn ($value) => $value !== null);

        if ($lineItem->hasChildren()) {
            
'filter' => [
                'sorterKey' => null,
                'applierKey' => null,
                'usageKey' => null,
                'pickerKey' => null,
            ],
            'exclusions' => [],
            'preventCombination' => false,
            'promotionCodeType' => 'fixed',
        ];

        static::assertEquals($expected$item->getPayload());
    }

    /** * This test verifies that we have a correct payload * including our max value from our discount, when building * a new line item for our cart. * * @group promotions * * @throws CartException * @throws UnknownPromotionDiscountTypeException */
$this->getWebhookDispatcher(false)->dispatch($event$event->getName());

        $messages = $this->bus->getMessages();
        static::assertCount(1, $messages);

        $envelop = $messages[0];
        static::assertInstanceOf(Envelope::class$envelop);
        $message = $envelop->getMessage();
        static::assertInstanceOf(WebhookEventMessage::class$message);

        $payload = $message->getPayload();
        static::assertArrayHasKey('source', $payload);
        static::assertArrayHasKey('eventId', $payload['source']);
        unset($payload['source']['eventId']);
        static::assertEquals([
            'foo' => 'bar',
            'source' => [
                'url' => 'https://example.com',
                'appVersion' => $webhookEntity->getApp()?->getVersion(),
                'shopId' => 'foobar',
                'action' => $event->getName(),
            ],
        ],

                        'type' => (new NotRule())->getName(),
                        'ruleId' => $ruleId,
                    ],
                ],
            ],
        ]$this->context);

        static::assertNotNull($this->conditionRepository->search(new Criteria([$id])$this->context)->get($id));
        /** @var RuleEntity $ruleStruct */
        $ruleStruct = $this->ruleRepository->search(new Criteria([$ruleId])$this->context)->get($ruleId);
        static::assertEquals(new AndRule([new NotRule([new NotRule()])])$ruleStruct->getPayload());
    }

    public function testUnsupportedValue(): void
    {
        try {
            $rule = new NotRule();
            $salesChannelContext = $this->createMock(SalesChannelContext::class);
            $rule->match(new CheckoutRuleScope($salesChannelContext));
            static::fail('Exception was not thrown');
        } catch (\Throwable $exception) {
            static::assertInstanceOf(UnsupportedValueException::class$exception);
        }
if ($this->fileSystem->fileExists($filePath)) {
                    $this->fileSystem->delete($filePath);
                }
            }
        }
    }

    private function productExportWritten(EntityWriteResult $writeResult): bool
    {
        return $writeResult->getEntityName() === 'product_export'
            && $writeResult->getOperation() !== EntityWriteResult::OPERATION_DELETE
            && !\array_key_exists('generatedAt', $writeResult->getPayload());
    }
}


        $this->ruleDefinition = $this->getContainer()->get(RuleDefinition::class);
    }

    public function testLoadValidRuleWithoutPayload(): void
    {
        $id = Uuid::randomHex();
        $rule = (new RuleEntity())->assign(['id' => $id, 'payload' => null, 'invalid' => false, '_uniqueIdentifier' => $id]);
        $loadedEvent = new EntityLoadedEvent($this->ruleDefinition, [$rule]$this->context);

        static::assertNull($rule->getPayload());

        $this->updater
            ->expects(static::once())
            ->method('update')
            ->with([$id])
            ->willReturn([$id => ['payload' => serialize(new AndRule()), 'invalid' => false]]);

        $this->rulePayloadSubscriber->unserialize($loadedEvent);

        static::assertNotNull($rule->getPayload());
        static::assertInstanceOf(Rule::class$rule->getPayload());
        
Home | Imprint | This part of the site doesn't use cookies.