Requestaction in a shell in cakephp 3.7

Hi, I’m moving an app from 2 to 3.7. In 2 I was using a shell to call a function in a controller via requestAction(), but can’t make it work on 3.7. I know I need to move away from a shell by 5.0, but don’t have the time to figure out how just now. My shell code in src/Shell/NotificationsShell.php is:-


namespace App\Shell;

use Cake\Console\Shell;
use Cake\Routing\RequestActionTrait;
class NotificationsShell extends Shell {
var $uses = array('User','Trip','Lunch');
function main() {
$this->layout = null;
$this->autoRender = false;

and the error I get when running bin/cake Notifications is:-
Call to undefined method App\Shell\NotificationsShell::requestAction() in /home/probusgi/public_html/ProbusLive/src/Shell/NotificationsShell.php on line 12

Can anyone help please? TIA

KInd of solved, I managed to do what I wanted without requestaction.

Hi Peterg, tell how you solved the problem, the same thing happens to me, thanks.

I dropped shell and used command instead:

The code now looks like:

 1 <?php
 2 namespace App\Command;
 4 use Cake\Console\Arguments;
 5 use Cake\Console\Command;
 6 use Cake\Console\ConsoleIo;
 8 use App\Controller\NotificationsController;
10 class NotificationsCommand extends Command {
11     public function execute(Arguments $args, ConsoleIo $io) {
12         $this->layout = null;
13         $this->autoRender = false;
14         $Notifications = new NotificationsController();
15         $Notifications->notification();
16     }
17 }