Skip to content

Commit

Permalink
Add symfony 5 compatibility (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored Jun 16, 2020
1 parent 8f4f34c commit 10270ee
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ matrix:
- php: 7.3
env:
- STORAGE=doctrine
- php: 7.4
env:
- STORAGE=array
- php: 7.4
env:
- STORAGE=doctrine

before_install:
- if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
],
"require": {
"php": "^5.6 || ^7.0",
"php-task/php-task": "^1.3",
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0",
"symfony/expression-language": "^2.8 || ^3.4 || ^4.0",
"symfony/config": "^2.8 || ^3.4 || ^4.0",
"symfony/console": "^2.8 || ^3.4 || ^4.0",
"symfony/process": "^2.8 || ^3.4 || ^4.0",
"php-task/php-task": "^1.4",
"symfony/http-kernel": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/dependency-injection": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/expression-language": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/config": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/console": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/process": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"doctrine/orm": "^2.5"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.0",
"sebastian/comparator": "^1.2.3",
"symfony/debug": "^2.8 || ^3.4 || ^4.0",
"symfony/framework-bundle": "^2.8 || ^3.4 || ^4.0",
"symfony/finder": "^2.8 || ^3.4 || ^4.0",
"symfony/yaml": "^2.8 || ^3.4 || ^4.0",
"symfony/debug": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/framework-bundle": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/finder": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"symfony/yaml": "^2.8 || ^3.4 || ^4.0 || ^5.0",
"doctrine/doctrine-bundle": "^1.5",
"doctrine/data-fixtures": "^1.1"
},
Expand Down
2 changes: 2 additions & 0 deletions src/Command/DebugTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$table->render();

return 0;
}
}
2 changes: 2 additions & 0 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->runner->runTasks();
$this->scheduler->scheduleTasks();

return 0;
}
}
2 changes: 2 additions & 0 deletions src/Command/ScheduleSystemTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

$output->writeln('');
$output->writeln('System-tasks successfully scheduled');

return 0;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Command/ScheduleTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$taskBuilder->schedule();

return 0;
}
}
12 changes: 10 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Task\TaskBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -37,9 +38,16 @@ public function __construct(array $lockingStorageAliases)
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$treeBuilder = new TreeBuilder('task');

$treeBuilder->root('task')
if (method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$rootNode = $treeBuilder->root('task');
}

$rootNode
->children()
->enumNode('storage')->values(['array', 'doctrine'])->defaultValue('doctrine')->end()
->arrayNode('adapters')
Expand Down
12 changes: 9 additions & 3 deletions src/Executor/ExecutionProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ public function __construct($consolePath, $processTimeout, $environment)
*/
public function create($uuid)
{
return $process = (new Process(
implode(' ', [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment])
))->setTimeout($this->processTimeout);
$command = implode(' ', [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment]);

if (method_exists(Process::class, 'fromShellCommandline')) {
$process = Process::fromShellCommandline($command);
} else {
$process = new Process($command);
}

return $process->setTimeout($this->processTimeout);
}
}

0 comments on commit 10270ee

Please sign in to comment.