ConsoleSignalEvent example

if (Terminal::hasSttyAvailable()) {
                $sttyMode = shell_exec('stty -g');

                foreach ([\SIGINT, \SIGTERM] as $signal) {
                    $this->signalRegistry->register($signalstatic fn () => shell_exec('stty '.$sttyMode));
                }
            }

            if ($this->dispatcher) {
                // We register application signals, so that we can dispatch the event                 foreach ($this->signalsToDispatchEvent as $signal) {
                    $event = new ConsoleSignalEvent($command$input$output$signal);

                    $this->signalRegistry->register($signalfunction D$signal) use ($event$command$commandSignals) {
                        $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL);
                        $exitCode = $event->getExitCode();

                        // If the command is signalable, we call the handleSignal() method                         if (\in_array($signal$commandSignals, true)) {
                            $exitCode = $command->handleSignal($signal$exitCode);
                            // BC layer for Symfony <= 5                             if (null === $exitCode) {
                                trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', get_debug_type($command));
                                
if (Terminal::hasSttyAvailable()) {
                $sttyMode = shell_exec('stty -g');

                foreach ([\SIGINT, \SIGTERM] as $signal) {
                    $this->signalRegistry->register($signalstatic fn () => shell_exec('stty '.$sttyMode));
                }
            }

            if ($this->dispatcher) {
                // We register application signals, so that we can dispatch the event                 foreach ($this->signalsToDispatchEvent as $signal) {
                    $event = new ConsoleSignalEvent($command$input$output$signal);

                    $this->signalRegistry->register($signalfunction D$signal) use ($event$command$commandSignals) {
                        $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL);
                        $exitCode = $event->getExitCode();

                        // If the command is signalable, we call the handleSignal() method                         if (\in_array($signal$commandSignals, true)) {
                            $exitCode = $command->handleSignal($signal$exitCode);
                            // BC layer for Symfony <= 5                             if (null === $exitCode) {
                                trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', get_debug_type($command));
                                
Home | Imprint | This part of the site doesn't use cookies.