/var/www/vhosts/nabawater/vendor/yiisoft/yii2/web
NameSizeModeActions
migrations/-0755rm
Application.php58360644editdlrm
AssetBundle.php86020644editdlrm
AssetConverter.php45990644editdlrm
AssetConverterInterface.php6980644editdlrm
AssetManager.php255860644editdlrm
BadRequestHttpException.php10770644editdlrm
CacheSession.php36730644editdlrm
CompositeUrlRule.php44820644editdlrm
ConflictHttpException.php8140644editdlrm
Controller.php97390644editdlrm
Cookie.php20020644editdlrm
CookieCollection.php80940644editdlrm
DbSession.php76280644editdlrm
ErrorAction.php60920644editdlrm
ErrorHandler.php191410644editdlrm
ForbiddenHttpException.php11260644editdlrm
GoneHttpException.php10730644editdlrm
GroupUrlRule.php46960644editdlrm
HeaderCollection.php72360644editdlrm
HeadersAlreadySentException.php7000644editdlrm
HtmlResponseFormatter.php10920644editdlrm
HttpException.php17600644editdlrm
IdentityInterface.php36610644editdlrm
JqueryAsset.php4590644editdlrm
JsExpression.php12530644editdlrm
JsonParser.php17310644editdlrm
JsonResponseFormatter.php46770644editdlrm
Link.php20780644editdlrm
Linkable.php11090644editdlrm
MethodNotAllowedHttpException.php8330644editdlrm
MultiFieldSession.php46140644editdlrm
MultipartFormDataParser.php122710644editdlrm
NotAcceptableHttpException.php10630644editdlrm
NotFoundHttpException.php8080644editdlrm
RangeNotSatisfiableHttpException.php12120644editdlrm
Request.php656150644editdlrm
RequestParserInterface.php6690644editdlrm
Response.php413540644editdlrm
ResponseFormatterInterface.php5430644editdlrm
ServerErrorHttpException.php8270644editdlrm
Session.php345780644editdlrm
SessionIterator.php19780644editdlrm
TooManyRequestsHttpException.php10190644editdlrm
UnauthorizedHttpException.php11530644editdlrm
UnprocessableEntityHttpException.php11200644editdlrm
UnsupportedMediaTypeHttpException.php10940644editdlrm
UploadedFile.php88360644editdlrm
UrlManager.php258720644editdlrm
UrlNormalizer.php51030644editdlrm
UrlNormalizerRedirectException.php17580644editdlrm
UrlRule.php217070644editdlrm
UrlRuleInterface.php12230644editdlrm
User.php331100644editdlrm
UserEvent.php12290644editdlrm
View.php237450644editdlrm
ViewAction.php47180644editdlrm
XmlResponseFormatter.php56670644editdlrm
YiiAsset.php5040644editdlrm
Edit: /var/www/vhosts/nabawater/vendor/yiisoft/yii2/web/XmlResponseFormatter.php (5667B)
* @since 2.0 */ class XmlResponseFormatter extends Component implements ResponseFormatterInterface { /** * @var string the Content-Type header for the response */ public $contentType = 'application/xml'; /** * @var string the XML version */ public $version = '1.0'; /** * @var string the XML encoding. If not set, it will use the value of [[Response::charset]]. */ public $encoding; /** * @var string the name of the root element. If set to false, null or is empty then no root tag should be added. */ public $rootTag = 'response'; /** * @var string the name of the elements that represent the array elements with numeric keys. */ public $itemTag = 'item'; /** * @var bool whether to interpret objects implementing the [[\Traversable]] interface as arrays. * Defaults to `true`. * @since 2.0.7 */ public $useTraversableAsArray = true; /** * @var bool if object tags should be added * @since 2.0.11 */ public $useObjectTags = true; /** * Formats the specified response. * @param Response $response the response to be formatted. */ public function format($response) { $charset = $this->encoding === null ? $response->charset : $this->encoding; if (stripos($this->contentType, 'charset') === false) { $this->contentType .= '; charset=' . $charset; } $response->getHeaders()->set('Content-Type', $this->contentType); if ($response->data !== null) { $dom = new DOMDocument($this->version, $charset); if (!empty($this->rootTag)) { $root = new DOMElement($this->rootTag); $dom->appendChild($root); $this->buildXml($root, $response->data); } else { $this->buildXml($dom, $response->data); } $response->content = $dom->saveXML(); } } /** * @param DOMElement $element * @param mixed $data */ protected function buildXml($element, $data) { if (is_array($data) || ($data instanceof \Traversable && $this->useTraversableAsArray && !$data instanceof Arrayable) ) { foreach ($data as $name => $value) { if (is_int($name) && is_object($value)) { $this->buildXml($element, $value); } elseif (is_array($value) || is_object($value)) { $child = new DOMElement($this->getValidXmlElementName($name)); $element->appendChild($child); $this->buildXml($child, $value); } else { $child = new DOMElement($this->getValidXmlElementName($name)); $element->appendChild($child); $child->appendChild(new DOMText($this->formatScalarValue($value))); } } } elseif (is_object($data)) { if ($this->useObjectTags) { $child = new DOMElement(StringHelper::basename(get_class($data))); $element->appendChild($child); } else { $child = $element; } if ($data instanceof Arrayable) { $this->buildXml($child, $data->toArray()); } else { $array = []; foreach ($data as $name => $value) { $array[$name] = $value; } $this->buildXml($child, $array); } } else { $element->appendChild(new DOMText($this->formatScalarValue($data))); } } /** * Formats scalar value to use in XML text node. * * @param int|string|bool|float $value a scalar value. * @return string string representation of the value. * @since 2.0.11 */ protected function formatScalarValue($value) { if ($value === true) { return 'true'; } if ($value === false) { return 'false'; } if (is_float($value)) { return StringHelper::floatToString($value); } return (string) $value; } /** * Returns element name ready to be used in DOMElement if * name is not empty, is not int and is valid. * * Falls back to [[itemTag]] otherwise. * * @param mixed $name * @return string * @since 2.0.12 */ protected function getValidXmlElementName($name) { if (empty($name) || is_int($name) || !$this->isValidXmlName($name)) { return $this->itemTag; } return $name; } /** * Checks if name is valid to be used in XML. * * @param mixed $name * @return bool * @see http://stackoverflow.com/questions/2519845/how-to-check-if-string-is-a-valid-xml-element-name/2519943#2519943 * @since 2.0.12 */ protected function isValidXmlName($name) { try { new DOMElement($name); return true; } catch (DOMException $e) { return false; } } }