Пример #1
0
 /**
  *
  * @param \MUtil_Task_TaskBatch $batch Optional batch with different source etc..
  * @return \MUtil_Task_TaskBatch
  */
 public function getImportOnlyBatch(\MUtil_Task_TaskBatch $batch = null)
 {
     if (!$this->_importBatch instanceof \MUtil_Task_TaskBatch) {
         $batch = $this->loader->getTaskRunnerBatch(__CLASS__ . '_import_' . basename($this->sourceModel->getName()) . '_' . __FUNCTION__);
         $batch->setVariable('targetModel', $this->getTargetModel());
         $this->_importBatch = $batch;
     } else {
         $batch = $this->_importBatch;
     }
     return parent::getImportOnlyBatch($batch);
 }
Пример #2
0
 /**
  * Add the elements from the model to the bridge for the current step
  *
  * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function addStep5(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $this->nextDisabled = true;
     if ($this->loadSourceModel()) {
         $form = $bridge->getForm();
         $batch = $this->importer->getImportOnlyBatch();
         $batch->setFormId($form->getId());
         $batch->autoStart = true;
         if ($batch->run($this->request)) {
             exit;
         }
         $element = $bridge->getForm()->createElement('html', $batch->getId());
         if ($batch->isFinished()) {
             $this->nextDisabled = $batch->getCounter('import_errors');
             $batch->autoStart = false;
             $text = $this->afterImport($batch, $element);
         } else {
             $iter = $batch->getSessionVariable('iterator');
             if ($iter instanceof \Iterator) {
                 // Restart the iterator
                 $iter->rewind();
             }
             $element->setValue($batch->getPanel($this->view, $batch->getProgressPercentage() . '%'));
         }
         $form->activateJQuery();
         $form->addElement($element);
     } else {
         $this->displayHeader($bridge, $this->_('Import error!'));
         $this->displayErrors($bridge);
         $this->nextDisabled = true;
     }
     return;
 }