CartExpirer
in package
Expires persistent carts: anonymous carts (without `userId`) and carts of logged-in customers each have their own retention period from the module 4 settings (`cart.expirationDaysGuest`, `cart.expirationDaysUser`).
CartManager reads the values through SettingContext (a manager may, a service may not)
and passes them in as parameters; this class never touches cms_system_settings.
Deletion is a raw DBAL DELETE on cms_mod_eshop_carts; cart_items and cart_vouchers
have a real FK with ON DELETE CASCADE, so deleting the parent deletes their rows too.
Table of Contents
Constants
- DEFAULT_TIME_BUDGET : int = 20
- Time budget of one run in seconds; keeps the cron below the PHP timeout.
- DEFAULT_BATCH : int = 200
Properties
- $em : EntityManagerInterface
Methods
- __construct() : mixed
-
run()
: array{processed: int, expired: int, skipped: int, errors: list
} - Deletes expired carts in repeated batches until nothing is left or the time budget runs out. `$limit` is the size of one batch; `ORDER BY cart_id` keeps the order deterministic.
Constants
DEFAULT_TIME_BUDGET
Time budget of one run in seconds; keeps the cron below the PHP timeout.
public
int
DEFAULT_TIME_BUDGET
= 20
DEFAULT_BATCH
private
int
DEFAULT_BATCH
= 200
Properties
$em read-only
private
EntityManagerInterface
$em
Methods
__construct()
public
__construct(EntityManagerInterface $em) : mixed
Parameters
- $em : EntityManagerInterface
run()
Deletes expired carts in repeated batches until nothing is left or the time budget runs out. `$limit` is the size of one batch; `ORDER BY cart_id` keeps the order deterministic.
public
run(int $guestDays, int $userDays[, int|null $limit = null ][, int $timeBudget = self::DEFAULT_TIME_BUDGET ]) : array{processed: int, expired: int, skipped: int, errors: list}
Parameters
- $guestDays : int
- $userDays : int
- $limit : int|null = null
- $timeBudget : int = self::DEFAULT_TIME_BUDGET