• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP batch_set函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: updateTheme

 /**
  * Callback for updating a theme.
  *
  * @param array $form
  *   Nested array of form elements that comprise the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public static function updateTheme(array $form, FormStateInterface $form_state)
 {
     if ($theme = SystemThemeSettings::getTheme($form, $form_state)) {
         // Due to the fact that the batch API stores it's arguments in DB storage,
         // theme based objects cannot be passed as an operation argument here.
         // During _batch_page(), the DB item will attempt to restore the arguments
         // using unserialize() and the autoload fix include added below may not
         // yet have been invoked to register the theme namespaces. So instead,
         // we capture the relevant information needed to reconstruct these objects
         // in the batch processing callback.
         $theme_name = $theme->getName();
         // Create an operation for each update.
         $operations = [];
         foreach ($theme->getPendingUpdates() as $update) {
             $operations[] = [[__CLASS__, 'batchProcessUpdate'], [$theme_name, $update->getProvider() . ':' . $update->getSchema()]];
         }
         if ($operations) {
             $variables = ['@theme_title' => $theme->getTitle()];
             batch_set(['operations' => $operations, 'finished' => [__CLASS__, 'batchFinished'], 'title' => t('Updating @theme_title', $variables), 'init_message' => \Drupal::translation()->formatPlural(count($operations), 'Initializing 1 theme update for @theme_title...', 'Initializing @count theme updates for @theme_title...', $variables), 'progress_message' => t('Processing update @current of @total...', $variables), 'error_message' => t('An error was encountered while attempting to update the @theme_title theme.', $variables), 'file' => Bootstrap::autoloadFixInclude()]);
         }
     }
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:30,代码来源:Schemas.php


示例17: submitForm

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $batch = [
      'title' => $this->t('Clearing Flag data'),
      'operations' => [
        [
          [__CLASS__, 'resetFlags'], [],
        ],
        [
          [__CLASS__, 'clearTables'], [],
        ],
      ],
      'progress_message' => $this->t('Clearing Flag data...'),
    ];
    batch_set($batch);

    drupal_set_message($this->t(
      'Flag data has been cleared. <a href="@uninstall-url">Proceed with uninstallation.</a>',
      [
        '@uninstall-url' => Url::fromRoute('system.modules_uninstall')->toString(),
      ]
    ));
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:25,代码来源:ClearAllForm.php


示例18: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $values = $form_state->getValues();
     $types = array_filter($values['types']);
     if (count($types) > 0) {
         try {
             foreach ($types as $bundle) {
                 $result = db_select('node');
                 $query = $result->fields('node', array('nid'));
                 $query = $result->condition('type', $bundle);
                 $query = $result->execute()->fetchAll();
                 $last_row = count($query);
                 $operations = array();
                 if (!empty($last_row)) {
                     $message = t('All nodes of type @content mark for deletion', array('@content' => $bundle));
                     \Drupal::logger('bulkdelete')->notice($message);
                     // Create batch of 20 nodes.
                     $count = 1;
                     foreach ($query as $row) {
                         $nids[] = $row->nid;
                         if ($count % 20 === 0 || $count === $last_row) {
                             $operations[] = array(array(get_class($this), 'processBatch'), array($nids));
                             $nids = array();
                         }
                         ++$count;
                     }
                     // Set up the Batch API
                     $batch = array('operations' => $operations, 'finished' => array(get_class($this), 'bulkdelete_finishedBatch'), 'title' => t('Node bulk delete'), 'init_message' => t('Starting nodes deletion.'), 'progress_message' => t('Completed @current step of @total.'), 'error_message' => t('Bulk node deletion has encountered an error.'));
                     batch_set($batch);
                 }
             }
         } catch (Exception $e) {
             foreach ($e->getErrors() as $error_message) {
                 drupal_set_message($error_message, 'error');
             }
         }
     }
 }
开发者ID:rahulseth,项目名称:bulkdelete,代码行数:41,代码来源:BulkDeleteForm.php


示例19: generateBatchContent

 /**
  * Method responsible for creating content when
  * the number of elements is greater than 50.
  */
 private function generateBatchContent($values)
 {
     // Setup the batch operations and save the variables.
     $operations[] = array('devel_generate_operation', array($this, 'batchContentPreNode', $values));
     // add the kill operation
     if ($values['kill']) {
         $operations[] = array('devel_generate_operation', array($this, 'batchContentKill', $values));
     }
     // add the operations to create the nodes
     for ($num = 0; $num < $values['num']; $num++) {
         $operations[] = array('devel_generate_operation', array($this, 'batchContentAddNode', $values));
     }
     // start the batch
     $batch = array('title' => $this->t('Generating Content'), 'operations' => $operations, 'finished' => 'devel_generate_batch_finished', 'file' => drupal_get_path('module', 'devel_generate') . '/devel_generate.batch.inc');
     batch_set($batch);
 }
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:20,代码来源:ContentDevelGenerate.php


示例20: submitConfirmForm

 /**
  * Credential form submission handler.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitConfirmForm(array &$form, FormStateInterface $form_state)
 {
     $batch = ['title' => $this->t('Running upgrade'), 'progress_message' => '', 'operations' => [[['Drupal\\migrate_upgrade\\MigrateUpgradeRunBatch', 'run'], [$form_state->get('migration_ids')]]], 'finished' => ['Drupal\\migrate_upgrade\\MigrateUpgradeRunBatch', 'finished']];
     batch_set($batch);
     $form_state->setRedirect('<front>');
     \Drupal::state()->set('migrate_upgrade.performed', REQUEST_TIME);
 }
开发者ID:Wylbur,项目名称:eight,代码行数:15,代码来源:MigrateUpgradeForm.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP batch_test_stack函数代码示例发布时间:2022-05-24
下一篇:
PHP batch_process函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap