You are here

public function WebformHelpManager::buildAddOns in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformHelpManager.php \Drupal\webform\WebformHelpManager::buildAddOns()

Build the add-ons section.

Parameters

bool $docs: Set to TRUE to build exportable HTML documentation.

Return value

array An render array containing the add-ons section.

Overrides WebformHelpManagerInterface::buildAddOns

File

src/WebformHelpManager.php, line 525

Class

WebformHelpManager
Webform help manager.

Namespace

Drupal\webform

Code

public function buildAddOns($docs = FALSE) {
  $build = [
    'quote' => [
      '#markup' => '<table class="views-view-grid" width="100%"><tr>
<td><blockquote>' . $this
        ->t('The Webform module for Drupal provides all the features expected from an enterprise proprietary form builder combined with the flexibility and openness of Drupal.') . '</blockquote></td>
<td width="100"><img src="https://www.drupal.org/files/webform_stacked-logo_256.png" width="256" alt="' . $this
        ->t('Webform logo') . '" /></td>
</tr></table>',
      '#allowed_tags' => Xss::getAdminTagList(),
    ],
    'content' => [
      '#markup' => '<p>' . $this
        ->t("Below is a list of modules and projects that extend and/or provide additional functionality to the Webform module and Drupal's Form API.") . '</p>' . '<hr/>' . '<p>★ = ' . $this
        ->t('Recommended') . '</p>',
    ],
  ];
  $categories = $this->addOnsManager
    ->getCategories();
  foreach ($categories as $category_name => $category) {
    $build['content'][$category_name]['title'] = [
      '#markup' => $category['title'],
      '#prefix' => '<h3 id="' . $category_name . '">',
      '#suffix' => '</h3>',
    ];
    $build['content'][$category_name]['projects'] = [
      '#prefix' => '<dl>',
      '#suffix' => '</dl>',
    ];
    $projects = $this->addOnsManager
      ->getProjects($category_name);
    foreach ($projects as $project_name => $project) {
      $build['content'][$category_name]['projects'][$project_name] = [
        'title' => [
          '#type' => 'link',
          '#title' => Markup::create($project['title'] . (!empty($project['experimental']) ? ' [' . $this
            ->t('EXPERIMENTAL') . ']' : '')),
          '#url' => $project['url'],
          '#prefix' => '<dt>',
          '#suffix' => (isset($project['recommended']) ? ' ★' : '') . '</dt>',
        ],
        'description' => [
          '#markup' => $project['description'],
          '#prefix' => '<dd>',
          '#suffix' => '</dd>',
        ],
      ];
    }
  }
  return $build;
}