vendor/sensio/framework-extra-bundle/src/Configuration/Entity.php line 21

  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 Sensio\Bundle\FrameworkExtraBundle\Configuration;
  11. /**
  12.  * Doctrine-specific ParamConverter with an easier syntax.
  13.  *
  14.  * @author Ryan Weaver <ryan@knpuniversity.com>
  15.  * @Annotation
  16.  */
  17. #[\Attribute(\Attribute::IS_REPEATABLE \Attribute::TARGET_CLASS \Attribute::TARGET_METHOD)]
  18. class Entity extends ParamConverter
  19. {
  20.     public function setExpr($expr)
  21.     {
  22.         $options $this->getOptions();
  23.         $options['expr'] = $expr;
  24.         $this->setOptions($options);
  25.     }
  26.     /**
  27.      * @param array|string $data
  28.      */
  29.     public function __construct(
  30.         $data = [],
  31.         string $expr null,
  32.         string $class null,
  33.         array $options = [],
  34.         bool $isOptional false,
  35.         string $converter null
  36.     ) {
  37.         $values = [];
  38.         if (\is_string($data)) {
  39.             $values['value'] = $data;
  40.         } else {
  41.             $values $data;
  42.         }
  43.         $values['expr'] = $values['expr'] ?? $expr;
  44.         parent::__construct($values$class$options$isOptional$converter);
  45.         $this->setExpr($values['expr']);
  46.     }
  47. }