How to prevent normalization of symfony config

I have a map in my config, that I defined using scalarPrototype.

The keys are strings in format number x number eg. 12x43 or 17x27
It works fine for most cases except when first number is zero eg. 0x588
When that happens symfony reads it not as a string, but as a hex number and returns 1416 instead.

Is there a way to either tell symfony that the key is a string, or disable normalization to prevent the conversion?

Some code to show the use case:

        $treeBuilder->getRootNode()
            ->children()
                ->arrayNode('formats')
                    ->arrayPrototype()
                        ->arrayPrototype()
                            ->scalarPrototype()->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
formats:
  image:
    avatar:
      100x100: "60%"
      800x800: "90%"
    picture:
      0x800: "watermark"
      0x100: "watermark 70%"
      100x0: "watermark 70%"
      200x200: "crop watermark 70%"

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *