You are here

public function FrontPage::content in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 modules/examples/src/Controller/FrontPage.php \Drupal\form_mode_manager_examples\Controller\FrontPage::content()

Displays useful information for form_mode_manager on the front page.

1 string reference to 'FrontPage::content'
form_mode_manager_examples.routing.yml in modules/form_mode_manager_examples/form_mode_manager_examples.routing.yml
modules/form_mode_manager_examples/form_mode_manager_examples.routing.yml

File

modules/form_mode_manager_examples/src/Controller/FrontPage.php, line 60

Class

FrontPage
Simple front page controller for form_mode_manager_examples module.

Namespace

Drupal\form_mode_manager_examples\Controller

Code

public function content() {
  $items = [];
  foreach ($this->fmmExampleEntityBundles as $node_type) {
    $node_type = $this->entityTypeManager
      ->getStorage('node_type')
      ->load($node_type);
    $items['#items'][] = $this
      ->t('<a href="@url">@label', [
      '@url' => Url::fromRoute('node.add', [
        'node_type' => $node_type
          ->id(),
      ])
        ->toString(),
      '@label' => $node_type
        ->label(),
    ]);
  }
  return [
    'intro' => [
      '#markup' => '<p>' . $this
        ->t('Welcome to Form Mode Manager example.') . '</p>',
    ],
    'description' => [
      '#markup' => '<p>' . $this
        ->t('Form Mode Manager allows to use form_mode implement on Drupal 8 on each Entity.') . '</p>' . '<p>' . $this
        ->t('You can test the functionality with custom content types created for the demonstration of features Form Mode Manager examples:') . '</p>',
    ],
    'content_types' => [
      '#type' => 'item',
      'list' => [
        '#theme' => 'item_list',
        '#items' => [
          array_values($items),
        ],
      ],
    ],
  ];
}