Add lesson 3
- Add failing blog page test. - Add custom routing, need to create Controller. - Add BlogPageController. - Test posts are visible.
This commit is contained in:
parent
e931656b68
commit
99204d78df
4 changed files with 65 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\example\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
|
||||
class BlogPageController extends ControllerBase {
|
||||
|
||||
public function __invoke(): array {
|
||||
$nodeStorage = $this->entityTypeManager()->getStorage('node');
|
||||
$nodes = $nodeStorage->loadMultiple();
|
||||
|
||||
$build = [];
|
||||
$build['content']['#theme'] = 'item_list';
|
||||
foreach ($nodes as $node) {
|
||||
$build['content']['#items'][] = $node->label();
|
||||
}
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue