| Current Path : /var/www/html/administrator/components/com_jchat/Controller/ |
| Current File : /var/www/html/administrator/components/com_jchat/Controller/CpanelController.php |
<?php
namespace JExtstore\Component\JChat\Administrator\Controller;
/**
* @package JCHAT::CPANEL::administrator::components::com_jchat
* @subpackage controllers
* @author Joomla! Extensions Store
* @copyright (C) 2024 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use JExtstore\Component\JChat\Administrator\Framework\Controller as JChatController;
use JExtstore\Component\JChat\Administrator\Framework\Http;
/**
* CPanel controller
*
* @package JCHAT::CPANEL::administrator::components::com_jchat
* @subpackage controllers
* @since 1.0
*/
class CpanelController extends JChatController {
/**
* Show Control Panel
* @access public
* @return void
*/
function display($cachable = false, $urlparams = false) {
$view = $this->getView('cpanel', 'html', '', array('base_path' => $this->basePath, 'layout' => 'default'));
// Dependency injection setter on view/model
$HTTPClient = new Http();
$view->httpClient = $HTTPClient;
// No operations
parent::display ($cachable);
}
/**
* Purge file and db cache
* @access public
* @return void
*/
public function purgeCaches() {
$option = $this->option;
//Load model
$model = $this->getModel ();
$result = $model->{$this->task}();
if(!$result) {
// Model set exceptions for something gone wrong, so enqueue exceptions and levels on application object then set redirect and exit
$modelException = $model->getException(null, false);
$this->app->enqueueMessage($modelException->getMessage(), $modelException->getExceptionLevel());
$this->setRedirect ( "index.php?option=$option&task=cpanel.display", Text::_('COM_JCHAT_ERROR_DELETE_CACHE'));
return false;
}
$this->setRedirect ( "index.php?option=$option&task=cpanel.display", Text::_('COM_JCHAT_SUCCESS_DELETE_CACHE') );
}
/**
* Class Constructor
*
* @access public
* @return Object&
*/
public function __construct($config = array(), ?MVCFactoryInterface $factory = null, $app = null, $input = null) {
parent::__construct($config, $factory, $app, $input);
// Register Extra tasks
$this->registerTask ( 'purgeFileCache', 'purgeCaches' );
$this->registerTask ( 'purgeDbCache', 'purgeCaches' );
}
}
?>