[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_templates/src/View/Style/ -> JsonView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_templates
   6   *
   7   * @copyright   (C) 2013 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\Templates\Administrator\View\Style;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  15  use Joomla\CMS\Object\CMSObject;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * View to edit a template style.
  23   *
  24   * @since  1.6
  25   */
  26  class JsonView extends BaseHtmlView
  27  {
  28      /**
  29       * The CMSObject (on success, false on failure)
  30       *
  31       * @var   CMSObject
  32       */
  33      protected $item;
  34  
  35      /**
  36       * The form object
  37       *
  38       * @var  \Joomla\CMS\Form\Form
  39       */
  40      protected $form;
  41  
  42      /**
  43       * The model state
  44       *
  45       * @var   CMSObject
  46       */
  47      protected $state;
  48  
  49      /**
  50       * Execute and display a template script.
  51       *
  52       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  53       *
  54       * @return  mixed  A string if successful, otherwise an Error object.
  55       *
  56       * @since   1.6
  57       */
  58      public function display($tpl = null)
  59      {
  60          try {
  61              $this->item = $this->get('Item');
  62          } catch (\Exception $e) {
  63              $app = Factory::getApplication();
  64              $app->enqueueMessage($e->getMessage(), 'error');
  65  
  66              return false;
  67          }
  68  
  69          $paramsList = $this->item->getProperties();
  70  
  71          unset($paramsList['xml']);
  72  
  73          $paramsList = json_encode($paramsList);
  74  
  75          return $paramsList;
  76      }
  77  }


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