Skip to content

Commit

Permalink
Merge pull request #27 from seferov/timezone
Browse files Browse the repository at this point in the history
add timezone option (CRON_TZ)
  • Loading branch information
gavinlove authored Aug 13, 2018
2 parents fef2ca3 + 3a96e51 commit 9e28d42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
4 changes: 4 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public function getConfigTreeBuilder()
->example('/bin/sh')
->info('Allows you to specify which shell each program should be run with.')
->end()
->scalarNode('timezone')
->example('Europe/Paris')
->info('Allows you to add CRON_TZ which specifies the time zone specific for the cron table.')
->end()
->end()
->end()
->end();
Expand Down
35 changes: 11 additions & 24 deletions Exporter/ArrayHeaderConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace MyBuilder\Bundle\CronosBundle\Exporter;

use Symfony\Component\PropertyAccess\PropertyAccessor;

class ArrayHeaderConfigurator
{
private $configFields = array('mailto', 'path', 'shell', 'encoding', 'contentType', 'timezone');

private $header;

public function __construct($header)
Expand All @@ -13,30 +17,13 @@ public function __construct($header)

public function configureFrom(array $config)
{
$this->setupMailto($config);
$this->setupPath($config);
$this->setupShell($config);
return $this->header;
}

private function setupMailto($config)
{
if (isset($config['mailto'])) {
$this->header->setMailTo($config['mailto']);
}
}

private function setupPath($config)
{
if (isset($config['path'])) {
$this->header->setPath($config['path']);
$propertyAccessor = new PropertyAccessor();
foreach ($this->configFields as $configField) {
if (isset($config[$configField])) {
$propertyAccessor->setValue($this->header, $configField, $config[$configField]);
}
}
}

private function setupShell($config)
{
if (isset($config['shell'])) {
$this->header->setShell($config['shell']);
}
return $this->header;
}
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"symfony/console": "~2.7|~3.0||^4.0",
"symfony/framework-bundle": "~2.7|~3.0||^4.0",
"symfony/yaml": "~2.7|~3.0||^4.0",
"symfony/property-access": "~2.7|~3.0||^4.0",
"php": ">=7.1"
},
"require-dev": {
Expand Down

0 comments on commit 9e28d42

Please sign in to comment.