VariantListingConfig example


class VariantListingConfigTest extends TestCase
{
    public function testInstantiate(): void
    {
        $displayParent = true;
        $mainVariantId = '1';
        $configuratorGroupConfig = ['key' => 'value'];

        $variantListingConfig = new VariantListingConfig($displayParent$mainVariantId$configuratorGroupConfig);

        static::assertSame($displayParent$variantListingConfig->getDisplayParent());
        static::assertSame($mainVariantId$variantListingConfig->getMainVariantId());
        static::assertSame($configuratorGroupConfig$variantListingConfig->getConfiguratorGroupConfig());
    }
}
public function decode(Field $field, mixed $value): ?VariantListingConfig
    {
        if ($value === null) {
            return null;
        }

        if (\is_string($value)) {
            $value = json_decode($value, true, 512, \JSON_THROW_ON_ERROR);
        }

        return new VariantListingConfig(
            isset($value['displayParent']) ? (bool) $value['displayParent'] : null,
            $value['mainVariantId'] ?? null,
            $value['configuratorGroupConfig'] ?? null,
        );
    }

    protected function getConstraints(Field $field): array
    {
        return [
            new Collection([
                'allowExtraFields' => true,
                
Home | Imprint | This part of the site doesn't use cookies.