[TYPO3-mvc] ViewHelperNode.php -> convertArgumentValue()

Susanne Moog typo3 at susannemoog.de
Thu May 21 20:02:43 CEST 2009


Hey,

just found an odd behavior and wanted to check whether I should file a
bug or not. The method convertArgumentValue converts nearly everything
that could be a boolean into a real one - except booleans.

What I mean is: If you enter in some fluid if condition a parameter that
is a true boolean like TRUE it gets converted to FALSE by the
convertArgumentValue(). Now I don't know if there is a way to prevent my
boolean value to be converted at all and I'm just doing it by mistake,
of this is a real "bug" and I should file a bug report?

Thanks for your efforts!

Susanne

___
The method in question:

	/**
	 * Convert argument strings to their equivalents. Needed to handle
strings with a boolean meaning.
	 *
	 * @param mixed $value Value to be converted
	 * @param string $type Target type
	 * @return mixed New value
	 * @author Sebastian Kurfürst <sebastian at typo3.org>
	 * @author Bastian Waidelich <bastian at typo3.org>
	 * @todo re-check boolean conditions
	 */
	protected function convertArgumentValue($value, $type) {
		if ($type === 'boolean') {
			if (is_string($value)) {
				return (strtolower($value) !== 'false' && !empty($value));
			}
			if (is_array($value) || (is_object($value) && $value instanceof
Countable)) {
				return count($value) > 0;
			}
			if (is_object($value)) {
				return TRUE;
			}
			return FALSE;
		}
		return $value;
	}


-- 
Susanne Moog
NEUSTA GmbH - www.neusta.de


More information about the TYPO3-project-typo3v4mvc mailing list