vendor/endroid/qr-code-bundle/src/DependencyInjection/Configuration.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * (c) Jeroen van den Enden <info@endroid.nl>
  5.  *
  6.  * This source file is subject to the MIT license that is bundled
  7.  * with this source code in the file LICENSE.
  8.  */
  9. namespace Endroid\QrCodeBundle\DependencyInjection;
  10. use Endroid\QrCode\ErrorCorrectionLevel;
  11. use Endroid\QrCode\LabelAlignment;
  12. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  13. use Symfony\Component\Config\Definition\ConfigurationInterface;
  14. class Configuration implements ConfigurationInterface
  15. {
  16.     /** @psalm-suppress PossiblyUndefinedMethod */
  17.     public function getConfigTreeBuilder(): TreeBuilder
  18.     {
  19.         $treeBuilder = new TreeBuilder('endroid_qr_code');
  20.         if (method_exists($treeBuilder'root')) {
  21.             $rootNode $treeBuilder->root('endroid_qr_code');
  22.         } else {
  23.             $rootNode $treeBuilder->getRootNode();
  24.         }
  25.         $rootNode
  26.             ->children()
  27.                 ->scalarNode('writer')->defaultValue('png')->end()
  28.                 ->arrayNode('writer_options')
  29.                     ->prototype('scalar')->end()
  30.                 ->end()
  31.                 ->integerNode('size')->min(0)->end()
  32.                 ->integerNode('margin')->min(0)->end()
  33.                 ->scalarNode('encoding')->defaultValue('UTF-8')->end()
  34.                 ->scalarNode('error_correction_level')
  35.                     ->validate()
  36.                         ->ifNotInArray(ErrorCorrectionLevel::toArray())
  37.                         ->thenInvalid('Invalid error correction level %s')
  38.                     ->end()
  39.                 ->end()
  40.                 ->arrayNode('foreground_color')
  41.                     ->children()
  42.                         ->scalarNode('r')->isRequired()->end()
  43.                         ->scalarNode('g')->isRequired()->end()
  44.                         ->scalarNode('b')->isRequired()->end()
  45.                         ->scalarNode('a')->defaultValue(0)->end()
  46.                     ->end()
  47.                 ->end()
  48.                 ->arrayNode('background_color')
  49.                     ->children()
  50.                         ->scalarNode('r')->isRequired()->end()
  51.                         ->scalarNode('g')->isRequired()->end()
  52.                         ->scalarNode('b')->isRequired()->end()
  53.                         ->scalarNode('a')->defaultValue(0)->end()
  54.                     ->end()
  55.                 ->end()
  56.                 ->scalarNode('logo_path')->end()
  57.                 ->integerNode('logo_width')->end()
  58.                 ->integerNode('logo_height')->end()
  59.                 ->scalarNode('label')->end()
  60.                 ->integerNode('label_font_size')->end()
  61.                 ->scalarNode('label_font_path')->end()
  62.                 ->scalarNode('label_alignment')
  63.                     ->validate()
  64.                         ->ifNotInArray(LabelAlignment::toArray())
  65.                         ->thenInvalid('Invalid label alignment %s')
  66.                     ->end()
  67.                 ->end()
  68.                 ->arrayNode('label_margin')
  69.                     ->children()
  70.                         ->scalarNode('t')->end()
  71.                         ->scalarNode('r')->end()
  72.                         ->scalarNode('b')->end()
  73.                         ->scalarNode('l')->end()
  74.                     ->end()
  75.                 ->end()
  76.                 ->booleanNode('validate_result')->end()
  77.             ->end()
  78.         ;
  79.         return $treeBuilder;
  80.     }
  81. }