- md5
- 6125d8df72c1f0604a85495fa907dc4b
- sha1
- 84c58a0bb0fc4dc890db21cadf5c3acb25590ec5
- sha256
- d12d5c45c39f1975550d8ab5ffb821caf32b3b42a9ef636bfce3cc9f4b1e11a8
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
<?php
/**
* @package Joomla.API
* @subpackage com_modules
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Modules\Api\View\Modules;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use Joomla\CMS\Router\Exception\RouteNotFoundException;
use Joomla\Component\Modules\Administrator\Model\SelectModel;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The modules view
*
* @since 4.0.0
*/
class JsonapiView extends BaseApiView
{
/**
* The fields to render item in the documents
*
* @var array
* @since 4.0.0
*/
protected $fieldsToRenderItem = [
'id',
'typeAlias',
'asset_id',
'title',
'note',
'content',
'ordering',
'position',
'checked_out',
'checked_out_time',
'publish_up',
'publish_down',
'published',
'module',
'access',
'showtitle',
'params',
'client_id',
'language',
'assigned',
'assignment',
'xml',
];
/**
* The fields to render items in the documents
*
* @var array
* @since 4.0.0
*/
protected $fieldsToRenderList = [
'id',
'title',
'note',
'position',
'module',
'language',
'checked_out',
'checked_out_time',
'published',
'enabled',
'access',
'ordering',
'publish_up',
'publish_down',
'language_title',
'language_image',
'editor',
'access_level',
'pages',
'name',
];
/**
* Execute and display a template script.
*
* @param object $item Item
*
* @return string
*
* @since 4.0.0
*/
public function displayItem($item = null)
{
/** @var \Joomla\CMS\MVC\Model\AdminModel $model */
$model = $this->getModel();
if ($item === null) {
$item = $this->prepareItem($model->getItem());
}
if ($item->id === null) {
throw new RouteNotFoundException('Item does not exist');
}
if ((int) $model->getState('client_id') !== $item->client_id) {
throw new RouteNotFoundException('Item does not exist');
}
return parent::displayItem($item);
}
/**
* Execute and display a list modules types.
*
* @return string
*
* @since 4.0.0
*/
public function displayListTypes()
{
/** @var SelectModel $model */
$model = $this->getModel();
$items = [];
foreach ($model->getItems() as $item) {
$item->id = $item->extension_id;
unset($item->extension_id);
$items[] = $item;
}
$this->fieldsToRenderList = ['id', 'name', 'module', 'xml', 'desc'];
return $this->displayList($items);
}
}
The same content is in 113 releases, Joomla 5.2.0-beta1 to 6.2.0. See them all, or every version of this file.