Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Illuminate/Console/Events/SchedulePaused.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Illuminate\Console\Events;

class SchedulePaused
{
}
7 changes: 7 additions & 0 deletions src/Illuminate/Console/Events/ScheduleResumed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Illuminate\Console\Events;

class ScheduleResumed
{
}
6 changes: 5 additions & 1 deletion src/Illuminate/Console/Scheduling/SchedulePauseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Illuminate\Console\Scheduling;

use Illuminate\Console\Command;
use Illuminate\Console\Events\SchedulePaused;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Events\Dispatcher;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'schedule:pause')]
Expand All @@ -21,10 +23,12 @@ class SchedulePauseCommand extends Command
*
* @return int
*/
public function handle(Cache $cache)
public function handle(Cache $cache, Dispatcher $dispatcher)
{
$cache->forever('illuminate:schedule:paused', true);

$dispatcher->dispatch(new SchedulePaused);

$this->components->info('Scheduled task processing has been paused.');

return 0;
Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Console/Scheduling/ScheduleResumeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Illuminate\Console\Scheduling;

use Illuminate\Console\Command;
use Illuminate\Console\Events\ScheduleResumed;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Events\Dispatcher;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'schedule:resume', aliases: ['schedule:continue'])]
Expand All @@ -28,10 +30,12 @@ class ScheduleResumeCommand extends Command
*
* @return int
*/
public function handle(Cache $cache)
public function handle(Cache $cache, Dispatcher $dispatcher)
{
$cache->forget('illuminate:schedule:paused');

$dispatcher->dispatch(new ScheduleResumed);

$this->components->info('Scheduled task processing has resumed.');

return 0;
Expand Down
19 changes: 19 additions & 0 deletions tests/Integration/Console/Scheduling/SchedulePauseCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Illuminate\Tests\Integration\Console\Scheduling;

use Illuminate\Console\Events\SchedulePaused;
use Illuminate\Support\Facades\Event;
use Orchestra\Testbench\TestCase;

class SchedulePauseCommandTest extends TestCase
{
public function testDispatchesEvent()
{
Event::fake();

$this->artisan('schedule:pause');

Event::assertDispatched(SchedulePaused::class);
}
}
19 changes: 19 additions & 0 deletions tests/Integration/Console/Scheduling/ScheduleResumeCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Illuminate\Tests\Integration\Console\Scheduling;

use Illuminate\Console\Events\ScheduleResumed;
use Illuminate\Support\Facades\Event;
use Orchestra\Testbench\TestCase;

class ScheduleResumeCommandTest extends TestCase
{
public function testDispatchesEvent()
{
Event::fake();

$this->artisan('schedule:resume');

Event::assertDispatched(ScheduleResumed::class);
}
}
Loading