Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Kunden\Property\TypeConverter;
- use TYPO3\FLOW3\Annotations as FLOW3;
- use TYPO3\FLOW3\Error\Error;
- /* *
- * This script belongs to the FLOW3 package "Kunden". *
- * *
- * */
- /**
- * HourMinuteToSecondsConverter for the Kunden package
- *
- * @FLOW3\Scope("singleton")
- */
- class HourMinuteToSecondsConverter extends \TYPO3\FLOW3\Property\TypeConverter\AbstractTypeConverter {
- /**
- * @var array<string>
- */
- protected $sourceTypes = array('string');
- /**
- * @var string
- */
- protected $targetType = 'integer';
- /**
- * @var integer
- */
- protected $priority = 100;
- /**
- * Converts $source to a \DateTime using the configured dateFormat
- *
- * @param string|array $source the string to be converted to a int
- * @param string $targetType must be "Integer"
- * @param array $convertedChildProperties not used currently
- * @param \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration
- * @return \integer
- * @throws \TYPO3\FLOW3\Property\Exception\TypeConverterException
- */
- public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration = NULL) {
- if(strlen($source)==0){
- return new Error('No input given' , 1332934124, array($source));
- }
- $inArray = explode(" ", $source);
- if(!is_array($inArray)){
- return new Error('General process error (is_array)' , 1332934124, array($source));
- }
- if(count($inArray)==2){
- $hours = (int)$inArray[0] * 60 * 60;
- $minutes = (int)$inArray[1] * 60;
- return (int)($hours + $minutes);
- } else {
- return new Error('No hour or minute given.' , 1332934124, array($source));
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment