当前位置: 首页>>代码示例>>PHP>>正文


PHP batch_set函数代码示例

本文整理汇总了PHP中batch_set函数的典型用法代码示例。如果您正苦于以下问题:PHP batch_set函数的具体用法?PHP batch_set怎么用?PHP batch_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了batch_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

 /**
  * Starts the batch process depending on where it was requested from.
  */
 public function start()
 {
     switch ($this->batchInfo['from']) {
         case 'form':
             batch_set($this->batch);
             break;
         case 'drush':
             batch_set($this->batch);
             $this->batch =& batch_get();
             $this->batch['progressive'] = FALSE;
             drush_log(t(self::BATCH_INIT_MESSAGE), 'status');
             drush_backend_batch_process();
             break;
         case 'backend':
             batch_set($this->batch);
             $this->batch =& batch_get();
             $this->batch['progressive'] = FALSE;
             batch_process();
             //todo: Does not take advantage of batch API and eventually runs out of memory on very large sites.
             break;
         case 'nobatch':
             $context = [];
             foreach ($this->batch['operations'] as $i => $operation) {
                 $operation[1][] =& $context;
                 call_user_func_array($operation[0], $operation[1]);
             }
             self::finishGeneration(TRUE, $context['results'], []);
             break;
     }
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:33,代码来源:Batch.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     batch_test_stack(NULL, TRUE);
     $function = '_batch_test_' . $form_state->getValue('batch');
     batch_set($function());
     $form_state->setRedirect('batch_test.redirect');
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:10,代码来源:BatchTestSimpleForm.php

示例3: submitForm

 public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state)
 {
     // Check to make sure that the file was uploaded to the server properly
     $userInputValues = $form_state->getUserInput();
     $uri = db_select('file_managed', 'f')->condition('f.fid', $userInputValues['import']['fids'], '=')->fields('f', array('uri'))->execute()->fetchField();
     if (!empty($uri)) {
         if (file_exists(\Drupal::service("file_system")->realpath($uri))) {
             // Open the csv
             $handle = fopen(\Drupal::service("file_system")->realpath($uri), "r");
             // Go through each row in the csv and run a function on it. In this case we are parsing by '|' (pipe) characters.
             // If you want commas are any other character, replace the pipe with it.
             while (($data = fgetcsv($handle, 0, ',', '"')) !== FALSE) {
                 $operations[] = ['csvimport_import_batch_processing', [$data]];
             }
             // Once everything is gathered and ready to be processed... well... process it!
             $batch = ['title' => t('Importing CSV...'), 'operations' => $operations, 'finished' => $this->csvimport_import_finished(), 'error_message' => t('The installation has encountered an error.'), 'progress_message' => t('Imported @current of @total products.')];
             batch_set($batch);
             fclose($handle);
         } else {
             drupal_set_message(t('Not able to find file path.'), 'error');
         }
     } else {
         drupal_set_message(t('There was an error uploading your file. Please contact a System administator.'), 'error');
     }
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:25,代码来源:CsvimportImportForm.php

示例4: startBatchClear

 /**
  * {@inheritodc}
  */
 public function startBatchClear(FeedInterface $feed)
 {
     $feed->lock();
     $feed->clearStates();
     $batch = ['title' => $this->t('Deleting items from: %title', ['%title' => $feed->label()]), 'init_message' => $this->t('Deleting items from: %title', ['%title' => $feed->label()]), 'operations' => [[[$this, 'clear'], [$feed]]], 'progress_message' => $this->t('Deleting items from: %title', ['%title' => $feed->label()]), 'error_message' => $this->t('An error occored while clearing %title.', ['%title' => $feed->label()])];
     batch_set($batch);
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:10,代码来源:FeedClearHandler.php

示例5: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Pass the file to the parser.
     $fid = $form_state->getValue('mtg_import_json_file');
     $fid = reset($fid);
     if ($fid == 0) {
         return FALSE;
     }
     $file = File::load($fid);
     if (!$file) {
         drupal_set_message('Unable to load file.');
         \Drupal::logger('mtg_import')->error(t('Unable to load the file.'));
         return FALSE;
     }
     $uri = $file->uri->value;
     $file_contents_raw = file_get_contents($uri);
     $file_contents = json_decode($file_contents_raw);
     if (!empty($file_contents->cards)) {
         $operations = [['mtg_import_parse_set_data', [$file_contents]]];
         $chunks = array_chunk($file_contents->cards, 20);
         foreach ($chunks as $chunk) {
             $operations[] = ['mtg_import_parse_card_data', [$chunk]];
         }
         $batch = ['title' => t('Importing'), 'operations' => $operations, 'finished' => 'mtg_import_completed', 'progress_message' => t('Completed part @current of @total.')];
         batch_set($batch);
     } else {
         drupal_set_message(t('There are no cards in the file, so no import will take place.'), 'warning');
     }
 }
开发者ID:mangyfox,项目名称:magic-v2,代码行数:32,代码来源:UploadForm.php

示例6: updateStatusManually

 /**
  * Manually checks the update status without the use of cron.
  */
 public function updateStatusManually()
 {
     $this->updateManager->refreshUpdateData();
     $batch = array('operations' => array(array(array($this->updateManager, 'fetchDataBatch'), array())), 'finished' => 'update_fetch_data_finished', 'title' => t('Checking available update data'), 'progress_message' => t('Trying to check available update data ...'), 'error_message' => t('Error checking available update data.'));
     batch_set($batch);
     return batch_process('admin/reports/updates');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:UpdateController.php

示例7: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     batch_test_stack(NULL, TRUE);
     $function = '_batch_test_' . $form_state['values']['batch'];
     batch_set($function());
     $form_state['redirect_route'] = new Url('batch_test.redirect');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:BatchTestSimpleForm.php

示例8: batchTestChainedFormSubmit4

 /**
  * Form submission handler #4 for batch_test_chained_form
  */
 public static function batchTestChainedFormSubmit4($form, FormStateInterface $form_state)
 {
     batch_test_stack('submit handler 4');
     batch_test_stack('value = ' . $form_state['values']['value']);
     $form_state['values']['value']++;
     batch_set(_batch_test_batch_3());
     $form_state->setRedirect('batch_test.redirect');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:BatchTestChainedForm.php

示例9: batchTestChainedFormSubmit4

 /**
  * Form submission handler #4 for batch_test_chained_form
  */
 public static function batchTestChainedFormSubmit4($form, &$form_state)
 {
     batch_test_stack('submit handler 4');
     batch_test_stack('value = ' . $form_state['values']['value']);
     $form_state['values']['value']++;
     batch_set(_batch_test_batch_3());
     $form_state['redirect_route'] = new Url('batch_test.redirect');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:BatchTestChainedForm.php

示例10: get_movies

 public function get_movies()
 {
     $batch = array('title' => t('Importing Douban Movies'), 'operations' => array(array('doubanmovie_get_movies', array())), 'finished' => 'my_finished_callback', 'file' => drupal_get_path('module', 'doubanmovie') . '/doubanmovie.batch.inc');
     batch_set($batch);
     // Only needed if not inside a form _submit handler.
     // Setting redirect in batch_process.
     return batch_process('node/1');
 }
开发者ID:randomyao22,项目名称:douban-movie-d8,代码行数:8,代码来源:DoubanmovieController.php

示例11: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $batch = array('title' => $this->t('Bulk updating URL aliases'), 'operations' => array(array('Drupal\\pathauto\\Form\\PathautoBulkUpdateForm::batchStart', array())), 'finished' => 'Drupal\\pathauto\\Form\\PathautoBulkUpdateForm::batchFinished');
     foreach ($form_state->getValue('update') as $id) {
         if (!empty($id)) {
             $batch['operations'][] = array('Drupal\\pathauto\\Form\\PathautoBulkUpdateForm::batchProcess', array($id));
         }
     }
     batch_set($batch);
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:13,代码来源:PathautoBulkUpdateForm.php

示例12: submitForm

 /**
  * {@inheritdoc}.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $batch = ['title' => $this->t('Importing feed sources'), 'operations' => [], 'progress_message' => $this->t('Processed @current feed source from @total.'), 'error_message' => $this->t('An error occurred during processing'), 'finished' => '_d8batch_batch_finished'];
     // Get the feed sources from the CSV file and add them to the batch
     // operations for later processing.
     if ($res = fopen(drupal_get_path('module', 'd8batch') . '/' . self::CSVFILE_NAME, 'r')) {
         while ($line = fgetcsv($res)) {
             $batch['operations'][] = ['_d8batch_batch_operation', [array_shift($line)]];
         }
         fclose($res);
     }
     batch_set($batch);
 }
开发者ID:boobaa,项目名称:d7to8,代码行数:16,代码来源:D8BatchProcessForm.php

示例13: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     batch_test_stack(NULL, TRUE);
     switch ($form_state['storage']['step']) {
         case 1:
             batch_set(_batch_test_batch_1());
             break;
         case 2:
             batch_set(_batch_test_batch_2());
             break;
     }
     if ($form_state['storage']['step'] < 2) {
         $form_state['storage']['step']++;
         $form_state['rebuild'] = TRUE;
     }
     $form_state->setRedirect('batch_test.redirect');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:20,代码来源:BatchTestMultiStepForm.php

示例14: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     batch_test_stack(NULL, TRUE);
     $step = $form_state->get('step');
     switch ($step) {
         case 1:
             batch_set(_batch_test_batch_1());
             break;
         case 2:
             batch_set(_batch_test_batch_2());
             break;
     }
     if ($step < 2) {
         $form_state->set('step', ++$step);
         $form_state->setRebuild();
     }
     $form_state->setRedirect('batch_test.redirect');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:21,代码来源:BatchTestMultiStepForm.php

示例15: startBatchExpire

 /**
  * {@inheritodc}
  */
 public function startBatchExpire(FeedInterface $feed)
 {
     try {
         $feed->lock();
     } catch (LockException $e) {
         drupal_set_message(t('The feed became locked before the expiring could begin.'), 'warning');
         return;
     }
     $feed->clearStates();
     $ids = $feed->getType()->getProcessor()->getExpiredIds($feed);
     if (!$ids) {
         $feed->unlock();
         return;
     }
     $batch = ['title' => $this->t('Expiring: %title', ['%title' => $feed->label()]), 'init_message' => $this->t('Expiring: %title', ['%title' => $feed->label()]), 'progress_message' => $this->t('Expiring: %title', ['%title' => $feed->label()]), 'error_message' => $this->t('An error occored while expiring %title.', ['%title' => $feed->label()])];
     foreach ($ids as $id) {
         $batch['operations'][] = [[$this, 'expireItem'], [$feed, $id]];
     }
     $batch['operations'][] = [[$this, 'postExpire'], [$feed]];
     batch_set($batch);
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:24,代码来源:FeedExpireHandler.php


注:本文中的batch_set函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。