Skip to content

Commit 9e28d42

Browse files
authored
Merge pull request #27 from seferov/timezone
add timezone option (CRON_TZ)
2 parents fef2ca3 + 3a96e51 commit 9e28d42

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function getConfigTreeBuilder()
4949
->example('/bin/sh')
5050
->info('Allows you to specify which shell each program should be run with.')
5151
->end()
52+
->scalarNode('timezone')
53+
->example('Europe/Paris')
54+
->info('Allows you to add CRON_TZ which specifies the time zone specific for the cron table.')
55+
->end()
5256
->end()
5357
->end()
5458
->end();

Exporter/ArrayHeaderConfigurator.php

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
namespace MyBuilder\Bundle\CronosBundle\Exporter;
44

5+
use Symfony\Component\PropertyAccess\PropertyAccessor;
6+
57
class ArrayHeaderConfigurator
68
{
9+
private $configFields = array('mailto', 'path', 'shell', 'encoding', 'contentType', 'timezone');
10+
711
private $header;
812

913
public function __construct($header)
@@ -13,30 +17,13 @@ public function __construct($header)
1317

1418
public function configureFrom(array $config)
1519
{
16-
$this->setupMailto($config);
17-
$this->setupPath($config);
18-
$this->setupShell($config);
19-
return $this->header;
20-
}
21-
22-
private function setupMailto($config)
23-
{
24-
if (isset($config['mailto'])) {
25-
$this->header->setMailTo($config['mailto']);
26-
}
27-
}
28-
29-
private function setupPath($config)
30-
{
31-
if (isset($config['path'])) {
32-
$this->header->setPath($config['path']);
20+
$propertyAccessor = new PropertyAccessor();
21+
foreach ($this->configFields as $configField) {
22+
if (isset($config[$configField])) {
23+
$propertyAccessor->setValue($this->header, $configField, $config[$configField]);
24+
}
3325
}
34-
}
3526

36-
private function setupShell($config)
37-
{
38-
if (isset($config['shell'])) {
39-
$this->header->setShell($config['shell']);
40-
}
27+
return $this->header;
4128
}
42-
}
29+
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"symfony/console": "~2.7|~3.0||^4.0",
2323
"symfony/framework-bundle": "~2.7|~3.0||^4.0",
2424
"symfony/yaml": "~2.7|~3.0||^4.0",
25+
"symfony/property-access": "~2.7|~3.0||^4.0",
2526
"php": ">=7.1"
2627
},
2728
"require-dev": {

0 commit comments

Comments
 (0)