function _update_manager_check_backends

Same name in other branches
  1. 7.x modules/update/update.manager.inc \_update_manager_check_backends()
  2. 9 core/modules/update/update.manager.inc \_update_manager_check_backends()
  3. 8.9.x core/modules/update/update.manager.inc \_update_manager_check_backends()
  4. 11.x core/modules/update/update.manager.inc \_update_manager_check_backends()

Checks for file transfer backends and prepares a form fragment about them.

Parameters

array $form: Reference to the form array we're building.

string $operation: The update manager operation we're in the middle of. Can be either 'update' or 'install'. Use to provide operation-specific interface text.

Return value

bool TRUE if the update manager should continue to the next step in the workflow, or FALSE if we've hit a fatal configuration and must halt the workflow.

3 calls to _update_manager_check_backends()
UpdateManagerInstall::buildForm in core/modules/update/src/Form/UpdateManagerInstall.php
Form constructor.
UpdateManagerUpdate::buildForm in core/modules/update/src/Form/UpdateManagerUpdate.php
Form constructor.
UpdateReady::buildForm in core/modules/update/src/Form/UpdateReady.php
Form constructor.

File

core/modules/update/update.manager.inc, line 89

Code

function _update_manager_check_backends(&$form, $operation) {
    // If file transfers will be performed locally, we do not need to display any
    // warnings or notices to the user and should automatically continue the
    // workflow, since we won't be using a FileTransfer backend that requires
    // user input or a specific server configuration.
    if (update_manager_local_transfers_allowed()) {
        return TRUE;
    }
    // Otherwise, show the available backends.
    $form['available_backends'] = [
        '#prefix' => '<p>',
        '#suffix' => '</p>',
    ];
    $available_backends = drupal_get_filetransfer_info();
    if (empty($available_backends)) {
        if ($operation == 'update') {
            $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this interface. Instead, update modules and themes by uploading the new versions directly to the server, as documented in <a href=":doc_url">Extending Drupal</a>.', [
                ':doc_url' => 'https://www.drupal.org/docs/extending-drupal/overview',
            ]);
        }
        else {
            $form['available_backends']['#markup'] = t('Your server does not support adding modules and themes from this interface. Instead, add modules and themes by uploading them directly to the server, as documented in <a href=":doc_url">Extending Drupal</a>.', [
                ':doc_url' => 'https://www.drupal.org/docs/extending-drupal/overview',
            ]);
        }
        return FALSE;
    }
    $backend_names = [];
    foreach ($available_backends as $backend) {
        $backend_names[] = $backend['title'];
    }
    if ($operation == 'update') {
        $form['available_backends']['#markup'] = \Drupal::translation()->formatPlural(count($available_backends), 'Updating modules and themes requires <strong>@backends access</strong> to your server. See <a href=":doc_url">Extending Drupal</a> for other update methods.', 'Updating modules and themes requires access to your server via one of the following methods: <strong>@backends</strong>. See <a href=":doc_url">Extending Drupal</a> for other update methods.', [
            '@backends' => implode(', ', $backend_names),
            ':doc_url' => 'https://www.drupal.org/docs/extending-drupal/overview',
        ]);
    }
    else {
        $form['available_backends']['#markup'] = \Drupal::translation()->formatPlural(count($available_backends), 'Adding modules and themes requires <strong>@backends access</strong> to your server. See <a href=":doc_url">Extending Drupal</a> for other methods.', 'Adding modules and themes requires access to your server via one of the following methods: <strong>@backends</strong>. See <a href=":doc_url">Extending Drupal</a> for other methods.', [
            '@backends' => implode(', ', $backend_names),
            ':doc_url' => 'https://www.drupal.org/docs/extending-drupal/overview',
        ]);
    }
    return TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.