encodeData example

Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0', '\Shopware\Core\Framework\App\Flow\Action\AppFlowActionProvider')
        );

        $context = $flow->getContext();

        $appFlowActionData = $this->getAppFlowActionData($appFlowActionId);

        if (empty($appFlowActionData)) {
            return [];
        }

        $additionData = $this->businessEventEncoder->encodeData($flow->data()$flow->stored());
        $data = [...$flow->getConfig(), ...$additionData];

        $configData = $this->resolveParamsData($flow->getConfig()$data$context$appFlowActionId);
        /** @var array<string, mixed> $data */
        $data = [...$configData, ...$additionData];

        /** @var string $parameterData */
        $parameterData = $appFlowActionData['parameters'];
        /** @var array<string, string> $parameters */
        $parameters = array_column(json_decode($parameterData, true, 512, \JSON_THROW_ON_ERROR), 'value', 'name');

        

    public function getWebhookPayloadAndHeaders(StorableFlow $flow, string $appFlowActionId): array
    {
        $context = $flow->getContext();

        $appFlowActionData = $this->getAppFlowActionData($appFlowActionId);

        if (empty($appFlowActionData)) {
            return [];
        }

        $additionData = $this->businessEventEncoder->encodeData($flow->data()$flow->stored());
        $data = [...$flow->getConfig(), ...$additionData];

        $configData = $this->resolveParamsData($flow->getConfig()$data$context$appFlowActionId);
        /** @var array<string, mixed> $data */
        $data = [...$configData, ...$additionData];

        /** @var string $parameterData */
        $parameterData = $appFlowActionData['parameters'];
        /** @var array<string, string> $parameters */
        $parameters = array_column(json_decode($parameterData, true, 512, \JSON_THROW_ON_ERROR), 'value', 'name');

        
$result = new JsonApiEncodingResult($baseUrl);

        if (!$data instanceof EntityCollection && !$data instanceof Entity) {
            throw new UnsupportedEncoderInputException();
        }

        $result->setSingleResult($data instanceof Entity);
        $result->setMetaData($metaData);

        $fields = new ResponseFields($criteria->getIncludes());

        $this->encodeData($fields$definition$data$result);

        return $this->formatToJson($result);
    }

    protected function serializeEntity(ResponseFields $fields, Entity $entity, EntityDefinition $definition, JsonApiEncodingResult $result, bool $isRelationship = false): void
    {
        if ($result->containsInData($entity->getUniqueIdentifier()$definition->getEntityName())
            || ($isRelationship && $result->containsInIncluded($entity->getUniqueIdentifier()$definition->getEntityName()))
        ) {
            return;
        }

        
'mail' => [
                'recipients' => ['firstName' => 'name'],
            ],
            'array' => ['test'],
            'string' => 'test',
        ];

        $entityEncoder = $this->createMock(JsonEntityEncoder::class);
        $definitionRegistry = $this->createMock(DefinitionInstanceRegistry::class);
        $businessEventEncoder = new BusinessEventEncoder($entityEncoder$definitionRegistry);

        $data = $businessEventEncoder->encodeData($data$stored);

        static::assertIsArray($data['tax']);
        static::assertIsArray($data['mail']);
        static::assertIsArray($data['array']);
        static::assertIsString($data['string']);
    }
}
Home | Imprint | This part of the site doesn't use cookies.