You are here

public function WebformEditorialController::drush in Webform 8.5

Returns webform drush.

Return value

array A renderable array containing webform entity scheme.

1 string reference to 'WebformEditorialController::drush'
webform_editorial.routing.yml in modules/webform_editorial/webform_editorial.routing.yml
modules/webform_editorial/webform_editorial.routing.yml

File

modules/webform_editorial/src/Controller/WebformEditorialController.php, line 401

Class

WebformEditorialController
Provides route responses for webform editorial.

Namespace

Drupal\webform_editorial\Controller

Code

public function drush() {
  module_load_include('inc', 'webform', 'drush/webform.drush');
  $build = [];
  $build['title'] = [
    '#prefix' => '<h1>',
    '#suffix' => '</h1>',
    '#markup' => $this
      ->t('Webform: Drush editorial'),
  ];

  // Header.
  $header = [
    [
      'data' => $this
        ->t('Name'),
      'width' => '30%',
    ],
    [
      'data' => $this
        ->t('Value'),
      'width' => '70%',
    ],
  ];
  $build = [];
  $commands = webform_drush_command();
  foreach ($commands as $command_name => $command) {
    $build[$command_name] = [];
    $build[$command_name]['title'] = [
      '#prefix' => '<h2>',
      '#suffix' => '</h2>',
      '#markup' => $command_name,
    ];
    $build[$command_name]['description'] = [
      '#prefix' => '<p>',
      '#suffix' => '</p>',
      '#markup' => $command['description'],
    ];
    if ($help = webform_drush_help('drush:' . $command_name)) {
      $build[$command_name]['help'] = [
        '#prefix' => '<address>',
        '#suffix' => '</address>',
        '#markup' => $help,
      ];
    }
    $properties = [
      'arguments',
      'options',
      'examples',
    ];
    foreach ($properties as $property) {
      if (isset($command[$property])) {
        $rows = [];
        foreach ($command[$property] as $name => $value) {
          $rows[] = [
            'data' => [
              [
                'data' => $name,
              ],
              [
                'data' => $value,
              ],
            ],
          ];
        }
        $build[$command_name][$property] = $this
          ->buildTable($property, $header, $rows, 'h3', FALSE);
      }
    }
    $build[$command_name]['hr'] = [
      '#markup' => '<br/><hr/>',
    ];
  }
  return $this
    ->response($build);
}