- md5
- 2f29495321f928c962b706e382d74e50
- sha1
- a9f2bfd1c99ef6f17e7dead56982fd0b4ef6e26b
- sha256
- 0c9cb15f199a7109806a4527ee23500d3080b3e54bced65b4780679a678b943a
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
<?php
/**
* @package Joomla.API
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Modules\Api\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\ApiController;
use Joomla\Component\Modules\Administrator\Model\SelectModel;
use Joomla\Component\Modules\Api\View\Modules\JsonapiView;
/**
* The modules controller
*
* @since 4.0.0
*/
class ModulesController extends ApiController
{
/**
* The content type of the item.
*
* @var string
* @since 4.0.0
*/
protected $contentType = 'modules';
/**
* The default view for the display method.
*
* @var string
* @since 3.0
*/
protected $default_view = 'modules';
/**
* Basic display of an item view
*
* @param integer $id The primary key to display. Leave empty if you want to retrieve data from the request
*
* @return static A \JControllerLegacy object to support chaining.
*
* @since 4.0.0
*/
public function displayItem($id = null)
{
$this->modelState->set('filter.client_id', $this->getClientIdFromInput());
return parent::displayItem($id);
}
/**
* Basic display of a list view
*
* @return static A \JControllerLegacy object to support chaining.
*
* @since 4.0.0
*/
public function displayList()
{
$this->modelState->set('filter.client_id', $this->getClientIdFromInput());
return parent::displayList();
}
/**
* Return module items types
*
* @return static A \JControllerLegacy object to support chaining.
*
* @since 4.0.0
*/
public function getTypes()
{
$viewType = $this->app->getDocument()->getType();
$viewName = $this->input->get('view', $this->default_view);
$viewLayout = $this->input->get('layout', 'default', 'string');
try
{
/** @var JsonapiView $view */
$view = $this->getView(
$viewName,
$viewType,
'',
['base_path' => $this->basePath, 'layout' => $viewLayout, 'contentType' => $this->contentType]
);
}
catch (\Exception $e)
{
throw new \RuntimeException($e->getMessage());
}
/** @var SelectModel $model */
$model = $this->getModel('select', '', ['ignore_request' => true]);
if (!$model)
{
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_MODEL_CREATE'));
}
$model->setState('client_id', $this->getClientIdFromInput());
$view->setModel($model, true);
$view->document = $this->app->getDocument();
$view->displayListTypes();
return $this;
}
/**
* Get client id from input
*
* @return string
*
* @since 4.0
*/
private function getClientIdFromInput()
{
return $this->input->exists('client_id') ?
$this->input->get('client_id') : $this->input->post->get('client_id');
}
}
The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.