Inheritance: extends Symfony\Component\Validator\Constraint
示例#1
0
 /**
  * {@inheritdoc}
  */
 public function __construct($options = null)
 {
     if (isset($options['entity'])) {
         /** @var AbstractEnumType $entity */
         $entity = $options['entity'];
         if (is_subclass_of($entity, 'Fresh\\DoctrineEnumBundle\\DBAL\\Types\\AbstractEnumType')) {
             $this->choices = $entity::getValues();
         }
     }
     parent::__construct($options);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function __construct($options = null)
 {
     if (isset($options['entity'])) {
         /** @var AbstractEnumType $entity */
         $entity = $options['entity'];
         if (is_a($entity, 'Fresh\\DoctrineEnumBundle\\DBAL\\Types\\AbstractEnumType', true)) {
             $this->choices = array_keys($entity::getChoices());
         }
     }
     parent::__construct($options);
 }
示例#3
0
文件: Enum.php 项目: greg0ire/enum
 /**
  * {@inheritdoc}
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     if (!is_a($this->class, AbstractEnum::class, true)) {
         throw new ConstraintDefinitionException('The option "class" must be a class that inherits from ' . AbstractEnum::class);
     }
     $this->choices = call_user_func([$this->class, 'getConstants']);
     if ($this->showKeys) {
         $keysMessage = 'Valid ' . $this->class . ' constant keys are: ' . implode(', ', call_user_func([$this->class, 'getKeys'])) . '.';
         $this->message .= ' ' . $keysMessage;
         $this->multipleMessage .= ' ' . $keysMessage;
     }
 }