protected function setResponseParam($name, $value, $isHtml = false) { if (!$isHtml) { $reflection = new ReflectionUtil(); $value = $reflection->htmlEscForResponseItem($value); } $this->response->{$name} = $value; }
public function htmlEscForResponseItem($object) { if (empty($object)) { return null; } if (is_object($object)) { $class_name = get_class($object); $reflection = new ReflectionUtil($class_name); $properties = $reflection->reflectedClass->getProperties(); foreach ($properties as $property) { $name = $property->getName(); if (is_object($object->{$name})) { $object->{$name} = $reflection->htmlEscForResponseItem($object->{$name}); } else { if (is_array($object->{$name})) { $object->{$name} = $object->{$name}; } else { $object->{$name} = htmlspecialchars($object->{$name}); } } } } else { if (is_array($object)) { $object = $this->htmlEscForArrays($object); } else { $object = htmlspecialchars($object); } } return $object; }