/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/View
NameSizeModeActions
Exception/-0755rm
Form/-0755rm
Helper/-0755rm
Widget/-0755rm
AjaxView.php10880644editdlrm
Cell.php90450644editdlrm
CellTrait.php44460644editdlrm
Helper.php73290644editdlrm
HelperRegistry.php48600644editdlrm
JsonView.php58780644editdlrm
NegotiationRequiredView.php18360644editdlrm
SerializedView.php36900644editdlrm
StringTemplate.php115640644editdlrm
StringTemplateTrait.php28640644editdlrm
View.php523500644editdlrm
ViewBlock.php64040644editdlrm
ViewBuilder.php176020644editdlrm
ViewVarsTrait.php30690644editdlrm
XmlView.php47980644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/View/XmlView.php (4798B)
set(['posts' => $posts]); * $this->viewBuilder()->setOption('serialize', true); * ``` * * When the view is rendered, the `$posts` view variable will be serialized * into XML. * * **Note** The view variable you specify must be compatible with Xml::fromArray(). * * You can also set `'serialize'` as an array. This will create an additional * top level element named `` containing all the named view variables: * * ``` * $this->set(compact('posts', 'users', 'stuff')); * $this->viewBuilder()->setOption('serialize', true); * ``` * * The above would generate a XML object that looks like: * * `......` * * You can also set `'serialize'` to a string or array to serialize only the * specified view variables. * * If you don't set the `serialize` option, you will need a view. You can use extended * views to provide layout like functionality. */ class XmlView extends SerializedView { /** * XML layouts are located in the `layouts/xml/` subdirectory * * @var string */ protected $layoutPath = 'xml'; /** * XML views are located in the 'xml' subdirectory for controllers' views. * * @var string */ protected $subDir = 'xml'; /** * Default config options. * * Use ViewBuilder::setOption()/setOptions() in your controller to set these options. * * - `serialize`: Option to convert a set of view variables into a serialized response. * Its value can be a string for single variable name or array for multiple * names. If true all view variables will be serialized. If null or false * normal view template will be rendered. * - `xmlOptions`: Option to allow setting an array of custom options for Xml::fromArray(). * For e.g. 'format' as 'attributes' instead of 'tags'. * - `rootNode`: Root node name. Defaults to "response". * * @var array */ protected $_defaultConfig = [ 'serialize' => null, 'xmlOptions' => null, 'rootNode' => null, ]; /** * Mime-type this view class renders as. * * @return string The JSON content type. */ public static function contentType(): string { return 'application/xml'; } /** * @inheritDoc */ protected function _serialize($serialize): string { $rootNode = $this->getConfig('rootNode', 'response'); if (is_array($serialize)) { if (empty($serialize)) { $serialize = ''; } elseif (count($serialize) === 1) { $serialize = current($serialize); } } if (is_array($serialize)) { $data = [$rootNode => []]; foreach ($serialize as $alias => $key) { if (is_numeric($alias)) { $alias = $key; } if (array_key_exists($key, $this->viewVars)) { $data[$rootNode][$alias] = $this->viewVars[$key]; } } } else { $data = $this->viewVars[$serialize] ?? []; if ( $data && (!is_array($data) || Hash::numeric(array_keys($data))) ) { /** @psalm-suppress InvalidArrayOffset */ $data = [$rootNode => [$serialize => $data]]; } } $options = $this->getConfig('xmlOptions', []); if (Configure::read('debug')) { $options['pretty'] = true; } return Xml::fromArray($data, $options)->saveXML(); } }