Hello!
The following initial situation: I have an object “Shipping” with a unique, consecutive number (NumberShipping).
/**
* @Flow\Entity
*/
class Shipping
{
/**
* @var NumberShipping
* @ORM\OneToOne(cascade={"persist", "remove"})
* @ORM\Column(nullable=true)
*/
protected $number;
…
/**
* @Flow\Entity
*/
class NumberShipping
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @var int
*/
protected $number;
/**
* @return int
*/
public function getNumber(): int
{
return $this->number;
}
/**
* @param int $number
*/
public function setNumber(int $number): void
{
$this->number = $number;
}
}
This works as far as it should. The numbers are generated ascending and unique. Now I want to give the user the possibility to increase the numbers. So he can specify that the number range starts at 10.000. I have implemented this as follows:
/**
* @Flow\Scope("singleton")
*/
class NumberShippingRepository extends Repository
{
protected $defaultOrderings = ["number" => QueryInterface::ORDER_DESCENDING];
/**
* @param int $nextNumber
* @throws \Neos\Flow\Persistence\Exception\IllegalObjectTypeException
*/
public function setNextNumber(int $nextNumber) {
$nextNumber -= 1;
/** @var NumberShipping $lastUsedNumberObject */
$lastUsedNumberObject = $this->createQuery()->setLimit(1)->execute()->getFirst();
$lastUsedNumber = $lastUsedNumberObject->getNumber();
if ($lastUsedNumber >= $nextNumber)
return;
$newNumber = new NumberShipping();
$newNumber->setNumber($nextNumber);
$this->add($newNumber);
}
}
Now the problem is, if $nextNumber has the value 10.000, a new instance of NumberShipping is created, but the counting method is unaffected. (so it is counted up normally). Can I force Doctrine (or whoever) to use my 10,000?
Thanks for your help!