FrontPage.php in Form mode manager 8
File
modules/form_mode_manager_examples/src/Controller/FrontPage.php
View source
<?php
namespace Drupal\form_mode_manager_examples\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FrontPage extends ControllerBase {
protected $fmmExampleEntityBundles = [
'node_form_mode_example',
];
protected $formModeManager;
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
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),
],
],
],
];
}
}
Classes
Name |
Description |
FrontPage |
Simple front page controller for form_mode_manager_examples module. |