[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/api/components/com_fields/src/View/Groups/ -> JsonapiView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.API
   5   * @subpackage  com_fields
   6   *
   7   * @copyright   (C) 2019 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\Fields\Api\View\Groups;
  12  
  13  use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
  14  use Joomla\CMS\Router\Exception\RouteNotFoundException;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * The groups view
  22   *
  23   * @since  4.0.0
  24   */
  25  class JsonapiView extends BaseApiView
  26  {
  27      /**
  28       * The fields to render item in the documents
  29       *
  30       * @var  array
  31       * @since  4.0.0
  32       */
  33      protected $fieldsToRenderItem = [
  34          'typeAlias',
  35          'id',
  36          'asset_id',
  37          'context',
  38          'title',
  39          'note',
  40          'description',
  41          'state',
  42          'checked_out',
  43          'checked_out_time',
  44          'ordering',
  45          'params',
  46          'language',
  47          'created',
  48          'created_by',
  49          'modified',
  50          'modified_by',
  51          'access',
  52          'type',
  53      ];
  54  
  55      /**
  56       * The fields to render items in the documents
  57       *
  58       * @var  array
  59       * @since  4.0.0
  60       */
  61      protected $fieldsToRenderList = [
  62          'id',
  63          'title',
  64          'name',
  65          'checked_out',
  66          'checked_out_time',
  67          'note',
  68          'state',
  69          'access',
  70          'created_time',
  71          'created_user_id',
  72          'ordering',
  73          'language',
  74          'fieldparams',
  75          'params',
  76          'type',
  77          'default_value',
  78          'context',
  79          'group_id',
  80          'label',
  81          'description',
  82          'required',
  83          'language_title',
  84          'language_image',
  85          'editor',
  86          'access_level',
  87          'author_name',
  88          'group_title',
  89          'group_access',
  90          'group_state',
  91          'group_note',
  92      ];
  93  
  94      /**
  95       * Execute and display a template script.
  96       *
  97       * @param   object  $item  Item
  98       *
  99       * @return  string
 100       *
 101       * @since   4.0.0
 102       */
 103      public function displayItem($item = null)
 104      {
 105          if ($item === null) {
 106              /** @var \Joomla\CMS\MVC\Model\AdminModel $model */
 107              $model = $this->getModel();
 108              $item  = $this->prepareItem($model->getItem());
 109          }
 110  
 111          if ($item->id === null) {
 112              throw new RouteNotFoundException('Item does not exist');
 113          }
 114  
 115          if ($item->context != $this->getModel()->getState('filter.context')) {
 116              throw new RouteNotFoundException('Item does not exist');
 117          }
 118  
 119          return parent::displayItem($item);
 120      }
 121  }


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