You are here

protected function YamlFormHelpManager::buildLibraries in YAML Form 8

Build the libraries section.

Return value

array An render array containing the libraries section.

1 call to YamlFormHelpManager::buildLibraries()
YamlFormHelpManager::buildIndex in src/YamlFormHelpManager.php
Build the main help page for the YAML Form module.

File

src/YamlFormHelpManager.php, line 286

Class

YamlFormHelpManager
Form help manager.

Namespace

Drupal\yamlform

Code

protected function buildLibraries() {

  // Libraries.
  $build = [
    'title' => [
      '#markup' => $this
        ->t('External Libraries'),
      '#prefix' => '<h3 id="libraries">',
      '#suffix' => '</h3>',
    ],
    'content' => [
      '#prefix' => '<div>',
      '#suffix' => '</div>',
      'description' => [
        '#markup' => '<p>' . $this
          ->t('The YAML Form module utilizes the third-party Open Source libraries listed below to enhance form elements and to provide additional functionality. It is recommended that these libraries be installed in your Drupal installations /libraries directory. If these libraries are not installed, they are automatically loaded from a CDN.') . '</p>' . '<p>' . $this
          ->t('Currently the best way to download all the needed third party libraries is to either add <a href=":href">yamlform.libraries.make.yml</a> to your drush make file or execute the below drush command from the root of your Drupal installation.', [
          ':href' => 'http://cgit.drupalcode.org/yamlform/tree/yamlform.libraries.make.yml',
        ]) . '</p>' . '<hr/><pre>drush yamlform-libraries-download</pre><hr/><br/>',
      ],
      'libraries' => [
        '#prefix' => '<dl>',
        '#suffix' => '</dl>',
      ],
    ],
  ];
  $libraries = $this->librariesManager
    ->getLibraries();
  foreach ($libraries as $library_name => $library) {
    $build['content']['libraries'][$library_name] = [
      'title' => [
        '#type' => 'link',
        '#title' => $library['title'],
        '#url' => $library['url'],
        '#prefix' => '<dt>',
        '#suffix' => '</dt>',
      ],
      'description' => [
        '#markup' => $library['description'] . '<br/><em>(' . $library['notes'] . ')</em>',
        '#prefix' => '<dd>',
        '#suffix' => '</dd>',
      ],
    ];
  }
  return $build;
}