Beispiel #1
0
 public function getDefaultValue()
 {
     $default_value = parent::getDefaultValue();
     if (!$this->isInRange($default_value)) {
         throw new InvalidConfigException("Configured range option ('min_value' or 'max_value') not compatible with the 'default' value.");
     }
     return $default_value;
 }
Beispiel #2
0
 protected function buildValidationRules()
 {
     $rules = parent::buildValidationRules();
     $options = $this->getOptions();
     $rule = new ListRule('valid-list', $options);
     $rules->push($rule);
     return $rules;
 }
 /**
  * Constructs a new attribute instance with some default options.
  *
  * @param string $name
  * @param EntityTypeInterface $type,
  * @param array $options
  * @param AttributeInterface $parent
  */
 public function __construct($name, EntityTypeInterface $type, array $options = [], AttributeInterface $parent = null)
 {
     if (!array_key_exists(self::OPTION_FORCE_INTERNAL_TIMEZONE, $options)) {
         $options[self::OPTION_FORCE_INTERNAL_TIMEZONE] = self::DEFAULT_FORCE_INTERNAL_TIMEZONE;
     }
     if (!array_key_exists(self::OPTION_INTERNAL_TIMEZONE_NAME, $options)) {
         $options[self::OPTION_INTERNAL_TIMEZONE_NAME] = self::DEFAULT_INTERNAL_TIMEZONE_NAME;
     }
     parent::__construct($name, $type, $options, $parent);
 }