vendor/symfony/config/Definition/Builder/NormalizationBuilder.php line 38

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Config\Definition\Builder;
  11. /**
  12.  * This class builds normalization conditions.
  13.  *
  14.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  15.  */
  16. class NormalizationBuilder
  17. {
  18.     protected $node;
  19.     public $before = [];
  20.     public $remappings = [];
  21.     public function __construct(NodeDefinition $node)
  22.     {
  23.         $this->node $node;
  24.     }
  25.     /**
  26.      * Registers a key to remap to its plural form.
  27.      *
  28.      * @param string      $key    The key to remap
  29.      * @param string|null $plural The plural of the key in case of irregular plural
  30.      *
  31.      * @return $this
  32.      */
  33.     public function remap(string $keystring $plural null)
  34.     {
  35.         $this->remappings[] = [$keynull === $plural $key.'s' $plural];
  36.         return $this;
  37.     }
  38.     /**
  39.      * Registers a closure to run before the normalization or an expression builder to build it if null is provided.
  40.      *
  41.      * @return ExprBuilder|$this
  42.      */
  43.     public function before(\Closure $closure null)
  44.     {
  45.         if (null !== $closure) {
  46.             $this->before[] = $closure;
  47.             return $this;
  48.         }
  49.         return $this->before[] = new ExprBuilder($this->node);
  50.     }
  51. }