public function dump($file = '') { $file_suffix = ''; $table_selection = $this->get_expanded_table_selection(); $file = $this->dumpFile($file); $cmd = $this->dumpCmd($table_selection); // Gzip the output from dump command(s) if requested. if (drush_get_option('gzip')) { $cmd .= ' | gzip -f'; $file_suffix .= '.gz'; } if ($file) { $file .= $file_suffix; $cmd .= ' > ' . drush_escapeshellarg($file); } // Avoid the php memory of the $output array in drush_shell_exec(). if (!($return = drush_op_system($cmd))) { if ($file) { drush_log(dt('Database dump saved to !path', array('!path' => $file)), LogLevel::SUCCESS); drush_backend_set_result($file); } } else { return drush_set_error('DRUSH_SQL_DUMP_FAIL', 'Database dump failed'); } }
public function extractOutput($structured_data) { $return = drush_backend_get_result(); if (empty($return)) { drush_backend_set_result($structured_data); } }
public function dump($file = '') { $table_selection = $this->get_expanded_table_selection(); $file = $this->dumpFile($file); list($cmd, $file) = $this->dumpCmd($table_selection, $file); list($cmd, $file) = $this->dumpGzip($cmd, $file); // Avoid the php memory of the $output array in drush_shell_exec(). if (!($return = drush_op_system($cmd))) { if ($file) { drush_log(dt('Database dump saved to !path', array('!path' => $file)), 'success'); drush_backend_set_result($file); } } else { return drush_set_error('DRUSH_SQL_DUMP_FAIL', 'Database dump failed'); } }
/** * Execute a view and show a count of the results, or the rendered HTML. * * @command views-execute * * @param string $view The name of the view to execute. * @param string $display The display ID to execute. If none specified, the default display will be used. * @param string $view_args A comma delimited list of values, corresponding to contextual filters. * @option count Display a count of the results instead of each row. * @option show-admin-links Show contextual admin links in the rendered markup. * @bootstrap DRUSH_BOOTSTRAP_DRUPAL_FULL * @usage drush views-execute my_view * Show the rendered HTML for the default display for the my_view View. * @usage drush views-execute my_view page_1 3 --count * Show a count of my_view:page_1 where the first contextual filter value is 3. * @usage drush views-execute my_view page_1 3,foo * Show the rendered HTML of my_view:page_1 where the first two contextual filter values are 3 and 'foo' respectively. * @bootstrap DRUSH_BOOTSTRAP_DRUPAL_FULL * @complete \Drush\CommandFiles\core\ViewsCommands::complete * @validate-entity-load view views * @aliases vex * * @return string */ public function execute($view, $display = NULL, $view_args = NULL, $options = ['count' => 0, 'show-admin-links' => 0]) { $view = Views::getView($view); // Set the display and execute the view. $view->setDisplay($display); $view->preExecute(_convert_csv_to_array($view_args)); $view->execute(); if (empty($view->result)) { $this->logger->log(LogLevel::WARNING, dt('No results returned for this view.')); return NULL; } elseif ($options['count']) { drush_backend_set_result(count($view->result)); drush_print(count($view->result)); return NULL; } else { // Don't show admin links in markup by default. $view->hide_admin_links = !$options['show-admin-links']; $build = $view->preview(); return (string) \Drupal::service('renderer')->renderPlain($build); } }