예제 #1
0
 /**
  * @return \Orm\Zed\SequenceNumber\Persistence\SpySequenceNumber
  */
 protected function getSequence()
 {
     $sequence = SpySequenceNumberQuery::create()->findOneByName($this->sequenceNumberSettings->getName());
     $offset = $this->sequenceNumberSettings->getOffset();
     if ($sequence === null) {
         $sequence = new SpySequenceNumber();
         $sequence->setName($this->sequenceNumberSettings->getName());
         $sequence->setCurrentId($offset);
         return $sequence;
     }
     $expectedCurrentValue = $offset - 1;
     $current = $sequence->getCurrentId();
     if ($current < $expectedCurrentValue) {
         $sequence->setCurrentId($expectedCurrentValue);
     }
     return $sequence;
 }
 /**
  * @return \Orm\Zed\SequenceNumber\Persistence\SpySequenceNumberQuery
  */
 public function createSequenceNumberQuery()
 {
     return SpySequenceNumberQuery::create();
 }