feat: add an example module with custom tests
Add a custom module based on my Drupal module template: https://github.com/opdavies/drupal-module-template
This commit is contained in:
parent
ea60b27438
commit
67a9f556c4
10 changed files with 117 additions and 0 deletions
web/modules/custom/example/src/Controller
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\example\Controller;
|
||||
|
||||
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
|
||||
final class ExamplePageController {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
public function __construct(
|
||||
private LoggerChannelFactoryInterface $logger
|
||||
) {}
|
||||
|
||||
public function __invoke(): array {
|
||||
$this->logger->get('example')->info('Example page viewed.');
|
||||
|
||||
return [
|
||||
'#markup' => $this->t(
|
||||
'This is an example page from the <a href="@url">Drupal Module Template</a>.',
|
||||
['@url' => 'https://github.com/opdavies/drupal-module-template']
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue