diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index f05ad4b..5ae5e5f 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -9,7 +9,7 @@ jobs: name: PHPCS runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e96f339..1816056 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,32 +10,30 @@ env: jobs: phpunit: name: "PHPUnit" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-24.04" strategy: matrix: php-version: - - "7.4" - - "8.1" - "8.2" - "8.3" + - "8.4" symfony-version: - "5.4.x" - "6.4.x" - - "7.0.x" + - "7.4.x" + - "8.0.x" monolog-version: - "^2.9" exclude: - - php-version: "7.4" - symfony-version: "6.4.x" - - php-version: "7.4" - symfony-version: "7.0.x" - - php-version: "8.1" - symfony-version: "7.0.x" + - php-version: "8.2" + symfony-version: "8.0.x" + - php-version: "8.3" + symfony-version: "8.0.x" steps: - name: "Checkout" - uses: "actions/checkout@v4" + uses: "actions/checkout@v7" with: fetch-depth: 2 diff --git a/DependencyInjection/RewieerTaskSchedulerExtension.php b/DependencyInjection/RewieerTaskSchedulerExtension.php index e1d5260..783ccb2 100644 --- a/DependencyInjection/RewieerTaskSchedulerExtension.php +++ b/DependencyInjection/RewieerTaskSchedulerExtension.php @@ -13,7 +13,7 @@ use Rewieer\TaskSchedulerBundle\Task\TaskInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader; class RewieerTaskSchedulerExtension extends Extension @@ -25,7 +25,7 @@ public function load(array $configs, ContainerBuilder $container): void $configuration = new Configuration(); $this->processConfiguration($configuration, $configs); - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); - $loader->load('services.xml'); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader->load('services.yaml'); } } diff --git a/Resources/config/services.xml b/Resources/config/services.xml deleted file mode 100644 index ab8c900..0000000 --- a/Resources/config/services.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Resources/config/services.yaml b/Resources/config/services.yaml new file mode 100644 index 0000000..2e1bbc8 --- /dev/null +++ b/Resources/config/services.yaml @@ -0,0 +1,35 @@ +services: + ts.event_dispatcher: + class: Rewieer\TaskSchedulerBundle\Event\EventDispatcher + public: true + + ts.scheduler: + class: Rewieer\TaskSchedulerBundle\Task\Scheduler + public: true + arguments: + - '@ts.event_dispatcher' + + ts.scheduler_logger: + class: Rewieer\TaskSchedulerBundle\Services\SchedulerLogger + public: true + arguments: + - '@logger' + tags: + - { name: 'ts.event_subscriber' } + - { name: 'monolog.logger', channel: 'scheduler' } + + ts.list_command: + class: Rewieer\TaskSchedulerBundle\Command\ListCommand + public: true + arguments: + - '@ts.scheduler' + tags: + - { name: 'console.command' } + + ts.run_command: + class: Rewieer\TaskSchedulerBundle\Command\RunCommand + public: true + arguments: + - '@ts.scheduler' + tags: + - { name: 'console.command' } diff --git a/Task/Scheduler.php b/Task/Scheduler.php index eaebb14..db054d3 100644 --- a/Task/Scheduler.php +++ b/Task/Scheduler.php @@ -17,7 +17,7 @@ class Scheduler { private EventDispatcher $dispatcher; - public function __construct(EventDispatcher $dispatcher = null) + public function __construct(?EventDispatcher $dispatcher = null) { if ($dispatcher === null) { $dispatcher = new EventDispatcher(); diff --git a/Tests/Command/ListCommandTest.php b/Tests/Command/ListCommandTest.php index f0c6707..73233e9 100644 --- a/Tests/Command/ListCommandTest.php +++ b/Tests/Command/ListCommandTest.php @@ -33,7 +33,7 @@ public function testListCommand(): void $scheduler->addTask(new TaskMock()); $application = new Application(); - $application->add(new ListCommand($scheduler)); + $application->addCommands([new ListCommand($scheduler)]); $command = $application->find('ts:list'); @@ -55,7 +55,7 @@ public function testListCommandWithOption(): void $application = new Application(); /** @var Scheduler $scheduler */ - $application->add(new ListCommand($scheduler)); + $application->addCommands([new ListCommand($scheduler)]); $command = $application->find('ts:list'); diff --git a/Tests/Command/RunCommandTest.php b/Tests/Command/RunCommandTest.php index 216c854..3d351bd 100644 --- a/Tests/Command/RunCommandTest.php +++ b/Tests/Command/RunCommandTest.php @@ -32,7 +32,7 @@ public function testRunCommand(): void $scheduler->addTask(new TaskMock()); $application = new Application(); - $application->add(new RunCommand($scheduler)); + $application->addCommands([new RunCommand($scheduler)]); $command = $application->find('ts:run'); $commandTester = new CommandTester($command); @@ -57,7 +57,7 @@ public function testRunCommandWithId(): void $scheduler->addTask($t2); $application = new Application(); - $application->add(new RunCommand($scheduler)); + $application->addCommands([new RunCommand($scheduler)]); $command = $application->find('ts:run'); $commandTester = new CommandTester($command); @@ -85,7 +85,7 @@ public function testRunCommandWithClassName(): void $scheduler->addTask($t2); $application = new Application(); - $application->add(new RunCommand($scheduler)); + $application->addCommands([new RunCommand($scheduler)]); $command = $application->find('ts:run'); $commandTester = new CommandTester($command); diff --git a/composer.json b/composer.json index 3063eb9..8e54387 100644 --- a/composer.json +++ b/composer.json @@ -9,10 +9,11 @@ }, "keywords": ["cron", "task", "scheduler", "symfony", "bundle"], "require": { - "php": "^7.4|^8.1", + "php": "^8.2", "symfony/deprecation-contracts": "^2.5|^3.4", - "symfony/framework-bundle": "^5.4|^6.4|^7.0", - "symfony/console": "^5.3|^6.4|^7.0", + "symfony/framework-bundle": "^5.4|^6.4|^7.4|^8.0", + "symfony/console": "^5.4|^6.4|^7.4|^8.0", + "symfony/yaml": "^5.4|^6.4|^7.4|^8.0", "dragonmantank/cron-expression": "^3.3" }, "require-dev": {