function _drush_bootstrap_output_prepare

8.0.x bootstrap.inc _drush_bootstrap_output_prepare()
6.x bootstrap.inc _drush_bootstrap_output_prepare()
7.x bootstrap.inc _drush_bootstrap_output_prepare()
5.x bootstrap.inc _drush_bootstrap_output_prepare()
master bootstrap.inc _drush_bootstrap_output_prepare()
1 call to _drush_bootstrap_output_prepare()
BaseBoot::bootstrap_and_dispatch in lib/Drush/Boot/BaseBoot.php
Main entrypoint to bootstrap the selected CMS and execute the selected command.

File

includes/bootstrap.inc, line 533

Code

function _drush_bootstrap_output_prepare() {
  // Note that as soon as we set the DRUSH_BACKEND context, we change
  // the behavior of drush_log().  It is therefore important that we
  // should not set this context until immediately before we call ob_start
  // (i.e., in this function).
  $backend = drush_set_context('DRUSH_BACKEND', drush_get_option('backend'));
  $quiet = drush_get_context('DRUSH_QUIET');

  if ($backend) {
    // Load options passed as a JSON encoded string through STDIN.
    $stdin_options = _drush_backend_get_stdin();
    if (is_array($stdin_options)) {
      drush_set_context('stdin', $stdin_options);
    }
    // Add an output buffer handler to collect output/pass through backend
    // packets. Using a chunksize of 2 ensures that each line is flushed
    // straight away.
    if ($quiet) {
      // Pass through of backend packets, discard regular output.
      ob_start('drush_backend_output_discard', 2);
    }
    else {
      // Collect output.
      ob_start('drush_backend_output_collect', 2);
    }
  }

  // In non-backend quiet mode we start buffering and discards it on command
  // completion.
  if ($quiet && !$backend) {
    ob_start();
  }
}