/**
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $storeId = $observer->getData('store')->getId();
     foreach ($this->entityPool->getEntities() as $entityType) {
         $this->sequenceBuilder->setPrefix($storeId)->setSuffix($this->sequenceConfig->get('suffix'))->setStartValue($this->sequenceConfig->get('startValue'))->setStoreId($storeId)->setStep($this->sequenceConfig->get('step'))->setWarningValue($this->sequenceConfig->get('warningValue'))->setMaxValue($this->sequenceConfig->get('maxValue'))->setEntityType($entityType)->create();
     }
     return $this;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $defaultStoreIds = [0, 1];
     foreach ($defaultStoreIds as $storeId) {
         foreach ($this->entityPool->getEntities() as $entityType) {
             $this->sequenceBuilder->setPrefix($this->sequenceConfig->get('prefix'))->setSuffix($this->sequenceConfig->get('suffix'))->setStartValue($this->sequenceConfig->get('startValue'))->setStoreId($storeId)->setStep($this->sequenceConfig->get('step'))->setWarningValue($this->sequenceConfig->get('warningValue'))->setMaxValue($this->sequenceConfig->get('maxValue'))->setEntityType($entityType)->create();
         }
     }
 }
예제 #3
0
 public function testAddSequence()
 {
     $entityType = 'lalalka';
     $storeId = 1;
     $prefix = 'PRE';
     $suffix = 'SUF';
     $startValue = 1;
     $step = 1;
     $maxValue = 120000;
     $warningValue = 110000;
     $this->resourceSequenceMeta->expects($this->once())->method('loadByEntityTypeAndStore')->with($entityType, $storeId)->willReturn($this->meta);
     $this->meta->expects($this->once())->method('getSequenceTable')->willReturn(null);
     $this->profileFactory->expects($this->once())->method('create')->with(['data' => ['prefix' => $prefix, 'suffix' => $suffix, 'start_value' => $startValue, 'step' => $step, 'max_value' => $maxValue, 'warning_value' => $warningValue, 'is_active' => 1]])->willReturn($this->profile);
     $sequenceTable = sprintf('sequence_%s_%s', $entityType, $storeId);
     $this->metaFactory->expects($this->once())->method('create')->with(['data' => ['entity_type' => $entityType, 'store_id' => $storeId, 'sequence_table' => $sequenceTable, 'active_profile' => $this->profile]])->willReturn($this->meta);
     $this->resourceSequenceMeta->expects($this->once())->method('save')->willReturn($this->meta);
     $this->stepCreateSequence($sequenceTable, $startValue);
     $this->sequenceBuilder->setEntityType($entityType)->setStoreId($storeId)->setPrefix($prefix)->setSuffix($suffix)->setStartValue($startValue)->setStep($step)->setMaxValue($maxValue)->setWarningValue($warningValue)->create();
 }