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


PHP batch_process函数代码示例

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


在下文中一共展示了batch_process函数的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: 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

示例3: doSubmitForm

 /**
  * {@inheritdoc}
  */
 public function doSubmitForm(&$form, FormStateInterface &$form_state)
 {
     if (!$form_state->isSubmitted()) {
         return;
     }
     // Execute form submit handlers.
     $this->executeSubmitHandlers($form, $form_state);
     // If batches were set in the submit handlers, we process them now,
     // possibly ending execution. We make sure we do not react to the batch
     // that is already being processed (if a batch operation performs a
     // \Drupal\Core\Form\FormBuilderInterface::submitForm).
     if (($batch =& $this->batchGet()) && !isset($batch['current_set'])) {
         // Store $form_state information in the batch definition.
         $batch['form_state'] = $form_state;
         $batch['progressive'] = !$form_state->isProgrammed();
         $response = batch_process();
         if ($batch['progressive']) {
             return $response;
         }
         // Execution continues only for programmatic forms.
         // For 'regular' forms, we get redirected to the batch processing
         // page. Form redirection will be handled in _batch_finished(),
         // after the batch is processed.
     }
     // Set a flag to indicate the form has been processed and executed.
     $form_state->setExecuted();
     // If no response has been set, process the form redirect.
     if (!$form_state->getResponse() && ($redirect = $this->redirectForm($form_state))) {
         $form_state->setResponse($redirect);
     }
     // If there is a response was set, return it instead of continuing.
     if (($response = $form_state->getResponse()) && $response instanceof Response) {
         return $response;
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:38,代码来源:FormSubmitter.php

示例4: 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

示例5: cancel

 /**
  * Block a user and remove or reassign their content.
  */
 public function cancel()
 {
     if (drush_get_option('delete-content')) {
         user_cancel(array(), $this->id(), 'user_cancel_delete');
     } else {
         user_cancel(array(), $this->id(), 'user_cancel_reassign');
     }
     // I got the following technique here: http://drupal.org/node/638712
     $batch =& batch_get();
     $batch['progressive'] = FALSE;
     batch_process();
 }
开发者ID:bjargud,项目名称:drush,代码行数:15,代码来源:UserSingleBase.php

示例6: checkTranslation

 /**
  * Checks for translation updates and displays the translations status.
  *
  * Manually checks the translation status without the use of cron.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirection to translations reports page.
  */
 public function checkTranslation()
 {
     $this->moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');
     // Check translation status of all translatable project in all languages.
     // First we clear the cached list of projects. Although not strictly
     // necessary, this is helpful in case the project list is out of sync.
     locale_translation_flush_projects();
     locale_translation_check_projects();
     // Execute a batch if required. A batch is only used when remote files
     // are checked.
     if (batch_get()) {
         return batch_process('admin/reports/translations');
     }
     return $this->redirect('locale.translate_status');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:23,代码来源:LocaleController.php

示例7: checkTranslation

 /**
  * Checks for translation updates and displays the translations status.
  *
  * Manually checks the translation status without the use of cron.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirection to translations reports page.
  */
 public function checkTranslation()
 {
     $this->moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');
     // Check translation status of all translatable project in all languages.
     // First we clear the cached list of projects. Although not strictly
     // necessary, this is helpful in case the project list is out of sync.
     locale_translation_flush_projects();
     locale_translation_check_projects();
     // Execute a batch if required. A batch is only used when remote files
     // are checked.
     if (batch_get()) {
         return batch_process('admin/reports/translations');
     }
     // @todo Use $this->redirect() after https://drupal.org/node/1978926.
     return new RedirectResponse($this->getUrlGenerator()->generateFromPath('admin/reports/translations', array('absolute' => TRUE)));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:LocaleController.php

示例8: doSubmitForm

 /**
  * {@inheritdoc}
  */
 public function doSubmitForm(&$form, &$form_state)
 {
     if (!$form_state['submitted']) {
         return;
     }
     // Execute form submit handlers.
     $this->executeSubmitHandlers($form, $form_state);
     // If batches were set in the submit handlers, we process them now,
     // possibly ending execution. We make sure we do not react to the batch
     // that is already being processed (if a batch operation performs a
     // \Drupal\Core\Form\FormBuilderInterface::submitForm).
     if (($batch =& $this->batchGet()) && !isset($batch['current_set'])) {
         // Store $form_state information in the batch definition.
         // We need the full $form_state when either:
         // - Some submit handlers were saved to be called during batch
         //   processing. See self::executeSubmitHandlers().
         // - The form is multistep.
         // In other cases, we only need the information expected by
         // self::redirectForm().
         if ($batch['has_form_submits'] || !empty($form_state['rebuild'])) {
             $batch['form_state'] = $form_state;
         } else {
             $batch['form_state'] = array_intersect_key($form_state, array_flip(array('programmed', 'rebuild', 'storage', 'no_redirect', 'redirect', 'redirect_route')));
         }
         $batch['progressive'] = !$form_state['programmed'];
         $response = batch_process();
         if ($batch['progressive']) {
             return $response;
         }
         // Execution continues only for programmatic forms.
         // For 'regular' forms, we get redirected to the batch processing
         // page. Form redirection will be handled in _batch_finished(),
         // after the batch is processed.
     }
     // Set a flag to indicate the the form has been processed and executed.
     $form_state['executed'] = TRUE;
     // If no response has been set, process the form redirect.
     if (!isset($form_state['response']) && ($redirect = $this->redirectForm($form_state))) {
         $form_state['response'] = $redirect;
     }
     // If there is a response was set, return it instead of continuing.
     if (isset($form_state['response']) && $form_state['response'] instanceof Response) {
         return $form_state['response'];
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:48,代码来源:FormSubmitter.php

示例9: action_begin

function action_begin()
{
    $transaction = TransactionSession::getFromSession();
    if (!$transaction) {
        drupal_access_denied();
    }
    // If there are no root entities, throw an error.
    $root_entities = $transaction->getRootEntities();
    if (count($root_entities) <= 0) {
        drupal_access_denied();
    }
    // Launch a batch session to get all the dependencies of the root entities.
    $queue = new \Drupal\publisher\Batch\BeginOperationQueue();
    foreach ($root_entities as $root_entity) {
        $queue->addOperation(new \Drupal\publisher\Batch\BeginOperation(), $root_entity['entity'], $transaction->getRemote(), $root_entity['options']);
    }
    $queue->start();
    // We'll need to call batch_process because we're not in the context of a
    // form's submit handler.
    batch_process('publisher/feedback');
}
开发者ID:sammarks,项目名称:publisher,代码行数:21,代码来源:send.php

示例10: processUserSyncFormSubmit

 /**
  * Runs batch process of user accounts synchronization on submit form above
  * 
  * @param array &$form      Form descriptions
  * @param array &$formState Form state
  *  
  * @return void
  */
 public function processUserSyncFormSubmit(array &$form, array &$formState)
 {
     if (t(self::LC_OP_NAME_USERSYNC) == $formState['values']['op']) {
         if ($this->isUserSynchronizationRequired()) {
             variable_set('lc_user_sync_notify', $formState['values']['notify_users']);
             // Calculate number of steps and list ot operations
             $maxSteps = $this->totalNonSynchronizedAccounts;
             // $this->userAccountsPerStepCounter) + 1;
             $operations = array();
             for ($i = 0; $i < $maxSteps; $i++) {
                 $operations[] = array('lcConnectorUserSync', array());
             }
             // Initialize batch (to set title).
             $batch = array('title' => t('Synchronize user accounts'), 'init_message' => t('Starting user accounts synchronization...'), 'operations' => $operations, 'finished' => 'lcConnectorUserSyncFinishedCallback');
             batch_set($batch);
             // Run batch process
             batch_process();
         } else {
             drupal_set_message(t('User accounts synchronization is not required.'));
         }
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:30,代码来源:UserSync.php

示例11: update_batch

function update_batch()
{
    global $base_url;
    // During the update, bring the site offline so that schema changes do not
    // affect visiting users.
    $_SESSION['site_offline'] = variable_get('site_offline', FALSE);
    if ($_SESSION['site_offline'] == FALSE) {
        variable_set('site_offline', TRUE);
    }
    $operations = array();
    // Set the installed version so updates start at the correct place.
    foreach ($_POST['start'] as $module => $version) {
        drupal_set_installed_schema_version($module, $version - 1);
        $updates = drupal_get_schema_versions($module);
        $max_version = max($updates);
        if ($version <= $max_version) {
            foreach ($updates as $update) {
                if ($update >= $version) {
                    $operations[] = array('update_do_one', array($module, $update));
                }
            }
        }
    }
    $batch = array('operations' => $operations, 'title' => 'Updating', 'init_message' => 'Starting updates', 'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.', 'finished' => 'update_finished');
    batch_set($batch);
    batch_process($base_url . '/update.php?op=results', $base_url . '/update.php');
}
开发者ID:veggieryan,项目名称:drupal,代码行数:27,代码来源:update.php

示例12: processBatch

 public function processBatch()
 {
     $batch =& batch_get();
     $batch['progressive'] = FALSE;
     batch_process();
 }
开发者ID:ian-yin,项目名称:drupalextension,代码行数:6,代码来源:Drupal7.php

示例13: install_run_task

/**
 * Run an individual installation task.
 *
 * @param $task
 *   An array of information about the task to be run.
 * @param $install_state
 *   An array of information about the current installation state. This is
 *   passed in by reference so that it can be modified by the task.
 * @return
 *   The output of the task function, if there is any.
 */
function install_run_task($task, &$install_state)
{
    $function = $task['function'];
    if ($task['type'] == 'form') {
        require_once DRUPAL_ROOT . '/includes/form.inc';
        if ($install_state['interactive']) {
            // For interactive forms, build the form and ensure that it will not
            // redirect, since the installer handles its own redirection only after
            // marking the form submission task complete.
            $form_state = array('args' => array(&$install_state), 'no_redirect' => TRUE);
            $form = drupal_build_form($function, $form_state);
            // If a successful form submission did not occur, the form needs to be
            // rendered, which means the task is not complete yet.
            if (empty($form_state['executed'])) {
                $install_state['task_not_complete'] = TRUE;
                return drupal_render($form);
            }
            // Otherwise, return nothing so the next task will run in the same
            // request.
            return;
        } else {
            // For non-interactive forms, submit the form programmatically with the
            // values taken from the installation state. Throw an exception if any
            // errors were encountered.
            $form_state = array('values' => !empty($install_state['forms'][$function]) ? $install_state['forms'][$function] : array());
            drupal_form_submit($function, $form_state, $install_state);
            $errors = form_get_errors();
            if (!empty($errors)) {
                throw new Exception(implode("\n", $errors));
            }
        }
    } elseif ($task['type'] == 'batch') {
        // Start a new batch based on the task function, if one is not running
        // already.
        $current_batch = variable_get('install_current_batch');
        if (!$install_state['interactive'] || !$current_batch) {
            $batch = $function($install_state);
            if (empty($batch)) {
                // If the task did some processing and decided no batch was necessary,
                // there is nothing more to do here.
                return;
            }
            batch_set($batch);
            // For interactive batches, we need to store the fact that this batch
            // task is currently running. Otherwise, we need to make sure the batch
            // will complete in one page request.
            if ($install_state['interactive']) {
                variable_set('install_current_batch', $function);
            } else {
                $batch =& batch_get();
                $batch['progressive'] = FALSE;
            }
            // Process the batch. For progressive batches, this will redirect.
            // Otherwise, the batch will complete.
            batch_process(install_redirect_url($install_state), install_full_redirect_url($install_state));
        } elseif ($current_batch == $function) {
            include_once DRUPAL_ROOT . '/includes/batch.inc';
            $output = _batch_page();
            // The task is complete when we try to access the batch page and receive
            // FALSE in return, since this means we are at a URL where we are no
            // longer requesting a batch ID.
            if ($output === FALSE) {
                // Return nothing so the next task will run in the same request.
                variable_del('install_current_batch');
                return;
            } else {
                // We need to force the page request to end if the task is not
                // complete, since the batch API sometimes prints JSON output
                // rather than returning a themed page.
                $install_state['task_not_complete'] = $install_state['stop_page_request'] = TRUE;
                return $output;
            }
        }
    } else {
        // For normal tasks, just return the function result, whatever it is.
        return $function($install_state);
    }
}
开发者ID:blipp,项目名称:drupal,代码行数:89,代码来源:install.php

示例14: install_tasks

/**
 * Tasks performed after the database is initialized.
 */
function install_tasks($profile, $task)
{
    global $base_url, $install_locale;
    // Bootstrap newly installed Drupal, while preserving existing messages.
    $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $_SESSION['messages'] = $messages;
    // URL used to direct page requests.
    $url = $base_url . '/install.php?locale=' . $install_locale . '&profile=' . $profile;
    // Build a page for final tasks.
    if (empty($task)) {
        variable_set('install_task', 'profile-install');
        $task = 'profile-install';
    }
    // We are using a list of if constructs here to allow for
    // passing from one task to the other in the same request.
    // Install profile modules.
    if ($task == 'profile-install') {
        $modules = variable_get('install_profile_modules', array());
        $files = module_rebuild_cache();
        variable_del('install_profile_modules');
        $operations = array();
        foreach ($modules as $module) {
            $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
        }
        $batch = array('operations' => $operations, 'finished' => '_install_profile_batch_finished', 'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_name())), 'error_message' => st('The installation has encountered an error.'));
        // Start a batch, switch to 'profile-install-batch' task. We need to
        // set the variable here, because batch_process() redirects.
        variable_set('install_task', 'profile-install-batch');
        batch_set($batch);
        batch_process($url, $url);
    }
    // We are running a batch install of the profile's modules.
    // This might run in multiple HTTP requests, constantly redirecting
    // to the same address, until the batch finished callback is invoked
    // and the task advances to 'locale-initial-import'.
    if ($task == 'profile-install-batch') {
        include_once 'includes/batch.inc';
        $output = _batch_page();
    }
    // Import interface translations for the enabled modules.
    if ($task == 'locale-initial-import') {
        if (!empty($install_locale) && $install_locale != 'en') {
            include_once 'includes/locale.inc';
            // Enable installation language as default site language.
            locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE);
            // Collect files to import for this language.
            $batch = locale_batch_by_language($install_locale, '_install_locale_initial_batch_finished');
            if (!empty($batch)) {
                // Remember components we cover in this batch set.
                variable_set('install_locale_batch_components', $batch['#components']);
                // Start a batch, switch to 'locale-batch' task. We need to
                // set the variable here, because batch_process() redirects.
                variable_set('install_task', 'locale-initial-batch');
                batch_set($batch);
                batch_process($url, $url);
            }
        }
        // Found nothing to import or not foreign language, go to next task.
        $task = 'configure';
    }
    if ($task == 'locale-initial-batch') {
        include_once 'includes/batch.inc';
        include_once 'includes/locale.inc';
        $output = _batch_page();
    }
    if ($task == 'configure') {
        if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) {
            // Site already configured: This should never happen, means re-running
            // the installer, possibly by an attacker after the 'install_task' variable
            // got accidentally blown somewhere. Stop it now.
            install_already_done_error();
        }
        $form = drupal_get_form('install_configure_form', $url);
        if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) {
            // Not submitted yet: Prepare to display the form.
            $output = $form;
            drupal_set_title(st('Configure site'));
            // Warn about settings.php permissions risk
            $settings_dir = './' . conf_path();
            $settings_file = $settings_dir . '/settings.php';
            if (!drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($settings_dir, FILE_NOT_WRITABLE, 'dir')) {
                drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, please consult the <a href="@handbook_url">on-line handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/getting-started')), 'error');
            } else {
                drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file)));
            }
            // Add JavaScript validation.
            _user_password_dynamic_validation();
            drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
            // We add these strings as settings because JavaScript translation does not
            // work on install time.
            drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')), 'cleanURL' => array('success' => st('Your server has been successfully tested to support this feature.'), 'failure' => st('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => st('Testing clean URLs...'))), 'setting');
            drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.cleanURLsInstallCheck();
//.........这里部分代码省略.........
开发者ID:alexismb5,项目名称:ckan-drupal,代码行数:101,代码来源:install.php

示例15: confirmCancel

 /**
  * Confirms cancelling a user account via an email link.
  *
  * @param \Drupal\user\UserInterface $user
  *   The user account.
  * @param int $timestamp
  *   The timestamp.
  * @param string $hashed_pass
  *   The hashed password.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirect response.
  */
 public function confirmCancel(UserInterface $user, $timestamp = 0, $hashed_pass = '')
 {
     // Time out in seconds until cancel URL expires; 24 hours = 86400 seconds.
     $timeout = 86400;
     $current = REQUEST_TIME;
     // Basic validation of arguments.
     $account_data = $this->userData->get('user', $user->id());
     if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) {
         // Validate expiration and hashed password/login.
         if ($timestamp <= $current && $current - $timestamp < $timeout && $user->id() && $timestamp >= $user->getLastLoginTime() && Crypt::hashEquals($hashed_pass, user_pass_rehash($user, $timestamp))) {
             $edit = array('user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : $this->config('user.settings')->get('notify.status_canceled'));
             user_cancel($edit, $user->id(), $account_data['cancel_method']);
             // Since user_cancel() is not invoked via Form API, batch processing
             // needs to be invoked manually and should redirect to the front page
             // after completion.
             return batch_process('');
         } else {
             drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'error');
             return $this->redirect('entity.user.cancel_form', ['user' => $user->id()], ['absolute' => TRUE]);
         }
     }
     throw new AccessDeniedHttpException();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:36,代码来源:UserController.php


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