diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml
index 21bda153..81a2eb3b 100644
--- a/.github/workflows/analysis.yaml
+++ b/.github/workflows/analysis.yaml
@@ -16,11 +16,10 @@ jobs:
fail-fast: false
matrix:
php:
- - 8.1
- 8.2
+ - 8.3
symfony:
- - '5.4.*'
- - '6.2.*'
+ - '6.4.*'
env:
APP_ENV: test
steps:
diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml
index 155fabfb..69c0e82d 100644
--- a/.github/workflows/sylius.yaml
+++ b/.github/workflows/sylius.yaml
@@ -16,23 +16,16 @@ jobs:
fail-fast: false
matrix:
php:
- - 8.1
- 8.2
+ - 8.3
sylius:
- - 1.10.0
- 1.12.0
+ - 1.13.0
+ - 1.14.0
symfony:
- - 5.4
- - 6.2
+ - 6.4
node:
- 14.x
- exclude:
- -
- sylius: 1.10.0
- symfony: 6.2
- -
- php: '8.0'
- symfony: 6.2
env:
APP_ENV: test
package-name: synolia/sylius-scheduler-command-plugin
@@ -122,7 +115,7 @@ jobs:
run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun'
if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
-
- uses: actions/upload-artifact@v2.1.4
+ uses: actions/upload-artifact@v4
if: failure()
with:
name: logs
diff --git a/Makefile b/Makefile
index 75eddc13..95ed07ca 100644
--- a/Makefile
+++ b/Makefile
@@ -2,13 +2,14 @@
SHELL=/bin/bash
COMPOSER_ROOT=composer
TEST_DIRECTORY=tests/Application
-CONSOLE=cd tests/Application && php bin/console -e test
-COMPOSER=cd tests/Application && composer
-YARN=cd tests/Application && yarn
-
-SYLIUS_VERSION=1.12.0
-SYMFONY_VERSION=6.1
-PHP_VERSION=8.1
+INSTALL_DIRECTORY=install/Application
+CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test
+COMPOSER=cd ${TEST_DIRECTORY} && composer
+YARN=cd ${TEST_DIRECTORY} && yarn
+
+SYLIUS_VERSION=1.14.0
+SYMFONY_VERSION=6.4
+PHP_VERSION=8.2
PLUGIN_NAME=synolia/sylius-scheduler-command-plugin
###
@@ -19,10 +20,10 @@ install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.0] [SYMFONY_VER
.PHONY: install
reset: ## Remove dependencies
-ifneq ("$(wildcard tests/Application/bin/console)","")
+ifneq ("$(wildcard ${TEST_DIRECTORY}/bin/console)","")
${CONSOLE} doctrine:database:drop --force --if-exists || true
endif
- rm -rf tests/Application
+ rm -rf ${TEST_DIRECTORY}
.PHONY: reset
phpunit: phpunit-configure phpunit-run ## Run PHPUnit
@@ -62,7 +63,7 @@ install-plugin:
${COMPOSER} config minimum-stability "dev"
${COMPOSER} config prefer-stable true
${COMPOSER} req ${PLUGIN_NAME}:* --prefer-source --no-scripts
- cp -r install/Application tests
+ cp -r ${INSTALL_DIRECTORY} tests
install-sylius:
${CONSOLE} doctrine:database:create -n
@@ -97,7 +98,7 @@ grumphp: ## Run GrumPHP
vendor/bin/grumphp run
help: SHELL=/bin/bash
-help: ## Dislay this help
+help: ## Display this help
@IFS=$$'\n'; for line in `grep -h -E '^[a-zA-Z_#-]+:?.*?##.*$$' $(MAKEFILE_LIST)`; do if [ "$${line:0:2}" = "##" ]; then \
echo $$line | awk 'BEGIN {FS = "## "}; {printf "\033[33m %s\033[0m\n", $$2}'; else \
echo $$line | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m%s\n", $$1, $$2}'; fi; \
diff --git a/README.md b/README.md
index e34db537..e92c3d93 100644
--- a/README.md
+++ b/README.md
@@ -41,8 +41,8 @@
| | Version |
|:-------|:--------|
-| PHP | ^8.0 |
-| Sylius | ^1.10 |
+| PHP | ^8.2 |
+| Sylius | ^1.12 |
## Installation
diff --git a/composer.json b/composer.json
index fc5d0937..54f720d2 100644
--- a/composer.json
+++ b/composer.json
@@ -10,54 +10,54 @@
"description": "Scheduler Command Plugin.",
"license": "MIT",
"require": {
- "php": "^8.0",
+ "php": "^8.2",
"ext-json": "*",
"ext-intl": "*",
- "dragonmantank/cron-expression": "^3.0",
- "sylius/sylius": "^1.10",
+ "dragonmantank/cron-expression": "^3.4",
+ "sylius/sylius": "^1.12",
"symfony/framework-bundle": "^5.4|^6.0",
- "symfony/lock": "^5.4|^6.0",
+ "symfony/lock": "^6.4",
"symfony/polyfill-intl-icu": "^1.26",
- "symfony/process": "^5.4|^6.0",
- "symfony/service-contracts": "^1.1|^2.0|^3.0",
- "webmozart/assert": "^1.10"
+ "symfony/process": "^6.4",
+ "symfony/service-contracts": "^3.5",
+ "webmozart/assert": "^1.11"
},
"require-dev": {
- "behat/behat": "3.12.0",
- "behat/mink-selenium2-driver": "1.6.0",
- "dmore/behat-chrome-extension": "1.4.0",
- "dmore/chrome-mink-driver": "2.9.0",
- "friends-of-behat/mink": "1.10.0",
- "friends-of-behat/mink-browserkit-driver": "1.6.1",
- "friends-of-behat/mink-debug-extension": "2.1.0",
- "friends-of-behat/mink-extension": "2.7.2",
- "friends-of-behat/page-object-extension": "0.3.2",
- "friends-of-behat/suite-settings-extension": "1.1.0",
- "friends-of-behat/symfony-extension": "2.4.0",
- "friends-of-behat/variadic-extension": "1.5.0",
- "friendsoftwig/twigcs": "6.0.0",
- "j13k/yaml-lint": "1.1.4",
- "php-parallel-lint/php-parallel-lint": "1.3.2",
- "phpmd/phpmd": "2.13.0",
- "phpro/grumphp": "1.15.0",
- "phpspec/phpspec": "7.3.0",
- "phpstan/extension-installer": "1.2.0",
- "phpstan/phpstan": "1.9.5",
- "phpstan/phpstan-doctrine": "1.3.28",
- "phpstan/phpstan-strict-rules": "1.4.4",
- "phpstan/phpstan-webmozart-assert": "1.2.2",
- "phpunit/phpunit": "9.5.27",
- "rector/rector": "^0.15.2",
- "sebastian/phpcpd": "6.0.3",
- "seld/jsonlint": "1.9.0",
- "slevomat/coding-standard": "8.7.1",
- "sylius-labs/coding-standard": "4.3.0",
- "symfony/browser-kit": "6.0.11",
- "symfony/debug-bundle": "6.0.11",
- "symfony/dotenv": "6.0.5",
- "symfony/intl": "6.0.15",
- "symfony/web-profiler-bundle": "6.0.17",
- "symplify/easy-coding-standard": "11.1.32.72"
+ "behat/behat": "^3.12",
+ "behat/mink-selenium2-driver": "^1.6",
+ "dmore/behat-chrome-extension": "^1.4",
+ "dmore/chrome-mink-driver": "^2.9",
+ "friends-of-behat/mink": "^1.10",
+ "friends-of-behat/mink-browserkit-driver": "^1.6",
+ "friends-of-behat/mink-debug-extension": "^2.1",
+ "friends-of-behat/mink-extension": "^2.7",
+ "friends-of-behat/page-object-extension": "^0.3",
+ "friends-of-behat/suite-settings-extension": "^1.1",
+ "friends-of-behat/symfony-extension": "^2.4",
+ "friends-of-behat/variadic-extension": "^1.5",
+ "friendsoftwig/twigcs": "6.4.0",
+ "j13k/yaml-lint": "^1.1",
+ "php-parallel-lint/php-parallel-lint": "^1.4",
+ "phpmd/phpmd": "^2.15.0",
+ "phpro/grumphp": "^2.9",
+ "phpspec/phpspec": "^7.3",
+ "phpstan/extension-installer": "^1.3",
+ "phpstan/phpstan": "^2.0",
+ "phpstan/phpstan-doctrine": "^2.0",
+ "phpstan/phpstan-strict-rules": "^2.0",
+ "phpstan/phpstan-webmozart-assert": "^2.0",
+ "phpunit/phpunit": "^9.5",
+ "rector/rector": "^2.0",
+ "seld/jsonlint": "^1.11",
+ "slevomat/coding-standard": "^8.7",
+ "squizlabs/php_codesniffer": "^3.11",
+ "sylius-labs/coding-standard": "^4.3",
+ "symfony/browser-kit": "^6.4",
+ "symfony/debug-bundle": "^6.4",
+ "symfony/dotenv": "^6.4",
+ "symfony/intl": "^6.4",
+ "symfony/web-profiler-bundle": "^6.4",
+ "symplify/easy-coding-standard": "^12.5"
},
"suggest": {
"lorisleiva/cron-translator": "Allow showing humanized and translated cron expression."
diff --git a/config/config.yaml b/config/config.yaml
new file mode 100644
index 00000000..e20caa8e
--- /dev/null
+++ b/config/config.yaml
@@ -0,0 +1,5 @@
+imports:
+ - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/resources.yaml" }
+ - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/grids.yaml" }
+ - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/services.yaml" }
+ - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/ui.yaml" }
diff --git a/src/Resources/config/grids.yaml b/config/grids.yaml
similarity index 100%
rename from src/Resources/config/grids.yaml
rename to config/grids.yaml
diff --git a/src/Resources/config/resources.yaml b/config/resources.yaml
similarity index 100%
rename from src/Resources/config/resources.yaml
rename to config/resources.yaml
diff --git a/config/routes/admin/attributes.yaml b/config/routes/admin/attributes.yaml
new file mode 100644
index 00000000..ff6564fd
--- /dev/null
+++ b/config/routes/admin/attributes.yaml
@@ -0,0 +1,5 @@
+controllers:
+ resource:
+ path: ../../../src/Controller/
+ namespace: Synolia\SyliusSchedulerCommandPlugin\Controller
+ type: attribute
\ No newline at end of file
diff --git a/config/routes/admin/routing.yaml b/config/routes/admin/routing.yaml
new file mode 100644
index 00000000..1d484ac2
--- /dev/null
+++ b/config/routes/admin/routing.yaml
@@ -0,0 +1,25 @@
+synolia_admin_commands:
+ resource: |
+ alias: synolia.command
+ templates: "@SyliusAdmin\\Crud"
+ section: admin
+ grid: synolia_admin_commands
+ except: ['show']
+ permission: true
+ vars:
+ index:
+ icon: 'box'
+ type: sylius.resource
+
+synolia_admin_scheduled_commands:
+ resource: |
+ alias: synolia.scheduled_command
+ templates: "@SyliusAdmin\\Crud"
+ section: admin
+ grid: synolia_admin_scheduled_commands
+ except: ['update', 'show']
+ permission: true
+ vars:
+ index:
+ icon: 'box'
+ type: sylius.resource
\ No newline at end of file
diff --git a/config/services.yaml b/config/services.yaml
new file mode 100644
index 00000000..dfc112f3
--- /dev/null
+++ b/config/services.yaml
@@ -0,0 +1,13 @@
+parameters:
+ env(SYNOLIA_SCHEDULER_PLUGIN_PING_INTERVAL): 300
+ env(SYNOLIA_SCHEDULER_PLUGIN_KEEP_ALIVE): true
+ env(SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR): '%kernel.logs_dir%'
+
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Synolia\SyliusSchedulerCommandPlugin\:
+ resource: '../src/*'
+ exclude: '../src/{Entity,SynoliaSyliusSchedulerCommandPlugin.php}'
diff --git a/src/Resources/config/ui.yaml b/config/ui.yaml
similarity index 100%
rename from src/Resources/config/ui.yaml
rename to config/ui.yaml
diff --git a/src/Resources/config/validation.yaml b/config/validation.yaml
similarity index 100%
rename from src/Resources/config/validation.yaml
rename to config/validation.yaml
diff --git a/grumphp.yml b/grumphp.yml
index cd5f8b0f..f6bb2fc7 100644
--- a/grumphp.yml
+++ b/grumphp.yml
@@ -5,28 +5,18 @@ grumphp:
tasks:
composer:
no_check_all: true
- git_blacklist:
- keywords:
- - 'var_dump'
- - 'dump\('
- - 'print_r'
- - 'die\('
- - 'console\.'
- triggered_by: [php, twig, js]
jsonlint:
detect_key_conflicts: true
- phpcpd:
- directory:
- - src
phplint:
- exclude: ['vendor']
+ exclude: ['vendor', 'tests/Application/*']
triggered_by: ['php']
phpmd:
+ exclude: ['migrations']
ruleset: ['ruleset/.php_md.xml']
phpstan:
level: ~
configuration: 'ruleset/phpstan.neon'
- securitychecker_symfony: ~
+ use_grumphp_paths: false
yamllint:
parse_custom_tags: true
ecs:
@@ -35,3 +25,10 @@ grumphp:
twigcs:
path: 'src/'
severity: error
+ phpcs:
+ standard: "ruleset"
+ warning_severity: 0
+ whitelist_patterns:
+ - 'src'
+ exclude:
+ - 'PSR12.Files.FileHeader'
\ No newline at end of file
diff --git a/install/Application/config/packages/sylius_scheduler_command.yaml b/install/Application/config/packages/sylius_scheduler_command.yaml
index a0afbda5..42c16364 100644
--- a/install/Application/config/packages/sylius_scheduler_command.yaml
+++ b/install/Application/config/packages/sylius_scheduler_command.yaml
@@ -1,2 +1,2 @@
imports:
- - { resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/config.yaml" }
+ - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/config.yaml" }
diff --git a/install/Application/config/routes/sylius_scheduler_command.yaml b/install/Application/config/routes/sylius_scheduler_command.yaml
index 19961fb5..544777b4 100644
--- a/install/Application/config/routes/sylius_scheduler_command.yaml
+++ b/install/Application/config/routes/sylius_scheduler_command.yaml
@@ -1,3 +1,3 @@
synolia_scheduled_command:
- resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/admin_routing.yaml"
+ resource: "@SynoliaSyliusSchedulerCommandPlugin/config/routes/admin/**.yaml"
prefix: '/%sylius_admin.path_name%'
diff --git a/src/Migrations/Version20200107151826.php b/migrations/Version20200107151826.php
similarity index 100%
rename from src/Migrations/Version20200107151826.php
rename to migrations/Version20200107151826.php
diff --git a/src/Migrations/Version20210810054537.php b/migrations/Version20210810054537.php
similarity index 100%
rename from src/Migrations/Version20210810054537.php
rename to migrations/Version20210810054537.php
diff --git a/src/Migrations/Version20210828114655.php b/migrations/Version20210828114655.php
similarity index 100%
rename from src/Migrations/Version20210828114655.php
rename to migrations/Version20210828114655.php
diff --git a/src/Migrations/Version20211224090032.php b/migrations/Version20211224090032.php
similarity index 100%
rename from src/Migrations/Version20211224090032.php
rename to migrations/Version20211224090032.php
diff --git a/src/Resources/public/column/index.js b/public/column/index.js
similarity index 100%
rename from src/Resources/public/column/index.js
rename to public/column/index.js
diff --git a/src/Resources/public/controller/index.css b/public/controller/index.css
similarity index 100%
rename from src/Resources/public/controller/index.css
rename to public/controller/index.css
diff --git a/src/Resources/public/controller/index.js b/public/controller/index.js
similarity index 100%
rename from src/Resources/public/controller/index.js
rename to public/controller/index.js
diff --git a/ruleset/phpstan.neon b/ruleset/phpstan.neon
index 0366d85e..27faa563 100644
--- a/ruleset/phpstan.neon
+++ b/ruleset/phpstan.neon
@@ -1,20 +1,17 @@
parameters:
level: 8
reportUnmatchedIgnoredErrors: false
- checkMissingIterableValueType: false
- checkGenericClassInNonGenericObjectType: false
+ paths:
+ - ../src
excludePaths:
- # Makes PHPStan crash
- - ../src/DependencyInjection/Configuration.php
- - ../src/Migrations/
-
- # Test dependencies
+ - ../src/DependencyInjection/Configuration.php?
+ - ../migrations
- ../tests
-
- # PHPSpec
- ../spec
ignoreErrors:
+ - identifier: missingType.iterableValue
+ - identifier: missingType.generics
- '/Parameter #1 \$configuration of method Symfony\Component\DependencyInjection\Extension\Extension::processConfiguration\(\) expects Symfony\Component\Config\Definition\ConfigurationInterface, Symfony\Component\Config\Definition\ConfigurationInterface\|null given./'
- '#^Method [\w\\]+Type::render\(\) has parameter \$[\w]+ with no typehint specified.$#'
- '#Variable method call on Synolia\\SyliusSchedulerCommandPlugin\\Entity\\ScheduledCommand.#'
diff --git a/ruleset/rector.php b/ruleset/rector.php
index 635e3267..e793608a 100644
--- a/ruleset/rector.php
+++ b/ruleset/rector.php
@@ -3,18 +3,30 @@
declare(strict_types=1);
use Rector\Config\RectorConfig;
-use Rector\Set\ValueObject\LevelSetList;
+use Rector\Set\ValueObject\SetList;
+use Rector\Symfony\Set\SymfonySetList;
-return static function (RectorConfig $rectorConfig): void {
- $rectorConfig->paths([
- dirname(__DIR__) . '/src',
- dirname(__DIR__) . '/spec',
- dirname(__DIR__) . '/tests/Behat',
- dirname(__DIR__) . '/tests/PHPUnit',
+return RectorConfig::configure()
+ ->withPaths([
+ \dirname(__DIR__, 1) . '/src',
+ \dirname(__DIR__, 1) . '/tests/PHPUnit',
+ ])
+ ->withPHPStanConfigs([__DIR__ . '/phpstan.neon'])
+ ->withPhpSets(php82: true)
+ ->withAttributesSets(symfony: true, doctrine: true)
+ ->withPreparedSets(
+ deadCode: true,
+ codeQuality: true,
+ doctrineCodeQuality: true,
+ symfonyConfigs: true,
+ )
+ ->withTypeCoverageLevel(0)
+ ->withSets([
+ SymfonySetList::SYMFONY_60,
+ SymfonySetList::SYMFONY_61,
+ SymfonySetList::SYMFONY_62,
+ SymfonySetList::SYMFONY_63,
+ SymfonySetList::SYMFONY_64,
+ SetList::CODE_QUALITY,
+ SetList::DEAD_CODE,
]);
-
- $rectorConfig->sets([
- LevelSetList::UP_TO_PHP_74,
- LevelSetList::UP_TO_PHP_80
- ]);
-};
diff --git a/ruleset/ruleset.xml b/ruleset/ruleset.xml
new file mode 100644
index 00000000..3008a56f
--- /dev/null
+++ b/ruleset/ruleset.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Action/CleanLogAction.php b/src/Action/CleanLogAction.php
index 3b1b28ba..f2ef5a1c 100644
--- a/src/Action/CleanLogAction.php
+++ b/src/Action/CleanLogAction.php
@@ -7,12 +7,14 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommand;
use Synolia\SyliusSchedulerCommandPlugin\Repository\CommandRepository;
final class CleanLogAction extends AbstractController
{
+ #[Route('/scheduled-commands/{command}/clean-log', name: 'sylius_admin_scheduler_empty_log_file', defaults: ['_sylius' => ['permission' => true]], methods: ['GET'])]
public function __invoke(
TranslatorInterface $translator,
CommandRepository $commandRepository,
diff --git a/src/Checker/EveryMinuteIsDueChecker.php b/src/Checker/EveryMinuteIsDueChecker.php
index 1b309b1f..a8649b07 100644
--- a/src/Checker/EveryMinuteIsDueChecker.php
+++ b/src/Checker/EveryMinuteIsDueChecker.php
@@ -5,25 +5,29 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Checker;
use Cron\CronExpression;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Synolia\SyliusSchedulerCommandPlugin\Components\Exceptions\Checker\IsNotDueException;
use Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface;
/**
* This checker only works if current date/time is checked every minutes
*/
+#[AutoconfigureTag(IsDueCheckerInterface::TAG_ID)]
class EveryMinuteIsDueChecker implements IsDueCheckerInterface
{
+ private const PRIORITY = 0;
+
public static function getDefaultPriority(): int
{
- return 0;
+ return self::PRIORITY;
}
/**
- * @throws \Synolia\SyliusSchedulerCommandPlugin\Components\Exceptions\Checker\IsNotDueException
+ * @throws IsNotDueException
*/
public function isDue(CommandInterface $command, ?\DateTimeInterface $dateTime = null): bool
{
- if (null === $dateTime) {
+ if (!$dateTime instanceof \DateTimeInterface) {
$dateTime = new \DateTime();
}
diff --git a/src/Checker/SoftLimitThresholdIsDueChecker.php b/src/Checker/SoftLimitThresholdIsDueChecker.php
index f65471b8..a5cfa542 100644
--- a/src/Checker/SoftLimitThresholdIsDueChecker.php
+++ b/src/Checker/SoftLimitThresholdIsDueChecker.php
@@ -5,23 +5,27 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Checker;
use Cron\CronExpression;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Synolia\SyliusSchedulerCommandPlugin\Components\Exceptions\Checker\IsNotDueException;
use Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepositoryInterface;
+#[AutoconfigureTag(IsDueCheckerInterface::TAG_ID)]
class SoftLimitThresholdIsDueChecker implements IsDueCheckerInterface
{
+ private const PRIORITY = -100;
+
public static function getDefaultPriority(): int
{
- return -100;
+ return self::PRIORITY;
}
public function __construct(
- private ScheduledCommandRepositoryInterface $scheduledCommandRepository,
+ private readonly ScheduledCommandRepositoryInterface $scheduledCommandRepository,
/**
* Threshold in minutes
*/
- private int $threshold = 5,
+ private readonly int $threshold = 5,
) {
}
@@ -30,7 +34,7 @@ public function __construct(
*/
public function isDue(CommandInterface $command, ?\DateTimeInterface $dateTime = null): bool
{
- if (null === $dateTime) {
+ if (!$dateTime instanceof \DateTimeInterface) {
$dateTime = new \DateTime();
}
@@ -45,7 +49,7 @@ public function isDue(CommandInterface $command, ?\DateTimeInterface $dateTime =
$lastCreatedScheduledCommand = $this->scheduledCommandRepository->findLastCreatedCommand($command);
// if never, do my command is valid for the least "threshold" minutes
- if ($lastCreatedScheduledCommand === null) {
+ if (!$lastCreatedScheduledCommand instanceof \Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface) {
if ($dateTime->getTimestamp() >= $previousRunDate->getTimestamp() && $dateTime->getTimestamp() <= $previousRunDateThreshold->getTimestamp()) {
return true;
}
@@ -54,13 +58,16 @@ public function isDue(CommandInterface $command, ?\DateTimeInterface $dateTime =
}
// check if last command has been started since scheduled datetime +0..5 minutes
- if ($lastCreatedScheduledCommand->getCreatedAt()->getTimestamp() >= $previousRunDate->getTimestamp() &&
+ if (
+ $lastCreatedScheduledCommand->getCreatedAt()->getTimestamp() >= $previousRunDate->getTimestamp() &&
$lastCreatedScheduledCommand->getCreatedAt()->getTimestamp() <= $previousRunDateThreshold->getTimestamp() &&
- $dateTime->getTimestamp() <= $previousRunDateThreshold->getTimestamp()) {
+ $dateTime->getTimestamp() <= $previousRunDateThreshold->getTimestamp()
+ ) {
throw new IsNotDueException();
}
- if ($dateTime->getTimestamp() >= $previousRunDate->getTimestamp() &&
+ if (
+ $dateTime->getTimestamp() >= $previousRunDate->getTimestamp() &&
$dateTime->getTimestamp() <= $previousRunDateThreshold->getTimestamp()
) {
return true;
diff --git a/src/Command/PurgeScheduledCommandCommand.php b/src/Command/PurgeScheduledCommandCommand.php
index 971a8b07..28c29d05 100644
--- a/src/Command/PurgeScheduledCommandCommand.php
+++ b/src/Command/PurgeScheduledCommandCommand.php
@@ -6,6 +6,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -15,6 +16,7 @@
use Synolia\SyliusSchedulerCommandPlugin\Enum\ScheduledCommandStateEnum;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepositoryInterface;
+#[AsCommand(name: 'synolia:scheduler:purge-history', description: 'Purge scheduled command history greater than {X} days old.')]
class PurgeScheduledCommandCommand extends Command
{
private const DEFAULT_PURGE_PERIODE_IN_DAYS = 3;
@@ -23,14 +25,12 @@ class PurgeScheduledCommandCommand extends Command
private const DEFAULT_BATCH = 100;
- protected static $defaultName = 'synolia:scheduler:purge-history';
-
private SymfonyStyle $io;
public function __construct(
- private EntityManagerInterface $entityManager,
- private ScheduledCommandRepositoryInterface $scheduledCommandRepository,
- private LoggerInterface $logger,
+ private readonly EntityManagerInterface $entityManager,
+ private readonly ScheduledCommandRepositoryInterface $scheduledCommandRepository,
+ private readonly LoggerInterface $logger,
?string $name = null,
) {
parent::__construct($name);
@@ -39,7 +39,6 @@ public function __construct(
protected function configure(): void
{
$this
- ->setDescription('Purge scheduled command history greater than {X} days old.')
->addOption('all', 'p', InputOption::VALUE_NONE, 'Remove all schedules with specified state (default is finished).')
->addOption('days', 'd', InputOption::VALUE_OPTIONAL, '{X} days old', self::DEFAULT_PURGE_PERIODE_IN_DAYS)
->addOption('state', 's', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'State of scheduled history to be cleaned', [self::DEFAULT_STATE])
@@ -47,7 +46,7 @@ protected function configure(): void
;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->io = new SymfonyStyle($input, $output);
diff --git a/src/Command/SynoliaSchedulerRunCommand.php b/src/Command/SynoliaSchedulerRunCommand.php
index c3d551a0..6d4ac231 100644
--- a/src/Command/SynoliaSchedulerRunCommand.php
+++ b/src/Command/SynoliaSchedulerRunCommand.php
@@ -8,6 +8,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Command\LockableTrait;
use Symfony\Component\Console\Input\InputInterface;
@@ -23,12 +24,11 @@
use Synolia\SyliusSchedulerCommandPlugin\Runner\ScheduleCommandRunnerInterface;
use Synolia\SyliusSchedulerCommandPlugin\Voter\IsDueVoterInterface;
+#[AsCommand(name: 'synolia:scheduler-run', description: 'Execute scheduled commands')]
final class SynoliaSchedulerRunCommand extends Command
{
use LockableTrait;
- protected static $defaultName = 'synolia:scheduler-run';
-
public function __construct(
private EntityManagerInterface $entityManager,
private ScheduleCommandRunnerInterface $scheduleCommandRunner,
@@ -38,12 +38,11 @@ public function __construct(
private IsDueVoterInterface $isDueVoter,
private LoggerInterface $logger,
) {
- parent::__construct(static::$defaultName);
+ parent::__construct();
}
protected function configure(): void
{
- $this->setDescription('Execute scheduled commands');
$this->addOption('id', 'i', InputOption::VALUE_OPTIONAL, 'Command ID');
}
diff --git a/src/Controller/DownloadController.php b/src/Controller/DownloadController.php
index d8e31dbf..b802d3d9 100644
--- a/src/Controller/DownloadController.php
+++ b/src/Controller/DownloadController.php
@@ -5,22 +5,27 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Attribute\Route;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepositoryInterface;
final class DownloadController extends AbstractController
{
public function __construct(
- private ScheduledCommandRepositoryInterface $scheduledCommandRepository,
- private string $logsDir,
+ private readonly ScheduledCommandRepositoryInterface $scheduledCommandRepository,
+ #[Autowire(param: 'env(string:SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR)')]
+ private readonly string $logsDir,
) {
}
+ #[Route('/scheduled-commands/download/logfile/{command}', name: 'download_schedule_log_file', defaults: ['_sylius' => ['permission' => true]], methods: ['GET'])]
public function downloadLogFile(string $command): Response
{
$scheduleCommand = $this->scheduledCommandRepository->find($command);
- if (null === $scheduleCommand ||
+ if (
+ null === $scheduleCommand ||
null === $scheduleCommand->getLogFile()
) {
return new Response('', Response::HTTP_NOT_FOUND);
diff --git a/src/Controller/EmptyLogsController.php b/src/Controller/EmptyLogsController.php
index 7e155ce4..95b83709 100644
--- a/src/Controller/EmptyLogsController.php
+++ b/src/Controller/EmptyLogsController.php
@@ -5,20 +5,24 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepositoryInterface;
final class EmptyLogsController extends AbstractController
{
public function __construct(
- private ScheduledCommandRepositoryInterface $scheduledCommandRepository,
- private TranslatorInterface $translator,
- private string $logsDir,
+ private readonly ScheduledCommandRepositoryInterface $scheduledCommandRepository,
+ private readonly TranslatorInterface $translator,
+ #[Autowire(env: 'string:SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR')]
+ private readonly string $logsDir,
) {
}
+ #[Route('/scheduled-commands/empty-logs', name: 'sylius_admin_scheduler_empty_logs', defaults: ['_sylius' => ['permission' => true, 'repository' => ['method' => 'findById', 'arguments' => ['$ids']]]], methods: ['GET|PUT'])]
public function emptyLogs(Request $request): Response
{
$commandIds = $request->get('ids');
diff --git a/src/Controller/LogViewerController.php b/src/Controller/LogViewerController.php
index 57b8eb39..c73d1651 100644
--- a/src/Controller/LogViewerController.php
+++ b/src/Controller/LogViewerController.php
@@ -5,9 +5,11 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Synolia\SyliusSchedulerCommandPlugin\DataRetriever\LogDataRetriever;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepositoryInterface;
@@ -15,26 +17,29 @@
final class LogViewerController extends AbstractController
{
public function __construct(
- private ScheduledCommandRepositoryInterface $scheduledCommandRepository,
- private LogDataRetriever $logDataRetriever,
- private TranslatorInterface $translator,
- private string $logsDir,
+ private readonly ScheduledCommandRepositoryInterface $scheduledCommandRepository,
+ private readonly LogDataRetriever $logDataRetriever,
+ private readonly TranslatorInterface $translator,
+ #[Autowire(param: 'kernel.logs_dir')]
+ private readonly string $logsDir,
/** @var int The time in milliseconds between two AJAX requests to the server. */
- private int $updateTime = 2000,
+ private readonly int $updateTime = 2000,
) {
}
+ #[Route('/scheduled-commands/{command}/get-log.json', name: 'sylius_admin_scheduler_get_log_file', defaults: ['_sylius' => ['permission' => true]], methods: ['GET'])]
public function getLogs(Request $request, string $command): JsonResponse
{
$scheduleCommand = $this->scheduledCommandRepository->find($command);
- if (null === $scheduleCommand ||
+ if (
+ null === $scheduleCommand ||
null === $scheduleCommand->getLogFile()
) {
return new JsonResponse('', Response::HTTP_NO_CONTENT);
}
- if (true === (bool) $request->get('refresh')) {
+ if ((bool) $request->get('refresh')) {
$result = $this->logDataRetriever->getLog(
$this->logsDir . \DIRECTORY_SEPARATOR . $scheduleCommand->getLogFile(),
(int) $request->get('lastsize'),
@@ -56,11 +61,13 @@ public function getLogs(Request $request, string $command): JsonResponse
]);
}
+ #[Route('/scheduled-commands/{command}/view-log', name: 'sylius_admin_scheduler_view_log_file', defaults: ['_sylius' => ['permission' => true]], methods: ['GET'])]
public function show(string $command): Response
{
$scheduledCommand = $this->scheduledCommandRepository->find($command);
- if (null === $scheduledCommand ||
+ if (
+ null === $scheduledCommand ||
null === $scheduledCommand->getLogFile()
) {
$this->addFlash('error', $this->translator->trans('sylius.ui.does_not_exists_or_missing_log_file'));
diff --git a/src/Controller/ScheduledCommandExecuteImmediateController.php b/src/Controller/ScheduledCommandExecuteImmediateController.php
index 9947bc8f..477c0cde 100644
--- a/src/Controller/ScheduledCommandExecuteImmediateController.php
+++ b/src/Controller/ScheduledCommandExecuteImmediateController.php
@@ -5,9 +5,11 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Process\Process;
+use Symfony\Component\Routing\Attribute\Route;
use Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface;
use Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface;
use Synolia\SyliusSchedulerCommandPlugin\Planner\ScheduledCommandPlannerInterface;
@@ -17,12 +19,14 @@
class ScheduledCommandExecuteImmediateController extends AbstractController
{
public function __construct(
- private ScheduledCommandPlannerInterface $scheduledCommandPlanner,
- private CommandRepositoryInterface $commandRepository,
- private string $projectDir,
+ private readonly ScheduledCommandPlannerInterface $scheduledCommandPlanner,
+ private readonly CommandRepositoryInterface $commandRepository,
+ #[Autowire(param: 'kernel.project_dir')]
+ private readonly string $projectDir,
) {
}
+ #[Route('/scheduled-commands/execute/immediate/{commandId}', name: 'execute_immediate_schedule', defaults: ['_sylius' => ['permission' => true]], methods: ['GET|PUT'])]
public function executeImmediate(Request $request, string $commandId): Response
{
$command = $this->commandRepository->find($commandId);
diff --git a/src/DependencyInjection/SynoliaSyliusSchedulerCommandExtension.php b/src/DependencyInjection/SynoliaSyliusSchedulerCommandExtension.php
index 246e633f..6ad919fa 100644
--- a/src/DependencyInjection/SynoliaSyliusSchedulerCommandExtension.php
+++ b/src/DependencyInjection/SynoliaSyliusSchedulerCommandExtension.php
@@ -16,11 +16,11 @@ final class SynoliaSyliusSchedulerCommandExtension extends Extension implements
use PrependDoctrineMigrationsTrait;
/**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @inheritDoc
*/
- public function load(array $config, ContainerBuilder $container): void
+ public function load(array $configs, ContainerBuilder $container): void
{
- $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
+ $loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__, 2) . '/config'));
$loader->load('services.yaml');
}
@@ -39,7 +39,7 @@ protected function getMigrationsNamespace(): string
protected function getMigrationsDirectory(): string
{
- return '@SynoliaSyliusSchedulerCommandPlugin/Migrations';
+ return '@SynoliaSyliusSchedulerCommandPlugin/migrations';
}
protected function getNamespacesOfMigrationsExecutedBefore(): array
diff --git a/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php b/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php
index bf5ce2ea..b1e826a8 100644
--- a/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php
+++ b/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php
@@ -7,12 +7,17 @@
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface;
+#[AutoconfigureTag(attributes: ['name' => 'doctrine.event_subscriber', 'connection' => 'default'])]
class ScheduledCommandPostRemoveEvent implements EventSubscriber
{
- public function __construct(private string $logsDir)
- {
+ public function __construct(
+ #[Autowire(param: 'kernel.logs_dir')]
+ private readonly string $logsDir,
+ ) {
}
public function getSubscribedEvents(): array
diff --git a/src/Entity/Command.php b/src/Entity/Command.php
index ab441199..2f71cc45 100644
--- a/src/Entity/Command.php
+++ b/src/Entity/Command.php
@@ -10,80 +10,55 @@
use Doctrine\ORM\Mapping as ORM;
use Synolia\SyliusSchedulerCommandPlugin\Repository\CommandRepository;
-/**
- * @ORM\Entity(repositoryClass="Synolia\SyliusSchedulerCommandPlugin\Repository\CommandRepository")
- * @ORM\Table("synolia_commands")
- */
#[ORM\Entity(repositoryClass: CommandRepository::class)]
#[ORM\Table(name: 'synolia_commands')]
class Command implements CommandInterface
{
- /**
- * @var int|null
- *
- * @ORM\Id()
- * @ORM\GeneratedValue()
- * @ORM\Column(type="integer")
- */
+ /** @var int|null */
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;
- /** @ORM\Column(type="string") */
#[ORM\Column(type: Types::STRING)]
private string $name = '';
- /** @ORM\Column(type="string") */
#[ORM\Column(type: Types::STRING)]
private string $command = '';
- /** @ORM\Column(type="string", nullable=true) */
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $arguments = null;
- /**
- * @see https://abunchofutils.com/u/computing/cron-format-helper/
- *
- * @ORM\Column(type="string")
- */
+ /** @see https://abunchofutils.com/u/computing/cron-format-helper/ */
#[ORM\Column(type: Types::STRING)]
private string $cronExpression = '* * * * *';
/**
* Log's file name prefix (without path), followed by a time stamp of the execution
- *
- * @ORM\Column(type="string", nullable=true)
*/
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $logFilePrefix = null;
- /** @ORM\Column(type="integer") */
#[ORM\Column(type: Types::INTEGER)]
private int $priority = 0;
/**
- * If true, command will be execute next time regardless cron expression
- *
- * @ORM\Column(type="boolean")
+ * If true, command will be executed next time regardless cron expression
*/
#[ORM\Column(type: Types::BOOLEAN)]
private bool $executeImmediately = false;
- /** @ORM\Column(type="boolean") */
#[ORM\Column(type: Types::BOOLEAN)]
private bool $enabled = true;
- /** @ORM\Column(type="integer", nullable=true) */
#[ORM\Column(type: Types::INTEGER, nullable: true)]
private ?int $timeout = null;
- /** @ORM\Column(type="integer", nullable=true) */
#[ORM\Column(type: Types::INTEGER, nullable: true)]
private ?int $idleTimeout = null;
- /** @ORM\OneToMany(targetEntity="Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface", mappedBy="owner") */
- #[ORM\OneToMany(targetEntity: ScheduledCommandInterface::class, mappedBy: 'owner')]
+ /** @var Collection */
+ #[ORM\OneToMany(mappedBy: 'owner', targetEntity: ScheduledCommandInterface::class)]
private Collection $scheduledCommands;
public function __construct()
@@ -192,9 +167,6 @@ public function setEnabled(bool $enabled): self
return $this;
}
- /**
- * @return Collection|\Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface[]
- */
public function getScheduledCommands(): Collection
{
return $this->scheduledCommands;
diff --git a/src/Entity/CommandInterface.php b/src/Entity/CommandInterface.php
index eb9e73d8..91675dda 100644
--- a/src/Entity/CommandInterface.php
+++ b/src/Entity/CommandInterface.php
@@ -51,9 +51,6 @@ public function getIdleTimeout(): ?int;
public function setIdleTimeout(?int $timeout): self;
- /**
- * @return Collection|\Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface[]
- */
public function getScheduledCommands(): Collection;
public function addScheduledCommand(ScheduledCommandInterface $scheduledCommand): self;
diff --git a/src/Entity/ScheduledCommand.php b/src/Entity/ScheduledCommand.php
index 522385bd..e4061ddb 100644
--- a/src/Entity/ScheduledCommand.php
+++ b/src/Entity/ScheduledCommand.php
@@ -9,81 +9,55 @@
use Synolia\SyliusSchedulerCommandPlugin\Enum\ScheduledCommandStateEnum;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepository;
-/**
- * @ORM\Entity(repositoryClass="Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepository")
- * @ORM\Table("synolia_scheduled_commands")
- */
#[ORM\Entity(repositoryClass: ScheduledCommandRepository::class)]
#[ORM\Table(name: 'synolia_scheduled_commands')]
class ScheduledCommand implements ScheduledCommandInterface
{
- /**
- * @var int|null
- *
- * @ORM\Id()
- * @ORM\GeneratedValue()
- * @ORM\Column(type="integer")
- */
+ /** @var int|null */
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;
- /** @ORM\Column(type="string") */
#[ORM\Column(type: Types::STRING)]
private string $name = '';
- /** @ORM\Column(type="string") */
#[ORM\Column(type: Types::STRING)]
private string $command = '';
- /** @ORM\Column(type="string", nullable=true) */
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $arguments = null;
- /** @ORM\Column(name="executed_at", type="datetime", nullable=true) */
#[ORM\Column(name: 'executed_at', type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTime $executedAt = null;
- /** @ORM\Column(type="integer", nullable=true) */
#[ORM\Column(type: Types::INTEGER, nullable: true)]
private ?int $lastReturnCode = null;
/**
* Log's file name (without path)
- *
- * @ORM\Column(type="string", nullable=true)
*/
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $logFile = null;
- /** @ORM\Column(type="datetime", nullable=true) */
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTime $commandEndTime = null;
- /** @ORM\Column(name="created_at", type="datetime", nullable=false) */
#[ORM\Column(name: 'created_at', type: Types::DATETIME_MUTABLE, nullable: false)]
private \DateTime $createdAt;
- /** @ORM\Column(name="state", type="string") */
#[ORM\Column(name: 'state', type: Types::STRING)]
private string $state = ScheduledCommandStateEnum::WAITING;
- /** @ORM\Column(type="integer", nullable=true) */
#[ORM\Column(type: Types::INTEGER, nullable: true)]
private ?int $timeout = null;
- /** @ORM\Column(type="integer", nullable=true) */
#[ORM\Column(type: Types::INTEGER, nullable: true)]
private ?int $idleTimeout = null;
- /**
- * @ORM\ManyToOne(targetEntity="Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface", inversedBy="scheduledCommands")
- * @ORM\JoinColumn(name="owner_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
- */
#[ORM\ManyToOne(targetEntity: CommandInterface::class, inversedBy: 'scheduledCommands')]
#[ORM\JoinColumn(name: 'owner_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- private ?\Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface $owner = null;
+ private ?CommandInterface $owner = null;
public function __construct()
{
diff --git a/src/Fixture/SchedulerCommandFixture.php b/src/Fixture/SchedulerCommandFixture.php
index dcb6e4fd..b31b8105 100644
--- a/src/Fixture/SchedulerCommandFixture.php
+++ b/src/Fixture/SchedulerCommandFixture.php
@@ -13,8 +13,8 @@
class SchedulerCommandFixture extends AbstractFixture
{
public function __construct(
- private RepositoryInterface $commandRepository,
- private FactoryInterface $commandFactory,
+ private readonly RepositoryInterface $commandRepository,
+ private readonly FactoryInterface $commandFactory,
) {
}
diff --git a/src/Form/CommandChoiceType.php b/src/Form/CommandChoiceType.php
index 4807e2e7..de9ec37a 100644
--- a/src/Form/CommandChoiceType.php
+++ b/src/Form/CommandChoiceType.php
@@ -11,7 +11,7 @@
final class CommandChoiceType extends AbstractType
{
- public function __construct(private CommandParserInterface $commandParser)
+ public function __construct(private readonly CommandParserInterface $commandParser)
{
}
@@ -24,7 +24,7 @@ public function configureOptions(OptionsResolver $resolver): void
);
}
- public function getParent()
+ public function getParent(): string
{
return ChoiceType::class;
}
diff --git a/src/Form/CommandType.php b/src/Form/CommandType.php
index 31eca393..0d230499 100644
--- a/src/Form/CommandType.php
+++ b/src/Form/CommandType.php
@@ -15,7 +15,7 @@
final class CommandType extends AbstractType
{
/**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
diff --git a/src/Form/ScheduledCommandType.php b/src/Form/ScheduledCommandType.php
index 4d53288a..e6f09e67 100644
--- a/src/Form/ScheduledCommandType.php
+++ b/src/Form/ScheduledCommandType.php
@@ -15,7 +15,7 @@
final class ScheduledCommandType extends AbstractType
{
/**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @inheritdoc
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
diff --git a/src/Grid/FieldType/DatetimeFieldType.php b/src/Grid/FieldType/DatetimeFieldType.php
index 0ed93d21..933291c7 100644
--- a/src/Grid/FieldType/DatetimeFieldType.php
+++ b/src/Grid/FieldType/DatetimeFieldType.php
@@ -8,11 +8,15 @@
use Sylius\Component\Grid\Definition\Field;
use Sylius\Component\Grid\FieldTypes\FieldTypeInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\OptionsResolver\OptionsResolver;
-final class DatetimeFieldType implements FieldTypeInterface
+#[AutoconfigureTag('sylius.grid_field', attributes: ['type' => 'scheduled_command_executed_at'])]
+final readonly class DatetimeFieldType implements FieldTypeInterface
{
public function __construct(
+ #[Autowire('@sylius.grid.data_extractor.property_access')]
private DataExtractorInterface $dataExtractor,
private LocaleContextInterface $localeContext,
) {
diff --git a/src/Grid/FieldType/ScheduledCommandExecutionTimeType.php b/src/Grid/FieldType/ScheduledCommandExecutionTimeType.php
index a96a632e..05ca003a 100644
--- a/src/Grid/FieldType/ScheduledCommandExecutionTimeType.php
+++ b/src/Grid/FieldType/ScheduledCommandExecutionTimeType.php
@@ -6,8 +6,10 @@
use Sylius\Component\Grid\Definition\Field;
use Sylius\Component\Grid\FieldTypes\FieldTypeInterface;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Component\OptionsResolver\OptionsResolver;
+#[AutoconfigureTag('sylius.grid_field', attributes: ['type' => 'scheduled_command_execution_time'])]
class ScheduledCommandExecutionTimeType implements FieldTypeInterface
{
private const HOUR_IN_SECONDES = 3600;
diff --git a/src/Grid/FieldType/ScheduledCommandHumanReadableExpressionType.php b/src/Grid/FieldType/ScheduledCommandHumanReadableExpressionType.php
index b5786ed2..770e0a67 100644
--- a/src/Grid/FieldType/ScheduledCommandHumanReadableExpressionType.php
+++ b/src/Grid/FieldType/ScheduledCommandHumanReadableExpressionType.php
@@ -6,11 +6,14 @@
use Sylius\Component\Grid\Definition\Field;
use Sylius\Component\Grid\FieldTypes\FieldTypeInterface;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Synolia\SyliusSchedulerCommandPlugin\Humanizer\HumanizerInterface;
use Twig\Environment;
-final class ScheduledCommandHumanReadableExpressionType implements FieldTypeInterface
+// app.grid_field.scheduled_command.humanReadableExpression
+#[AutoconfigureTag('sylius.grid_field', attributes: ['type' => 'scheduled_human_readable_expression'])]
+final readonly class ScheduledCommandHumanReadableExpressionType implements FieldTypeInterface
{
public function __construct(private Environment $twig, private HumanizerInterface $humanizer)
{
diff --git a/src/Grid/FieldType/ScheduledCommandStateType.php b/src/Grid/FieldType/ScheduledCommandStateType.php
index 55c3d810..ad095e87 100644
--- a/src/Grid/FieldType/ScheduledCommandStateType.php
+++ b/src/Grid/FieldType/ScheduledCommandStateType.php
@@ -6,10 +6,12 @@
use Sylius\Component\Grid\Definition\Field;
use Sylius\Component\Grid\FieldTypes\FieldTypeInterface;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Twig\Environment;
-final class ScheduledCommandStateType implements FieldTypeInterface
+#[AutoconfigureTag('sylius.grid_field', attributes: ['type' => 'scheduled_command_state'])]
+final readonly class ScheduledCommandStateType implements FieldTypeInterface
{
public function __construct(private Environment $twig)
{
@@ -20,12 +22,9 @@ public function __construct(private Environment $twig)
*/
public function render(Field $field, $scheduleCommand, array $options): string
{
- return $this->twig->render(
- $options['template'],
- [
- 'schedulerCommand' => $scheduleCommand,
- ],
- );
+ return $this->twig->render($options['template'], [
+ 'schedulerCommand' => $scheduleCommand,
+ ]);
}
/** @inheritdoc */
diff --git a/src/Grid/FieldType/ScheduledCommandUrlType.php b/src/Grid/FieldType/ScheduledCommandUrlType.php
index 6fe4dbee..42d52a2c 100644
--- a/src/Grid/FieldType/ScheduledCommandUrlType.php
+++ b/src/Grid/FieldType/ScheduledCommandUrlType.php
@@ -6,15 +6,19 @@
use Sylius\Component\Grid\Definition\Field;
use Sylius\Component\Grid\FieldTypes\FieldTypeInterface;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Environment;
-final class ScheduledCommandUrlType implements FieldTypeInterface
+#[AutoconfigureTag('sylius.grid_field', attributes: ['type' => 'scheduled_command_url'])]
+final readonly class ScheduledCommandUrlType implements FieldTypeInterface
{
public function __construct(
private UrlGeneratorInterface $urlGenerator,
private Environment $twig,
+ #[Autowire(env: 'string:SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR')]
private string $logsDir,
) {
}
diff --git a/src/Humanizer/CronExpressionHumanizer.php b/src/Humanizer/CronExpressionHumanizer.php
index 4ddd4b0a..9f1040c7 100644
--- a/src/Humanizer/CronExpressionHumanizer.php
+++ b/src/Humanizer/CronExpressionHumanizer.php
@@ -10,7 +10,7 @@
class CronExpressionHumanizer implements HumanizerInterface
{
- public function __construct(private LocaleContextInterface $localeContext)
+ public function __construct(private readonly LocaleContextInterface $localeContext)
{
}
diff --git a/src/Listener/Grid/GoToCommandsButtonGridListener.php b/src/Listener/Grid/GoToCommandsButtonGridListener.php
index 5bc2ce4b..31047beb 100644
--- a/src/Listener/Grid/GoToCommandsButtonGridListener.php
+++ b/src/Listener/Grid/GoToCommandsButtonGridListener.php
@@ -7,7 +7,9 @@
use Sylius\Component\Grid\Definition\Action;
use Sylius\Component\Grid\Definition\ActionGroup;
use Sylius\Component\Grid\Event\GridDefinitionConverterEvent;
+use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
+#[AsEventListener(event: 'sylius.grid.synolia_admin_scheduled_commands', method: 'onSyliusGridAdmin')]
final class GoToCommandsButtonGridListener
{
public function onSyliusGridAdmin(GridDefinitionConverterEvent $event): void
diff --git a/src/Listener/Grid/GoToHistoryButtonGridListener.php b/src/Listener/Grid/GoToHistoryButtonGridListener.php
index bc2501e9..45242050 100644
--- a/src/Listener/Grid/GoToHistoryButtonGridListener.php
+++ b/src/Listener/Grid/GoToHistoryButtonGridListener.php
@@ -7,7 +7,9 @@
use Sylius\Component\Grid\Definition\Action;
use Sylius\Component\Grid\Definition\ActionGroup;
use Sylius\Component\Grid\Event\GridDefinitionConverterEvent;
+use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
+#[AsEventListener(event: 'sylius.grid.synolia_admin_commands', method: 'onSyliusGridAdmin')]
final class GoToHistoryButtonGridListener
{
public function onSyliusGridAdmin(GridDefinitionConverterEvent $event): void
diff --git a/src/Menu/AdminMenuListener.php b/src/Menu/AdminMenuListener.php
index 52633026..8c9aa390 100644
--- a/src/Menu/AdminMenuListener.php
+++ b/src/Menu/AdminMenuListener.php
@@ -4,26 +4,29 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Menu;
-use Knp\Menu\ItemInterface;
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent;
+use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
+#[AsEventListener(event: 'sylius.menu.admin.main', method: 'addAdminMenuItems')]
final class AdminMenuListener
{
public function addAdminMenuItems(MenuBuilderEvent $event): void
{
$menu = $event->getMenu();
-
- /** @var ItemInterface $newSubmenu */
- $newSubmenu = $menu->addChild('scheduler')->setLabel('synolia.menu.admin.main.configuration.scheduler_command');
-
- $newSubmenu->addChild('scheduler-command', [
+ $newSubmenu = $menu
+ ->addChild('scheduler')
+ ->setLabel('synolia.menu.admin.main.configuration.scheduler_command')
+ ;
+ $newSubmenu
+ ->addChild('scheduler-command', [
'route' => 'synolia_admin_command_index',
])
->setAttribute('type', 'link')
->setLabel('synolia.menu.admin.main.configuration.scheduler_command')
->setLabelAttribute('icon', 'list')
;
- $newSubmenu->addChild('scheduler-command-history', [
+ $newSubmenu
+ ->addChild('scheduler-command-history', [
'route' => 'synolia_admin_scheduled_command_index',
])
->setAttribute('type', 'link')
diff --git a/src/Parser/CommandParser.php b/src/Parser/CommandParser.php
index 75725ce9..c15579cd 100644
--- a/src/Parser/CommandParser.php
+++ b/src/Parser/CommandParser.php
@@ -5,16 +5,20 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Parser;
use Symfony\Bundle\FrameworkBundle\Console\Application;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpKernel\KernelInterface;
use Webmozart\Assert\Assert;
class CommandParser implements CommandParserInterface
{
/** @var string[] */
- private array $excludedNamespaces;
+ private readonly array $excludedNamespaces;
- public function __construct(private KernelInterface $kernel, array $excludedNamespaces = [])
- {
+ public function __construct(
+ private readonly KernelInterface $kernel,
+ #[Autowire(['_complete'])]
+ array $excludedNamespaces = [],
+ ) {
Assert::allString($excludedNamespaces);
$this->excludedNamespaces = $excludedNamespaces;
}
diff --git a/src/Planner/ScheduledCommandPlanner.php b/src/Planner/ScheduledCommandPlanner.php
index 66d1b578..f3228ccb 100644
--- a/src/Planner/ScheduledCommandPlanner.php
+++ b/src/Planner/ScheduledCommandPlanner.php
@@ -15,10 +15,10 @@
class ScheduledCommandPlanner implements ScheduledCommandPlannerInterface
{
public function __construct(
- private FactoryInterface $scheduledCommandFactory,
- private EntityManagerInterface $entityManager,
- private ScheduledCommandRepository $scheduledCommandRepository,
- private LoggerInterface $logger,
+ private readonly FactoryInterface $scheduledCommandFactory,
+ private readonly EntityManagerInterface $entityManager,
+ private readonly ScheduledCommandRepository $scheduledCommandRepository,
+ private readonly LoggerInterface $logger,
) {
}
diff --git a/src/Resources/config/admin_routing.yaml b/src/Resources/config/admin_routing.yaml
deleted file mode 100644
index 2bb9a0a6..00000000
--- a/src/Resources/config/admin_routing.yaml
+++ /dev/null
@@ -1,76 +0,0 @@
-synolia_admin_commands:
- resource: |
- alias: synolia.command
- templates: "@SyliusAdmin\\Crud"
- section: admin
- grid: synolia_admin_commands
- except: ['show']
- permission: true
- vars:
- index:
- icon: 'box'
- type: sylius.resource
-
-synolia_admin_scheduled_commands:
- resource: |
- alias: synolia.scheduled_command
- templates: "@SyliusAdmin\\Crud"
- section: admin
- grid: synolia_admin_scheduled_commands
- except: ['update', 'show']
- permission: true
- vars:
- index:
- icon: 'box'
- type: sylius.resource
-
-download_schedule_log_file:
- path: /scheduled-commands/download/logfile/{command}
- methods: [GET]
- defaults:
- _controller: Synolia\SyliusSchedulerCommandPlugin\Controller\DownloadController::downloadLogFile
- _sylius:
- permission: true
-
-execute_immediate_schedule:
- path: /scheduled-commands/execute/immediate/{commandId}
- methods: [GET|PUT]
- defaults:
- _controller: Synolia\SyliusSchedulerCommandPlugin\Controller\ScheduledCommandExecuteImmediateController::executeImmediate
- _sylius:
- permission: true
-
-sylius_admin_scheduler_empty_log_file:
- path: /scheduled-commands/{command}/clean-log
- methods: [PUT]
- defaults:
- _controller: Synolia\SyliusSchedulerCommandPlugin\Action\CleanLogAction
- _sylius:
- permission: true
-
-sylius_admin_scheduler_view_log_file:
- path: /scheduled-commands/{command}/view-log
- methods: [GET]
- defaults:
- _controller: Synolia\SyliusSchedulerCommandPlugin\Controller\LogViewerController::show
- _sylius:
- permission: true
-
-sylius_admin_scheduler_get_log_file:
- path: /scheduled-commands/{command}/get-log.json
- methods: [GET]
- defaults:
- _controller: Synolia\SyliusSchedulerCommandPlugin\Controller\LogViewerController::getLogs
- _sylius:
- permission: true
-
-sylius_admin_scheduler_emtpy_logs:
- path: /scheduled-commands/emtpy_logs
- methods: [GET|PUT]
- controller: Synolia\SyliusSchedulerCommandPlugin\Controller\EmptyLogsController::emptyLogs
- defaults:
- _sylius:
- permission: true
- repository:
- method: findById
- arguments: [$ids]
diff --git a/src/Resources/config/config.yaml b/src/Resources/config/config.yaml
deleted file mode 100644
index 5b9c5220..00000000
--- a/src/Resources/config/config.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-imports:
- - { resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/resources.yaml" }
- - { resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/grids.yaml" }
- - { resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/services.yaml" }
- - { resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/ui.yaml" }
diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml
deleted file mode 100644
index d1589b70..00000000
--- a/src/Resources/config/services.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
-parameters:
- env(SYNOLIA_SCHEDULER_PLUGIN_PING_INTERVAL): 300
- env(SYNOLIA_SCHEDULER_PLUGIN_KEEP_ALIVE): true
- env(SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR): '%kernel.logs_dir%'
-
-services:
- _defaults:
- autowire: true
- autoconfigure: true
- public: false
- bind:
- $logsDir: '%env(string:SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR)%'
- $projectDir: '%kernel.project_dir%'
-
- Synolia\SyliusSchedulerCommandPlugin\:
- resource: '../../*'
- exclude: '../../{Entity,Migrations,SynoliaSyliusSchedulerCommandPlugin.php}'
-
- Synolia\SyliusSchedulerCommandPlugin\Menu\AdminMenuListener:
- tags:
- - { name: kernel.event_listener, event: sylius.menu.admin.main, method: addAdminMenuItems }
-
- Synolia\SyliusSchedulerCommandPlugin\Parser\CommandParser:
- arguments:
- $excludedNamespaces: ['_complete']
-
- app.grid_field.scheduled_command.url:
- class: Synolia\SyliusSchedulerCommandPlugin\Grid\FieldType\ScheduledCommandUrlType
- tags:
- - { name: sylius.grid_field, type: scheduled_command_url }
-
- app.grid_field.scheduled_command.state:
- class: Synolia\SyliusSchedulerCommandPlugin\Grid\FieldType\ScheduledCommandStateType
- tags:
- - { name: sylius.grid_field, type: scheduled_command_state }
-
- app.grid_field.scheduled_command.humanReadableExpression:
- class: Synolia\SyliusSchedulerCommandPlugin\Grid\FieldType\ScheduledCommandHumanReadableExpressionType
- tags:
- - { name: sylius.grid_field, type: scheduled_human_readable_expression }
-
- app.grid_field.scheduled_command.execution_time:
- class: Synolia\SyliusSchedulerCommandPlugin\Grid\FieldType\ScheduledCommandExecutionTimeType
- tags:
- - { name: sylius.grid_field, type: scheduled_command_execution_time }
-
- Synolia\SyliusSchedulerCommandPlugin\Grid\FieldType\DatetimeFieldType:
- arguments:
- $dataExtractor: '@sylius.grid.data_extractor.property_access'
- tags:
- - { name: sylius.grid_field, type: scheduled_command_executed_at }
-
- Synolia\SyliusSchedulerCommandPlugin\Listener\Grid\GoToHistoryButtonGridListener:
- tags:
- - { name: kernel.event_listener, event: sylius.grid.synolia_admin_commands, method: onSyliusGridAdmin }
-
- Synolia\SyliusSchedulerCommandPlugin\Listener\Grid\GoToCommandsButtonGridListener:
- tags:
- - { name: kernel.event_listener, event: sylius.grid.synolia_admin_scheduled_commands, method: onSyliusGridAdmin }
-
- Synolia\SyliusSchedulerCommandPlugin\Checker\EveryMinuteIsDueChecker:
- tags:
- - { name: !php/const Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface::TAG_ID }
-
- Synolia\SyliusSchedulerCommandPlugin\Checker\SoftLimitThresholdIsDueChecker:
- tags:
- - { name: !php/const Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface::TAG_ID }
-
- Synolia\SyliusSchedulerCommandPlugin\Voter\IsDueVoterInterface:
- class: Synolia\SyliusSchedulerCommandPlugin\Voter\IsDueVoter
- arguments:
- - !tagged_iterator { tag: !php/const Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface::TAG_ID }
-
- Synolia\SyliusSchedulerCommandPlugin\Runner\ScheduleCommandRunnerInterface:
- class: Synolia\SyliusSchedulerCommandPlugin\Runner\ScheduleCommandRunner
- bind:
- $pingInterval: '%env(int:SYNOLIA_SCHEDULER_PLUGIN_PING_INTERVAL)%'
- $keepConnectionAlive: '%env(bool:SYNOLIA_SCHEDULER_PLUGIN_KEEP_ALIVE)%'
-
- Synolia\SyliusSchedulerCommandPlugin\DoctrineEvent\ScheduledCommandPostRemoveEvent:
- tags:
- - { name: doctrine.event_subscriber, connection: default }
diff --git a/src/Runner/ScheduleCommandRunner.php b/src/Runner/ScheduleCommandRunner.php
index 0a6fd236..d4f683b1 100644
--- a/src/Runner/ScheduleCommandRunner.php
+++ b/src/Runner/ScheduleCommandRunner.php
@@ -5,22 +5,27 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Runner;
use Doctrine\ORM\EntityManagerInterface;
-use Symfony\Component\HttpKernel\KernelInterface;
+use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Process;
use Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface;
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepositoryInterface;
+#[AutoconfigureTag(attributes: ['name' => 'sylius.grid_field', 'type' => 'scheduled_command_url'])]
class ScheduleCommandRunner implements ScheduleCommandRunnerInterface
{
public function __construct(
- private ScheduledCommandRepositoryInterface $scheduledCommandRepository,
- private EntityManagerInterface $entityManager,
- private KernelInterface $kernel,
- private string $logsDir,
- private string $projectDir,
- private int $pingInterval = 60,
- private bool $keepConnectionAlive = false,
+ private readonly ScheduledCommandRepositoryInterface $scheduledCommandRepository,
+ private readonly EntityManagerInterface $entityManager,
+ #[Autowire(env: 'string:SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR')]
+ private readonly string $logsDir,
+ #[Autowire(param: 'kernel.project_dir')]
+ private readonly string $projectDir,
+ #[Autowire(env: 'int:SYNOLIA_SCHEDULER_PLUGIN_PING_INTERVAL')]
+ private readonly int $pingInterval = 60,
+ #[Autowire(env: 'bool:SYNOLIA_SCHEDULER_PLUGIN_KEEP_ALIVE')]
+ private readonly bool $keepConnectionAlive = false,
) {
}
@@ -34,7 +39,7 @@ public function runImmediately(string $scheduledCommandId): bool
$process = Process::fromShellCommandline(
$this->getCommandLine($scheduledCommand),
- $this->kernel->getProjectDir(),
+ $this->projectDir,
);
$scheduledCommand->setExecutedAt(new \DateTime());
diff --git a/src/SynoliaSyliusSchedulerCommandPlugin.php b/src/SynoliaSyliusSchedulerCommandPlugin.php
index 824eb921..97f67ada 100644
--- a/src/SynoliaSyliusSchedulerCommandPlugin.php
+++ b/src/SynoliaSyliusSchedulerCommandPlugin.php
@@ -10,4 +10,9 @@
final class SynoliaSyliusSchedulerCommandPlugin extends Bundle
{
use SyliusPluginTrait;
+
+ public function getPath(): string
+ {
+ return \dirname(__DIR__);
+ }
}
diff --git a/src/Twig/BytesFormatterExtension.php b/src/Twig/BytesFormatterExtension.php
index 3aca6bcd..022d822e 100644
--- a/src/Twig/BytesFormatterExtension.php
+++ b/src/Twig/BytesFormatterExtension.php
@@ -14,7 +14,7 @@ final class BytesFormatterExtension extends AbstractExtension
public function getFilters(): array
{
return [
- new TwigFilter('format_bytes', [$this, 'formatBytes']),
+ new TwigFilter('format_bytes', $this->formatBytes(...)),
];
}
diff --git a/src/Voter/IsDueVoter.php b/src/Voter/IsDueVoter.php
index 3a4462a4..8c7ff35d 100644
--- a/src/Voter/IsDueVoter.php
+++ b/src/Voter/IsDueVoter.php
@@ -4,22 +4,23 @@
namespace Synolia\SyliusSchedulerCommandPlugin\Voter;
+use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
+use Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface;
use Synolia\SyliusSchedulerCommandPlugin\Components\Exceptions\Checker\IsNotDueException;
use Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface;
class IsDueVoter implements IsDueVoterInterface
{
- /** @var array<\Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface> */
- private array $isDueCheckers;
-
- public function __construct(\Traversable $checkers)
- {
- $this->isDueCheckers = iterator_to_array($checkers);
+ public function __construct(
+ #[TaggedIterator(IsDueCheckerInterface::TAG_ID)]
+ private readonly iterable $checkers,
+ ) {
}
public function isDue(CommandInterface $command, ?\DateTimeInterface $dateTime = null): bool
{
- foreach ($this->isDueCheckers as $checker) {
+ /** @var IsDueCheckerInterface $checker */
+ foreach ($this->checkers as $checker) {
try {
return $checker->isDue($command, $dateTime);
} catch (IsNotDueException) {
diff --git a/src/Resources/views/Controller/css.html.twig b/templates/Controller/css.html.twig
similarity index 100%
rename from src/Resources/views/Controller/css.html.twig
rename to templates/Controller/css.html.twig
diff --git a/src/Resources/views/Controller/js.html.twig b/templates/Controller/js.html.twig
similarity index 100%
rename from src/Resources/views/Controller/js.html.twig
rename to templates/Controller/js.html.twig
diff --git a/src/Resources/views/Controller/modal.html.twig b/templates/Controller/modal.html.twig
similarity index 100%
rename from src/Resources/views/Controller/modal.html.twig
rename to templates/Controller/modal.html.twig
diff --git a/src/Resources/views/Controller/show.html.twig b/templates/Controller/show.html.twig
similarity index 100%
rename from src/Resources/views/Controller/show.html.twig
rename to templates/Controller/show.html.twig
diff --git a/src/Resources/views/Grid/Action/empty_log_file.html.twig b/templates/Grid/Action/empty_log_file.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Action/empty_log_file.html.twig
rename to templates/Grid/Action/empty_log_file.html.twig
diff --git a/src/Resources/views/Grid/Action/empty_logs_file.html.twig b/templates/Grid/Action/empty_logs_file.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Action/empty_logs_file.html.twig
rename to templates/Grid/Action/empty_logs_file.html.twig
diff --git a/src/Resources/views/Grid/Action/execute_immediate.html.twig b/templates/Grid/Action/execute_immediate.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Action/execute_immediate.html.twig
rename to templates/Grid/Action/execute_immediate.html.twig
diff --git a/src/Resources/views/Grid/Action/link.html.twig b/templates/Grid/Action/link.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Action/link.html.twig
rename to templates/Grid/Action/link.html.twig
diff --git a/src/Resources/views/Grid/Column/human_readable_expression.html.twig b/templates/Grid/Column/human_readable_expression.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Column/human_readable_expression.html.twig
rename to templates/Grid/Column/human_readable_expression.html.twig
diff --git a/src/Resources/views/Grid/Column/js.html.twig b/templates/Grid/Column/js.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Column/js.html.twig
rename to templates/Grid/Column/js.html.twig
diff --git a/src/Resources/views/Grid/Column/log_file.html.twig b/templates/Grid/Column/log_file.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Column/log_file.html.twig
rename to templates/Grid/Column/log_file.html.twig
diff --git a/src/Resources/views/Grid/Column/scheduled_command_state.html.twig b/templates/Grid/Column/scheduled_command_state.html.twig
similarity index 100%
rename from src/Resources/views/Grid/Column/scheduled_command_state.html.twig
rename to templates/Grid/Column/scheduled_command_state.html.twig
diff --git a/src/Resources/translations/messages.en.yml b/translations/messages.en.yml
similarity index 100%
rename from src/Resources/translations/messages.en.yml
rename to translations/messages.en.yml
diff --git a/src/Resources/translations/messages.fr.yml b/translations/messages.fr.yml
similarity index 100%
rename from src/Resources/translations/messages.fr.yml
rename to translations/messages.fr.yml
diff --git a/src/Resources/translations/messages.nl.yml b/translations/messages.nl.yml
similarity index 100%
rename from src/Resources/translations/messages.nl.yml
rename to translations/messages.nl.yml
diff --git a/src/Resources/translations/validators.en.yaml b/translations/validators.en.yaml
similarity index 100%
rename from src/Resources/translations/validators.en.yaml
rename to translations/validators.en.yaml
diff --git a/src/Resources/translations/validators.fr.yaml b/translations/validators.fr.yaml
similarity index 100%
rename from src/Resources/translations/validators.fr.yaml
rename to translations/validators.fr.yaml