/** * Method to call another console command * * @param string $class The command to call * @param string $task The command task to call * @param object $arguments The command arguments * @param object $output The command output * @return void */ public function call($class, $task, Arguments $arguments, Output $output) { // Namespace class $class = Arguments::routeCommand($class); // Say no to infinite nesting! $backtrace = debug_backtrace(); $previous = $backtrace[1]; $prevClass = $previous['class']; $prevTask = $previous['function']; if ($prevClass == $class && $prevTask == $task) { $output->error('You\'ve attempted to enter an infinite loop. We\'ve stopped you. You\'re welcome.'); } // If task is help, set the output to our output class with extra methods for rendering help doc if ($task == 'help') { $output = $output->getHelpOutput(); } $command = new $class($output, $arguments); $command->{$task}(); }