You are here

public function YamlFormAddonsController::index in YAML Form 8

Returns the YAML Form extend page.

Return value

array The form submission form.

1 string reference to 'YamlFormAddonsController::index'
yamlform.routing.yml in ./yamlform.routing.yml
yamlform.routing.yml

File

src/Controller/YamlFormAddonsController.php, line 47

Class

YamlFormAddonsController
Provides route responses for form add-on.

Namespace

Drupal\yamlform\Controller

Code

public function index() {
  $build = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'yamlform-addons',
        'js-yamlform-details-toggle',
        'yamlform-details-toggle',
      ],
    ],
  ];
  $build['#attached']['library'][] = 'yamlform/yamlform.admin';
  $build['#attached']['library'][] = 'yamlform/yamlform.element.details.toggle';
  $categories = $this->addons
    ->getCategories();
  foreach ($categories as $category_name => $category) {
    $build[$category_name] = [
      '#type' => 'details',
      '#title' => $category['title'],
      '#open' => TRUE,
    ];
    $projects = $this->addons
      ->getProjects($category_name);
    foreach ($projects as &$project) {
      $project['description'] .= ' ' . '<br/><small>' . $project['url']
        ->toString() . '</small>';
    }
    $build[$category_name]['content'] = [
      '#theme' => 'admin_block_content',
      '#content' => $projects,
    ];
  }
  return $build;
}