Skip to content

Commit a3c484c

Browse files
committed
Add some readme
1 parent 8e6fe4f commit a3c484c

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ in the `config/bundles.php` file of your project before (!) `SyliusGridBundle` a
2525
return [
2626
Setono\SyliusRestockNotificationPlugin\SetonoSyliusRestockNotificationPlugin::class => ['all' => true],
2727
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
28-
28+
2929
// ...
30-
30+
3131
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
3232
];
3333
```
@@ -48,6 +48,28 @@ php bin/console doctrine:migrations:diff
4848
php bin/console doctrine:migrations:migrate
4949
```
5050

51+
## Maintenance
52+
53+
### Pruning Old Notification Requests
54+
55+
The plugin includes a command to remove old restock notification requests that are no longer needed. By default, it removes requests that are older than 90 days.
56+
57+
```bash
58+
# Using the default threshold (90 days)
59+
php bin/console setono:sylius-restock-notification:prune-requests
60+
61+
# Specifying a custom threshold (e.g., 30 days)
62+
php bin/console setono:sylius-restock-notification:prune-requests --pruning-threshold=30
63+
```
64+
65+
You can configure the default threshold in your application's configuration:
66+
67+
```yaml
68+
# config/packages/setono_sylius_restock_notification.yaml
69+
setono_sylius_restock_notification:
70+
pruning_threshold: 60 # Set the threshold to 60 days
71+
```
72+
5173
[ico-version]: https://poser.pugx.org/setono/sylius-restock-notification-plugin/v/stable
5274
[ico-license]: https://poser.pugx.org/setono/sylius-restock-notification-plugin/license
5375
[ico-github-actions]: https://github.com/Setono/SyliusRestockNotificationPlugin/workflows/build/badge.svg

src/Command/PruneRestockNotificationRequestsCommand.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,21 @@ final class PruneRestockNotificationRequestsCommand extends Command
1818

1919
protected static $defaultDescription = 'Remove restock notification requests older than the configured threshold';
2020

21-
private RestockNotificationRequestRepositoryInterface $restockNotificationRequestRepository;
22-
23-
private int $pruningThreshold;
24-
2521
public function __construct(
26-
RestockNotificationRequestRepositoryInterface $restockNotificationRequestRepository,
27-
int $pruningThreshold,
22+
private readonly RestockNotificationRequestRepositoryInterface $restockNotificationRequestRepository,
23+
private readonly int $pruningThreshold,
2824
) {
2925
parent::__construct();
30-
31-
$this->restockNotificationRequestRepository = $restockNotificationRequestRepository;
32-
$this->pruningThreshold = $pruningThreshold;
3326
}
3427

3528
protected function configure(): void
3629
{
3730
$this
3831
->addOption(
39-
'threshold-days',
40-
't',
32+
'pruning-threshold',
33+
null,
4134
InputOption::VALUE_REQUIRED,
4235
'Override the configured threshold (in days)',
43-
null,
4436
)
4537
;
4638
}
@@ -49,8 +41,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4941
{
5042
$io = new SymfonyStyle($input, $output);
5143

52-
$thresholdDays = (int) ($input->getOption('threshold-days') ?? $this->pruningThreshold);
53-
$date = new DateTimeImmutable(sprintf('-%d days', $thresholdDays));
44+
$pruningThreshold = (int) ($input->getOption('pruning-threshold') ?? $this->pruningThreshold);
45+
$date = new DateTimeImmutable(sprintf('-%d days', $pruningThreshold));
5446

5547
$count = $this->restockNotificationRequestRepository->removeOlderThan($date);
5648

0 commit comments

Comments
 (0)