[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_privacy/src/View/Export/ -> XmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_privacy
   6   *
   7   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Privacy\Administrator\View\Export;
  12  
  13  use Joomla\CMS\MVC\View\AbstractView;
  14  use Joomla\CMS\MVC\View\GenericDataException;
  15  use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper;
  16  use Joomla\Component\Privacy\Administrator\Model\ExportModel;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Export view class
  24   *
  25   * @since  3.9.0
  26   *
  27   * @property-read   \Joomla\CMS\Document\XmlDocument  $document
  28   */
  29  class XmlView extends AbstractView
  30  {
  31      /**
  32       * Execute and display a template script.
  33       *
  34       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  35       *
  36       * @return  mixed  A string if successful, otherwise an Error object.
  37       *
  38       * @since   3.9.0
  39       * @throws  \Exception
  40       */
  41      public function display($tpl = null)
  42      {
  43          /** @var ExportModel $model */
  44          $model = $this->getModel();
  45  
  46          $exportData = $model->collectDataForExportRequest();
  47  
  48          // Check for errors.
  49          if (count($errors = $this->get('Errors'))) {
  50              throw new GenericDataException(implode("\n", $errors), 500);
  51          }
  52  
  53          $requestId = $model->getState($model->getName() . '.request_id');
  54  
  55          // This document should always be downloaded
  56          $this->document->setDownload(true);
  57          $this->document->setName('export-request-' . $requestId);
  58  
  59          echo PrivacyHelper::renderDataAsXml($exportData);
  60      }
  61  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer