Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ jobs:

- php-version: '8.4'
storage: doctrine
composer-flags: --ignore-platform-reqs
- php-version: '8.4'
storage: array

- php-version: '8.5'
storage: doctrine
composer-flags: --ignore-platform-reqs
- php-version: '8.5'
storage: array
composer-flags: --ignore-platform-reqs

steps:
- name: Checkout project
uses: actions/checkout@v2
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
"require": {
"php": "^8.0",
"php-task/php-task": "^3.0.1",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/process": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/process": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"doctrine/orm": "^2.5.3 || ^3.0"
},
"require-dev": {
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
"doctrine/doctrine-bundle": "^1.5 || ^2.0",
"doctrine/data-fixtures": "^1.3.3",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/finder": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"doctrine/doctrine-bundle": "^1.5 || ^2.0 || ^3.0",
"doctrine/data-fixtures": "^1.3.3 || ^2.0",
"phpunit/phpunit": "^9.6.5 || ^10",
"phpspec/prophecy": "^1.14",
"phpspec/prophecy-phpunit": "^2.0",
"symfony/var-exporter": "^5.4 || ^6.4 || ^7.0"
"symfony/var-exporter": "^5.4 || ^6.4 || ^7.0 || ^8.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DebugTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$execution->getHandlerClass(),
$execution->getScheduleTime()->format(\DateTimeImmutable::RFC3339),
!$execution->getEndTime() ? '' : $execution->getEndTime()->format(\DateTimeImmutable::RFC3339),
(round($execution->getDuration(), 6) * 1000000) . 'ms',
(round($execution->getDuration() ?? 0.0, 6) * 1000000) . 'ms',
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/HandlerCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HandlerCompilerPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
Comment thread
alexander-schranz marked this conversation as resolved.
if (!$container->has(self::REGISTRY_ID)) {
return;
Expand Down
31 changes: 16 additions & 15 deletions src/DependencyInjection/TaskExtension.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\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
Expand All @@ -29,7 +30,7 @@
*/
class TaskExtension extends Extension implements PrependExtensionInterface
{
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
$configs = $container->getExtensionConfig($this->getAlias());
$configuration = $this->getConfiguration($configs, $container);
Expand Down Expand Up @@ -59,7 +60,7 @@ public function prepend(ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
Expand All @@ -71,15 +72,15 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('task.lock.storages.' . $key, $config['locking']['storages'][$key]);
}

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load(sprintf('storage/%s.xml', $config['storage']));
$loader->load('task_event_listener.xml');
$loader->load('scheduler.xml');
$loader->load('command.xml');
$loader->load('locking/services.xml');
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load(sprintf('storage/%s.php', $config['storage']));
$loader->load('task_event_listener.php');
$loader->load('scheduler.php');
$loader->load('command.php');
$loader->load('locking/services.php');

if ($config['run']['mode'] === 'listener') {
$loader->load('listener.xml');
$loader->load('listener.php');
}

$this->loadDoctrineAdapter($config['adapters']['doctrine'], $container);
Expand Down Expand Up @@ -118,10 +119,10 @@ private function loadDoctrineAdapter(array $config, ContainerBuilder $container)
private function loadLockingComponent(array $config, ContainerBuilder $container, LoaderInterface $loader)
{
if (!$config['enabled'] || 'null' === $config['storage']) {
return $loader->load('locking/null.xml');
return $loader->load('locking/null.php');
}

$loader->load('locking/services.xml');
$loader->load('locking/services.php');
$container->setParameter('task.lock.ttl', $config['ttl']);
}

Expand All @@ -134,7 +135,7 @@ private function loadLockingComponent(array $config, ContainerBuilder $container
*/
private function loadExecutorComponent(array $config, ContainerBuilder $container, LoaderInterface $loader)
{
$loader->load('executor/' . $config['type'] . '.xml');
$loader->load('executor/' . $config['type'] . '.php');
$container->setAlias('task.executor', 'task.executor.' . $config['type']);

if (!array_key_exists($config['type'], $config)) {
Expand Down Expand Up @@ -176,10 +177,10 @@ private function getLockingStorageAliases(ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('locking/storages.xml');
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('locking/storages.php');

return new Configuration($this->getLockingStorageAliases($container));
}
Expand Down
67 changes: 67 additions & 0 deletions src/Resources/config/command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Task\TaskBundle\Command\DebugTasksCommand;
use Task\TaskBundle\Command\ExecuteCommand;
use Task\TaskBundle\Command\RunCommand;
use Task\TaskBundle\Command\RunHandlerCommand;
use Task\TaskBundle\Command\ScheduleTaskCommand;

return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->set('task.command.run', RunCommand::class)
->public()
->args([
null,
service('task.runner'),
service('task.scheduler'),
// add entity_manager if doctrine storage is enabled
])
->tag('console.command', ['command' => 'task:run']);

$services->set('task.command.run_handler', RunHandlerCommand::class)
->public()
->args([
null,
service('task.handler.factory'),
])
->tag('console.command', ['command' => 'task:run:handler']);

$services->set('task.command.executor', ExecuteCommand::class)
->public()
->args([
null,
service('task.handler.factory'),
service('task.storage.task_execution'),
service('event_dispatcher'),
])
->tag('console.command', ['command' => 'task:execute']);

$services->set('task.command.schedule_task', ScheduleTaskCommand::class)
->public()
->args([
null,
service('task.scheduler'),
// add entity_manager if doctrine storage is enabled
])
->tag('console.command', ['command' => 'task:schedule']);

$services->set('task.command.debug_tasks', DebugTasksCommand::class)
->public()
->args([
null,
service('task.storage.task_execution'),
])
->tag('console.command', ['command' => 'debug:tasks']);
};
46 changes: 0 additions & 46 deletions src/Resources/config/command.xml

This file was deleted.

21 changes: 21 additions & 0 deletions src/Resources/config/executor/inside.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Task\Executor\InsideProcessExecutor;

return static function (ContainerConfigurator $container): void {
$container->services()
->set('task.executor.inside', InsideProcessExecutor::class)
->public()
->args([service('task.handler.factory')]);
};
10 changes: 0 additions & 10 deletions src/Resources/config/executor/inside.xml

This file was deleted.

35 changes: 35 additions & 0 deletions src/Resources/config/executor/separate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Task\TaskBundle\Executor\ExecutionProcessFactory;
use Task\TaskBundle\Executor\SeparateProcessExecutor;

return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->set('task.executor.separate', SeparateProcessExecutor::class)
->public()
->args([
service('task.handler.factory'),
service('task.storage.task_execution'),
service('task.executor.separate.process_factory'),
]);

$services->set('task.executor.separate.process_factory', ExecutionProcessFactory::class)
->public()
->args([
'%task.executor.console_path%',
'%task.executor.process_timeout%',
'%kernel.environment%',
]);
};
18 changes: 0 additions & 18 deletions src/Resources/config/executor/separate.xml

This file was deleted.

22 changes: 22 additions & 0 deletions src/Resources/config/listener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Task\TaskBundle\EventListener\RunListener;

return static function (ContainerConfigurator $container): void {
$container->services()
->set('task.event_listener.run', RunListener::class)
->public()
->args([service('task.runner')])
->tag('kernel.event_listener', ['event' => 'kernel.terminate', 'method' => 'run']);
};
12 changes: 0 additions & 12 deletions src/Resources/config/listener.xml

This file was deleted.

Loading
Loading