protected function accept(\cmu\html\form\visitors\input\AbstractInputVisitor $visitor, \cmu\html\form\products\Input $component) { //get TYPE converted to upper case $type = ucfirst($component->getType()); //build method visit + type (from above) $method = "visit" . $type; //return the values from the new object function return $visitor->{$method}($component); }
function visitInput(\cmu\html\form\products\Input $component) { //if we have a value , type is TEXT and sanitize is set //we can only validate TEXT input if ($component->getType() == "text" && null !== $component->getSanitize() && null != $component->getValue()) { $sanitize = new \cmu\html\form\sanitize\SanitizeContext($component->getSanitize()); $component->setValue($sanitize->sanitizeText($component->getValue())); } }