Skip to content

Commit

Permalink
setSchedule() now property returns a $scheduler instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Kuhl committed Mar 24, 2014
1 parent 3add68a commit 503392b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ Simply `extend \Indatus\Dispatcher\ScheduledCommand` and implement the `schedule
}
```

You may also schedule commands via raw cron expressions

```php
public function schedule(Schedulable $scheduler)
{
//every other day at 3:15am, 4:15am and 5:15am
return $scheduler->setSchedule(3, [3,4,5], '*/2', '*', '*');
}
```

<a name="commands-as-users" />
### Running Commands As Users

Expand Down
3 changes: 3 additions & 0 deletions src/Indatus/Dispatcher/Drivers/Cron/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function getSchedule()
* @param mixed $dayOfMonth
* @param mixed $month
* @param mixed $dayOfWeek
* @return $this
*/
public function setSchedule($minute, $hour, $dayOfMonth, $month, $dayOfWeek)
{
Expand All @@ -85,6 +86,8 @@ public function setSchedule($minute, $hour, $dayOfMonth, $month, $dayOfWeek)
$this->setScheduleDayOfMonth($dayOfMonth);
$this->setScheduleMonth($month);
$this->setScheduleDayOfWeek($dayOfWeek);

return $this;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Indatus/Dispatcher/Schedulable.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function daysOfTheMonth($hoursIntoTheDay);
* @param mixed $dayOfMonth
* @param mixed $month
* @param mixed $dayOfWeek
* @return $this
*/
public function setSchedule($minute, $hour, $dayOfMonth, $month, $dayOfWeek);

Expand Down
2 changes: 1 addition & 1 deletion tests/Drivers/Cron/TestCronScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testBuildingSchedule()

public function testSetSchedule()
{
$this->scheduler->setSchedule(1, 2, 3, 4, 5);
$this->assertInstanceOf($this->schedularClass, $this->scheduler->setSchedule(1, 2, 3, 4, 5));
$this->assertEquals($this->scheduler->getSchedule(), '1 2 3 4 5');
}

Expand Down

0 comments on commit 503392b

Please sign in to comment.