public function setValue($value) { if (!is_numeric($value)) { throw new Exception(array("VALUE_NOT_INTEGER_OR_FLOAT", $value)); } parent::setValue((double) $value); }
/** * {@inheritdoc} */ public function dump(array $options = []) { $result = parent::dump($options); if (!isset($options['language'])) { throw new \InvalidArgumentException('Language not specified'); } if (!isset($options['indexAnalyzers'])) { throw new \InvalidArgumentException('Available index analyzers missing'); } // Replace {lang} in any analyzers with the respective language // If no analyzer is defined for a certain language, replace {lang} with 'default' array_walk($result, function (&$value, $key, $options) { if (in_array($key, ['analyzer', 'index_analyzer', 'search_analyzer']) && false !== strpos($value, self::LANGUAGE_PLACEHOLDER)) { // Get the names of all available analyzers in the index $indexAnalyzers = array_keys($options['indexAnalyzers']); // Make sure a default analyzer is defined, even if we don't need it right now // because, if a new language is added and we don't have an analyzer for it, ES mapping would fail $defaultAnalyzer = str_replace(self::LANGUAGE_PLACEHOLDER, self::DEFAULT_LANG_SUFFIX, $value); if (!in_array($defaultAnalyzer, $indexAnalyzers)) { throw new \LogicException(sprintf('There must be a default language analyzer "%s" defined for index', $defaultAnalyzer)); } $value = str_replace(self::LANGUAGE_PLACEHOLDER, $options['language'], $value); if (!in_array($value, $indexAnalyzers)) { $value = $defaultAnalyzer; } } }, $options); return $result; }
public function setValue($value) { if ($this->getParameter('constraint.uppercase')) { $value = mb_strtoupper($value, 'UTF-8'); } if ($this->getParameter('constraint.lowercase')) { $value = mb_strtolower($value, 'UTF-8'); } return parent::setValue($value); }
public function setValue($value) { switch ($value) { case self::NOW: $value = date('H:i'); break; default: break; } parent::setValue($value); }
public function getValue($key = null) { if (is_null($key)) { return parent::getValue(); } else { if (isset($this->_value[$key])) { return $this->_value[$key]; } else { return false; } } }