Skip to content

Commit 10270ee

Browse files
Add symfony 5 compatibility (#50)
1 parent 8f4f34c commit 10270ee

File tree

8 files changed

+44
-16
lines changed

8 files changed

+44
-16
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ matrix:
5757
- php: 7.3
5858
env:
5959
- STORAGE=doctrine
60+
- php: 7.4
61+
env:
62+
- STORAGE=array
63+
- php: 7.4
64+
env:
65+
- STORAGE=doctrine
6066

6167
before_install:
6268
- if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
],
1212
"require": {
1313
"php": "^5.6 || ^7.0",
14-
"php-task/php-task": "^1.3",
15-
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0",
16-
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0",
17-
"symfony/expression-language": "^2.8 || ^3.4 || ^4.0",
18-
"symfony/config": "^2.8 || ^3.4 || ^4.0",
19-
"symfony/console": "^2.8 || ^3.4 || ^4.0",
20-
"symfony/process": "^2.8 || ^3.4 || ^4.0",
14+
"php-task/php-task": "^1.4",
15+
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0 || ^5.0",
16+
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0 || ^5.0",
17+
"symfony/expression-language": "^2.8 || ^3.4 || ^4.0 || ^5.0",
18+
"symfony/config": "^2.8 || ^3.4 || ^4.0 || ^5.0",
19+
"symfony/console": "^2.8 || ^3.4 || ^4.0 || ^5.0",
20+
"symfony/process": "^2.8 || ^3.4 || ^4.0 || ^5.0",
2121
"doctrine/orm": "^2.5"
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "^4.8 || ^5.0",
2525
"sebastian/comparator": "^1.2.3",
26-
"symfony/debug": "^2.8 || ^3.4 || ^4.0",
27-
"symfony/framework-bundle": "^2.8 || ^3.4 || ^4.0",
28-
"symfony/finder": "^2.8 || ^3.4 || ^4.0",
29-
"symfony/yaml": "^2.8 || ^3.4 || ^4.0",
26+
"symfony/debug": "^2.8 || ^3.4 || ^4.0 || ^5.0",
27+
"symfony/framework-bundle": "^2.8 || ^3.4 || ^4.0 || ^5.0",
28+
"symfony/finder": "^2.8 || ^3.4 || ^4.0 || ^5.0",
29+
"symfony/yaml": "^2.8 || ^3.4 || ^4.0 || ^5.0",
3030
"doctrine/doctrine-bundle": "^1.5",
3131
"doctrine/data-fixtures": "^1.1"
3232
},

src/Command/DebugTasksCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8484
}
8585

8686
$table->render();
87+
88+
return 0;
8789
}
8890
}

src/Command/RunCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
{
6868
$this->runner->runTasks();
6969
$this->scheduler->scheduleTasks();
70+
71+
return 0;
7072
}
7173
}

src/Command/ScheduleSystemTasksCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108

109109
$output->writeln('');
110110
$output->writeln('System-tasks successfully scheduled');
111+
112+
return 0;
111113
}
112114

113115
/**

src/Command/ScheduleTaskCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9494
}
9595

9696
$taskBuilder->schedule();
97+
98+
return 0;
9799
}
98100
}

src/DependencyInjection/Configuration.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Task\TaskBundle\DependencyInjection;
1313

14+
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1415
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1516
use Symfony\Component\Config\Definition\ConfigurationInterface;
1617

@@ -37,9 +38,16 @@ public function __construct(array $lockingStorageAliases)
3738
*/
3839
public function getConfigTreeBuilder()
3940
{
40-
$treeBuilder = new TreeBuilder();
41+
$treeBuilder = new TreeBuilder('task');
4142

42-
$treeBuilder->root('task')
43+
if (method_exists($treeBuilder, 'getRootNode')) {
44+
$rootNode = $treeBuilder->getRootNode();
45+
} else {
46+
// BC layer for symfony/config 4.1 and older
47+
$rootNode = $treeBuilder->root('task');
48+
}
49+
50+
$rootNode
4351
->children()
4452
->enumNode('storage')->values(['array', 'doctrine'])->defaultValue('doctrine')->end()
4553
->arrayNode('adapters')

src/Executor/ExecutionProcessFactory.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ public function __construct($consolePath, $processTimeout, $environment)
4545
*/
4646
public function create($uuid)
4747
{
48-
return $process = (new Process(
49-
implode(' ', [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment])
50-
))->setTimeout($this->processTimeout);
48+
$command = implode(' ', [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment]);
49+
50+
if (method_exists(Process::class, 'fromShellCommandline')) {
51+
$process = Process::fromShellCommandline($command);
52+
} else {
53+
$process = new Process($command);
54+
}
55+
56+
return $process->setTimeout($this->processTimeout);
5157
}
5258
}

0 commit comments

Comments
 (0)