Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Improve schedule group behaviors #53641

Merged
merged 3 commits into from
Nov 25, 2024
Merged
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
10 changes: 8 additions & 2 deletions src/Illuminate/Console/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Schedule
/**
* The attributes to pass to the event.
*
* @var \Illuminate\Console\Scheduling\PendingEventAttributes
* @var \Illuminate\Console\Scheduling\PendingEventAttributes|null
*/
protected $attributes;

Expand Down Expand Up @@ -287,9 +287,15 @@ public function exec($command, array $parameters = [])
*
* @param \Illuminate\Console\Scheduling\Event $event
* @return void
*
* @throws \RuntimeException
*/
public function group(Closure $events)
{
if ($this->attributes === null) {
throw new RuntimeException('Invoke an attribute method such as Schedule::daily() before defining a schedule group.');
}

$this->groupStack[] = $this->attributes;

$events($this);
Expand All @@ -308,7 +314,7 @@ protected function mergePendingAttributes(Event $event)
if (isset($this->attributes)) {
$this->attributes->mergeAttributes($event);

unset($this->attributes);
$this->attributes = null;
}

if (! empty($this->groupStack)) {
Expand Down