[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/api/components/com_fields/src/View/Fields/ -> 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\Fields;
  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 fields 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          'group_id',
  39          'title',
  40          'name',
  41          'label',
  42          'default_value',
  43          'type',
  44          'note',
  45          'description',
  46          'state',
  47          'required',
  48          'checked_out',
  49          'checked_out_time',
  50          'ordering',
  51          'params',
  52          'fieldparams',
  53          'language',
  54          'created_time',
  55          'created_user_id',
  56          'modified_time',
  57          'modified_by',
  58          'access',
  59          'assigned_cat_ids',
  60      ];
  61  
  62      /**
  63       * The fields to render items in the documents
  64       *
  65       * @var  array
  66       * @since  4.0.0
  67       */
  68      protected $fieldsToRenderList = [
  69          'id',
  70          'title',
  71          'name',
  72          'checked_out',
  73          'checked_out_time',
  74          'note',
  75          'state',
  76          'access',
  77          'created_time',
  78          'created_user_id',
  79          'ordering',
  80          'language',
  81          'fieldparams',
  82          'params',
  83          'type',
  84          'default_value',
  85          'context',
  86          'group_id',
  87          'label',
  88          'description',
  89          'required',
  90          'language_title',
  91          'language_image',
  92          'editor',
  93          'access_level',
  94          'author_name',
  95          'group_title',
  96          'group_access',
  97          'group_state',
  98          'group_note',
  99      ];
 100  
 101      /**
 102       * Execute and display a template script.
 103       *
 104       * @param   object  $item  Item
 105       *
 106       * @return  string
 107       *
 108       * @since   4.0.0
 109       */
 110      public function displayItem($item = null)
 111      {
 112          if ($item === null) {
 113              /** @var \Joomla\CMS\MVC\Model\AdminModel $model */
 114              $model = $this->getModel();
 115              $item  = $this->prepareItem($model->getItem());
 116          }
 117  
 118          if ($item->id === null) {
 119              throw new RouteNotFoundException('Item does not exist');
 120          }
 121  
 122          if ($item->context != $this->getModel()->getState('filter.context')) {
 123              throw new RouteNotFoundException('Item does not exist');
 124          }
 125  
 126          return parent::displayItem($item);
 127      }
 128  }


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