pimcore / number-sequence-generator
Pimcore 数字序列生成器
v2.0.1
2024-05-03 08:33 UTC
Requires
- pimcore/pimcore: ^10.6 || ^11.0
Requires (Dev)
- phpstan/phpstan: ^1.9
README
连续数字
生成连续数字,例如用于订单号或客户号。
public function exampleAction(Pimcore\Bundle\NumberSequenceGeneratorBundle\Generator $generator) { /* * Generates the next order number (increments current order number by 1) * If no order number was generated before it will start with 10000 */ $next = $generator->getNext('ordernumber', 10000); /* * Receive the current order number without incrementing the counter. */ $current = $generator->getCurrent('ordernumber'); /* * Sets the order number to 35017 in the database. */ $generator->setCurrent('ordernumber', 35017); }
随机数字(可以是数字或字母数字)
生成唯一的随机数字。
public function __construct(Generator $generator) { $this->generator = $generator; } public function generateCode() { $code = $this->generator->generateCode("vouchercode", \Pimcore\Bundle\NumberSequenceGeneratorBundle\RandomGenerator::ALPHANUMERIC, 32); }
升级到 Pimcore XI
- 更新到 Pimcore X 的最新(允许)捆绑版本,并执行所有迁移。
- 然后更新到 Pimcore XI。