PHP 클래스 Neos\Flow\Property\TypeConverter\FloatConverter

This is basically done by simply casting it, unless the input is a string and you provide some configuration options which will make this converter use Flow's locale parsing capabilities in order to respect deviating decimal separators. Using NULL or an empty string as input will result in a NULL return value. **Advanced usage in action controller context** *Using default locale*:: protected function initializeCreateAction() { $this->arguments['newBid']->getPropertyMappingConfiguration()->forProperty('price')->setTypeConverterOption( \Neos\Flow\Property\TypeConverter\FloatConverter::class, 'locale', TRUE ); } Just providing TRUE as option value will use the current default locale. In case that default locale is "DE" for Germany for example, where a comma is used as decimal separator, the mentioned code will return (float)15.5 when the input was (string)"15,50". *Using arbitrary locale*:: protected function initializeCreateAction() { $this->arguments['newBid']->getPropertyMappingConfiguration()->forProperty('price')->setTypeConverterOption( \Neos\Flow\Property\TypeConverter\FloatConverter::class, 'locale', 'fr' ); } **Parsing mode** There are two parsing modes available, strict and lenient mode. Strict mode will check all constraints of the provided format, and if any of them are not fulfilled, the conversion will not take place. In Lenient mode the parser will try to extract the intended number from the string, even if it's not well formed. Default for strict mode is TRUE. *Example setting lenient mode (abridged)*:: ->setTypeConverterOption( \Neos\Flow\Property\TypeConverter\FloatConverter::class, 'strictMode', FALSE ); **Format type** Format type can be decimal, percent or currency; represented as class constant FORMAT_TYPE_DECIMAL, FORMAT_TYPE_PERCENT or FORMAT_TYPE_CURRENCY of class Neos\Flow\I18n\Cldr\Reader\NumbersReader. Default, if none given, is FORMAT_TYPE_DECIMAL. *Example setting format type currency (abridged)*:: ->setTypeConverterOption( \Neos\Flow\Property\TypeConverter\FloatConverter::class, 'formatType', \Neos\Flow\I18n\Cldr\Reader\NumbersReader::FORMAT_TYPE_CURRENCY ); **Format length** Format type can be default, full, long, medium or short; represented as class constant FORMAT_LENGTH_DEFAULT, FORMAT_LENGTH_FULL, FORMAT_LENGTH_LONG etc., of class Neos\Flow\I18n\Cldr\Reader\NumbersReader. The format length has a technical background in the CLDR repository, and specifies whether a different number pattern should be used. In most cases leaving this DEFAULT would be the correct choice. *Example setting format length (abridged)*:: ->setTypeConverterOption( \Neos\Flow\Property\TypeConverter\FloatConverter::class, 'formatLength', \Neos\Flow\I18n\Cldr\Reader\NumbersReader::FORMAT_LENGTH_FULL );
상속: extends AbstractTypeConverter
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$localizationService Neos\Flow\I18n\Service
$numberParser Neos\Flow\I18n\Parser\NumberParser
$priority integer
$sourceTypes array
$targetType string

공개 메소드들

메소드 설명
convertFrom ( mixed $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : float | Neos\Error\Messages\Error Actually convert from $source to $targetType, by doing a typecast.

보호된 메소드들

메소드 설명
getConfigurationKeysAndValues ( Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration, array $configurationKeys ) : array Helper method to collect configuration for this class.
parseUsingLocaleIfConfigured ( string $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : float | Error Tries to parse the input using the NumberParser.

메소드 상세

convertFrom() 공개 메소드

Actually convert from $source to $targetType, by doing a typecast.
public convertFrom ( mixed $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : float | Neos\Error\Messages\Error
$source mixed
$targetType string
$convertedChildProperties array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
리턴 float | Neos\Error\Messages\Error

getConfigurationKeysAndValues() 보호된 메소드

Helper method to collect configuration for this class.
protected getConfigurationKeysAndValues ( Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration, array $configurationKeys ) : array
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
$configurationKeys array
리턴 array

parseUsingLocaleIfConfigured() 보호된 메소드

Tries to parse the input using the NumberParser.
protected parseUsingLocaleIfConfigured ( string $source, Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration ) : float | Error
$source string
$configuration Neos\Flow\Property\PropertyMappingConfigurationInterface
리턴 float | Neos\Flow\Validation\Error Parsed float number or error

프로퍼티 상세

$localizationService 보호되어 있는 프로퍼티

protected Service,Neos\Flow\I18n $localizationService
리턴 Neos\Flow\I18n\Service

$numberParser 보호되어 있는 프로퍼티

protected NumberParser,Neos\Flow\I18n\Parser $numberParser
리턴 Neos\Flow\I18n\Parser\NumberParser

$priority 보호되어 있는 프로퍼티

protected int $priority
리턴 integer

$sourceTypes 보호되어 있는 프로퍼티

protected array $sourceTypes
리턴 array

$targetType 보호되어 있는 프로퍼티

protected string $targetType
리턴 string