JRequest Remove from Joomla 4 then how i must use this method
for example
$controller->execute( JRequest::getCmd('task', $view)
not work i must change it to what ?
Use Joomla\Input\Input
class. Instance relevant to the current request can be accessed through the application:
use Joomla\CMS\Factory;
$controller->execute(Factory::getApplication()->getInput()->get('task', $view));
Inside controllers you should already have the input instance injected which you could use like this:
$this->input->get('inputVar');
This is some of the current code inside my controller:
function add() {
if(JRequest::checkToken( 'get' )) {
JRequest::checkToken( 'get' ) or die( 'Invalid Token' );
} else {
JRequest::checkToken() or die( 'Invalid Token' );
}
JRequest::setVar('hidemainmenu', 1);
$model = $this->getModel('albums');
$view = $this->getView('albums', 'html');
$view->setModel($model, true);
$view->setLayout('add');
$view->add();
}
It must be changed to:
function add() {
if(Factory::getApplication()->getInput()->get('get')) {
Factory::getApplication()->getInput()->get('get') or die( 'Invalid Token' );
} else {
JFactory::getApplication()->getInput() or die( 'Invalid Token' );
}
$this->input->get('hidemainmenu', 1);
$model = $this->getModel('albums');
$view = $this->getView('albums', 'html');
$view->setModel($model, true);
$view->setLayout('add');
$view->add();
}