jsonSerialize example

return $this->eventManager->filter('Legacy_Struct_Converter_Convert_Payment', $data[
            'payment' => $payment,
        ]);
    }

    /** * @return array */
    public function convertShopPageStruct(ShopPage $shopPage)
    {
        $data = $shopPage->jsonSerialize();

        $data += [
            'attributes' => $shopPage->getAttributes(),
        ];

        if ($shopPage->hasAttribute('core')) {
            $data['attribute'] = $shopPage->getAttribute('core')->jsonSerialize();
        }

        $data['children'] = $this->convertShopPageStructList($shopPage->getChildren());
        $data['parentID'] = $shopPage->getParentId();

        
unset($vars['data']);

        return array_merge($vars$this->data);
    }

    /** * @return array<string, mixed> */
    public function jsonSerialize(): array
    {
        $jsonArray = parent::jsonSerialize();

        // The key-values pairs from the property $data are now serialized in the JSON property "data". But the         // key-value pairs from data should appear in the serialization as they were properties of the ArrayEntity         // itself. Therefore the key-values moved one level up.         unset($jsonArray['data']$jsonArray['createdAt']$jsonArray['updatedAt']$jsonArray['versionId']);
        $data = $this->data;
        $this->convertDateTimePropertiesToJsonStringRepresentation($data);

        return array_merge($jsonArray$data);
    }
}

    }

    public function serialize(Config $config, Field $entity$prices): iterable
    {
        if (!$prices) {
            return;
        }

        $isoPrices = [];
        foreach ($prices as $price) {
            $price = $price instanceof Struct ? $price->jsonSerialize() : $price;
            $currencyId = $price['currencyId'];
            $currency = $this->mapToCurrencyIso($currencyId);

            if (isset($price['listPrice']) && $price['listPrice'] instanceof Struct) {
                $price['listPrice'] = $price['listPrice']->jsonSerialize();
            }

            $isoPrices[$currency] = $price;
            if ($currencyId === Defaults::CURRENCY) {
                $isoPrices['DEFAULT'] = $isoPrices[$currency];
            }
        }

function rest_is_object( $maybe_object ) {
    if ( '' === $maybe_object ) {
        return true;
    }

    if ( $maybe_object instanceof stdClass ) {
        return true;
    }

    if ( $maybe_object instanceof JsonSerializable ) {
        $maybe_object = $maybe_object->jsonSerialize();
    }

    return is_array( $maybe_object );
}

/** * Converts an object-like value to an array. * * @since 5.5.0 * * @param mixed $maybe_object The value being evaluated. * @return array Returns the object extracted from the value as an associative array. */
class HtmlEscapedTextTest extends TestCase {

  /** * @covers ::__toString * @covers ::jsonSerialize * * @dataProvider providerToString */
  public function testToString($text$expected$message) {
    $escapable_string = new HtmlEscapedText($text);
    $this->assertEquals($expected(string) $escapable_string$message);
    $this->assertEquals($expected$escapable_string->jsonSerialize());
  }

  /** * Data provider for testToString(). * * @see testToString() */
  public static function providerToString() {
    $prophet = new Prophet();

    // Checks that invalid multi-byte sequences are escaped.

class LicenseCheckTest extends TestCase
{
    public function testLicenseIsValidWithoutLicenseHost(): void
    {
        $systemConfig = $this->createMock(SystemConfigService::class);
        $systemConfig->method('get')->willReturn(null);

        $licenseCheck = new LicenseCheck($systemConfig$this->createMock(StoreClient::class));

        $validationResult = $licenseCheck->check()->jsonSerialize();

        static::assertTrue($validationResult['result']);
    }

    public function testIsValid(): void
    {
        $systemConfig = $this->createMock(SystemConfigService::class);
        $systemConfig->method('get')->willReturn('licensehost.test');

        $storeClient = $this->createMock(StoreClient::class);
        $storeClient->method('isShopUpgradeable')->willReturn(true);

        

        return $this->flows;
    }

    public function setFlows(FlowCollection $flows): void
    {
        $this->flows = $flows;
    }

    public function jsonSerialize(): array
    {
        return parent::jsonSerialize();
    }
}
$shopUrl,
            $this->shopIdProvider->getShopId(),
            $app->getVersion()
        );
    }

    /** * @return array<string, mixed> */
    public function encode(SourcedPayloadInterface $payload): array
    {
        $array = $payload->jsonSerialize();

        foreach ($array as $propertyName => $property) {
            if ($property instanceof SalesChannelContext) {
                $salesChannelContext = $property->jsonSerialize();

                foreach ($salesChannelContext as $subPropertyName => $subProperty) {
                    if (!$subProperty instanceof Entity) {
                        continue;
                    }

                    $salesChannelContext[$subPropertyName] = $this->encodeEntity($subProperty);
                }
class CountAggregationTest extends TestCase
{
    public function testEncode(): void
    {
        $aggregation = new CountAggregation('foo', 'bar');

        static::assertEquals([
            'name' => 'foo',
            'extensions' => [],
            'field' => 'bar',
            '_class' => CountAggregation::class,
        ]$aggregation->jsonSerialize());
    }

    public function testClone(): void
    {
        $aggregation = new CountAggregation('foo', 'bar');
        $clone = clone $aggregation;

        static::assertEquals('foo', $clone->getName());
        static::assertEquals('bar', $clone->getField());
        static::assertEquals($aggregation->jsonSerialize()$clone->jsonSerialize());
    }
}

class AppSyncPaymentHandlerTest extends AbstractAppPaymentHandlerTestCase
{
    public function testPay(): void
    {
        $paymentMethodId = $this->getPaymentMethodId('syncTracked');
        $orderId = $this->createOrder($paymentMethodId);
        $transactionId = $this->createTransaction($orderId$paymentMethodId);
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId);

        $response = new SyncPayResponse();
        $this->appendNewResponse($this->signResponse($response->jsonSerialize()));

        $data = new RequestDataBag(['foo' => 'bar']);
        $this->paymentService->handlePaymentByOrder($orderId$data$salesChannelContext);

        /** @var Request $request */
        $request = $this->getLastRequest();
        $body = $request->getBody()->getContents();

        $appSecret = $this->app->getAppSecret();
        static::assertNotNull($appSecret);

        
$collection->add('b');

        static::assertEquals($elements$collection->getElements());
    }

    public function testJsonSerialize(): void
    {
        $elements = ['a', 'b'];
        $collection = new TestCollection();
        static::assertEquals(
            [],
            $collection->jsonSerialize()
        );

        $collection->add('a');
        $collection->add('b');

        static::assertEquals(
            $elements,
            $collection->jsonSerialize()
        );
    }

    
$filter = new PrefixFilter('foo', 'bar');

        static::assertEquals(
            [
                'field' => 'foo',
                'value' => 'bar',
                'isPrimary' => false,
                'resolved' => null,
                'extensions' => [],
                '_class' => PrefixFilter::class,
            ],
            $filter->jsonSerialize()
        );
    }

    public function testClone(): void
    {
        $filter = new PrefixFilter('foo', 'bar');
        $clone = clone $filter;

        static::assertEquals($filter->jsonSerialize()$clone->jsonSerialize());
        static::assertEquals($filter->getField()$clone->getField());
        static::assertEquals($filter->getFields()$clone->getFields());
        
$logEntity->setRecords(0);
        $logEntity->setConfig($this->getConfig($profile$config));

        $contextSource = $context->getSource();
        $userId = $contextSource instanceof AdminApiSource ? $contextSource->getUserId() : null;
        if ($userId !== null) {
            $logEntity->setUsername($this->findUser($context$userId)->getUsername());
            $logEntity->setUserId($userId);
        }

        $context->scope(Context::SYSTEM_SCOPE, function DContext $context) use ($logEntity): void {
            $logData = array_filter($logEntity->jsonSerialize()fn ($value) => $value !== null);
            $this->logRepository->create([$logData]$context);
        });

        $logEntity->setProfile($profile);
        $logEntity->setFile($file);

        return $logEntity;
    }

    private function findUser(Context $context, string $userId): UserEntity
    {
        

        $criteria->addFilter(new EqualsFilter('active', true));
        $criteria->addFilter(new EqualsFilter('visibilities.salesChannelId', $salesChannel->getId()));
    }

    public function getMapping(Entity $product, ?SalesChannelEntity $salesChannel): SeoUrlMapping
    {
        if (!$product instanceof ProductEntity && !$product instanceof PartialEntity) {
            throw new \InvalidArgumentException('Expected ProductEntity');
        }

        $productJson = $product->jsonSerialize();

        return new SeoUrlMapping(
            $product,
            ['productId' => $product->getId()],
            [
                'product' => $productJson,
            ]
        );
    }
}

        $salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
        $criteria = (new Criteria())
            ->setIds([$this->getSalesChannelDomain()->getSalesChannelId()])
            ->addAssociation('languages');

        /** @var SalesChannelEntity $originalSalesChannel */
        $originalSalesChannel = $salesChannelRepository->search($criteria$this->context)->first();

        /** @var LanguageCollection $originalSalesChannelLanguages */
        $originalSalesChannelLanguages = $originalSalesChannel->getLanguages();
        $originalSalesChannelArray = $originalSalesChannelLanguages->jsonSerialize();
        $languages = array_map(static fn ($language) => ['id' => $language->getId()]$originalSalesChannelArray);

        $id = '000000009276457086da48d5b5628f3c';
        $data = [
            'id' => $id,
            'accessKey' => $id,
            'name' => 'A totally fake Storefront SalesChannel',
            'typeId' => Defaults::SALES_CHANNEL_TYPE_STOREFRONT,
            'customerGroupId' => TestDefaults::FALLBACK_CUSTOMER_GROUP,
            'currencyId' => Defaults::CURRENCY,
            'languages' => $languages,
            
Home | Imprint | This part of the site doesn't use cookies.