[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_admin/src/View/Sysinfo/ -> JsonView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_admin
   6   *
   7   * @copyright   (C) 2015 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\Admin\Administrator\View\Sysinfo;
  12  
  13  use Exception;
  14  use Joomla\CMS\Access\Exception\NotAllowed;
  15  use Joomla\CMS\Factory;
  16  use Joomla\CMS\Language\Text;
  17  use Joomla\CMS\MVC\View\AbstractView;
  18  use Joomla\Component\Admin\Administrator\Model\SysinfoModel;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('_JEXEC') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * Sysinfo View class for the Admin component
  26   *
  27   * @since  3.5
  28   */
  29  class JsonView 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  void
  37       *
  38       * @since   3.5
  39       *
  40       * @throws  Exception
  41       */
  42      public function display($tpl = null): void
  43      {
  44          // Access check.
  45          if (!Factory::getUser()->authorise('core.admin')) {
  46              throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
  47          }
  48  
  49          header('MIME-Version: 1.0');
  50          header('Content-Disposition: attachment; filename="systeminfo-' . date('c') . '.json"');
  51          header('Content-Transfer-Encoding: binary');
  52  
  53          $data = $this->getLayoutData();
  54  
  55          echo json_encode($data, JSON_PRETTY_PRINT);
  56  
  57          Factory::getApplication()->close();
  58      }
  59  
  60      /**
  61       * Get the data for the view
  62       *
  63       * @return  array
  64       *
  65       * @since   3.5
  66       */
  67      protected function getLayoutData(): array
  68      {
  69          /** @var SysinfoModel $model */
  70          $model = $this->getModel();
  71  
  72          return [
  73              'info'        => $model->getSafeData('info'),
  74              'phpSettings' => $model->getSafeData('phpSettings'),
  75              'config'      => $model->getSafeData('config'),
  76              'directories' => $model->getSafeData('directory', true),
  77              'phpInfo'     => $model->getSafeData('phpInfoArray'),
  78              'extensions'  => $model->getSafeData('extensions')
  79          ];
  80      }
  81  }


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