Drupal module demo - module_hero_v2
module_hero.info.yml:
```
name: "Module Hero"
description: "We are going to be Drupal 8 module heros at the end"
type: module
core: 8.x
```
module_hero.routing.yml:
```
module_hero.herolist:
path: '/herolist'
defaults:
_controller: '\Drupal\module_hero\Controller\HeroController::heroList'
_title: 'Our super heroes list'
requirements:
_permission: 'access content'
```
src/Controller/HeroController.php:
```
<?php
namespace Drupal\module_hero\Controller;
use Drupal\Core\Controller\ControllerBase;
class HeroController extends ControllerBase
{
public function heroList()
{
$heroes =
[
['name' => 'Neo1'],
['name' => 'Neo2'],
['name' => 'Neo3'],
['name' => 'Neo4'],
['name' => 'Neo5'],
['name' => 'Neo6'],
['name' => 'Neo7'],
['name' => 'Neo8']
];
$ourHeroes = '';
foreach ($heroes as $hero)
{
$ourHeroes .='<li>'. $hero['name']. '</li>';
}
return
[
'#type' => 'markup',
'#markup' => '<h4>' . $this->t('These are the best voted heroes') . '</h4><ol>' . $ourHeroes . '</ol>',
];
}
}
```
.