Skip to content

Commit

Permalink
Use global configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
peppeocchi committed Sep 24, 2015
1 parent 772ba86 commit ffabefa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,40 @@ Then add to your crontab

And you are ready to go.

### Config
You can pass to the Scheduler constructor an array with your global config for the jobs

The only supported configuration until now is the sender email address when sending the result of a job execution

```php
...
$config = [
'emailFrom' => '[email protected]'
];

$scheduler = new Scheduler($config);
...
```

You can also switch configuration on a per job basis or for a group of jobs

```php
...
$config1 = [...];
$config2 = [...];
$scheduler = new Scheduler();

$scheduler->useConfig($config1)->php(...)....

$scheduler->useConfig($config2);

$scheduler->raw(...)....
$scheduler->call(...)....

$scheduler->useConfig($config1);
...
```

### Jobs execution order
The jobs that are due to run are being ordered by their execution: jobs that can run in **background** will be executed **first**

Expand Down
13 changes: 12 additions & 1 deletion src/GO/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@ class Scheduler
*/
public function __construct(array $config = [])
{
$this->config = $config;
$this->useConfig($config);

$this->time = time();
}

/**
* Switch between configurations
*
* @param array $config
* @return void
*/
public function useConfig(array $config)
{
$this->config = $config;
}

/**
* Set the timezone
*
Expand Down

0 comments on commit ffabefa

Please sign in to comment.