Initial Drupal 11 with DDEV setup

This commit is contained in:
gluebox
2025-10-08 11:39:17 -04:00
commit 89ef74b305
25344 changed files with 2599172 additions and 0 deletions

View File

@ -0,0 +1,49 @@
{% import '@lib/di.twig' as di %}
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Logger;
{% apply sort_namespaces %}
use Drupal\Core\Logger\LogMessageParserInterface;
use Drupal\Core\Logger\RfcLoggerTrait;
use Psr\Log\LoggerInterface;
{% if services %}
{{ di.use(services) }}
{% endif %}
{% endapply %}
/**
* @todo Add a description for the logger.
*/
final class {{ class }} implements LoggerInterface {
use RfcLoggerTrait;
{% if services %}
/**
* Constructs {{ class|article }} object.
*/
public function __construct(
{{ di.signature(services) }}
) {}
{% endif %}
/**
* {@inheritdoc}
*/
public function log($level, string|\Stringable $message, array $context = []): void {
$message = (string) $message;
// Convert PSR3-style messages to \Drupal\Component\Render\FormattableMarkup
// style, so they can be translated too.
$placeholders = $this->parser->parseMessagePlaceholders($message, $context);
// @see \Drupal\Core\Logger\LoggerChannel::log() for all available contexts.
$rendered_message = strtr($message, $placeholders);
// @todo Log the rendered message here.
{% if SUT_TEST %}
\file_put_contents('temporary://logger_test.log', $level . ' -> ' . $rendered_message);
{% endif %}
}
}

View File

@ -0,0 +1,9 @@
{% import '@lib/di.twig' as di %}
services:
logger.{{ service_id }}:
class: Drupal\{{ machine_name }}\Logger\{{ class }}
{% if services %}
arguments: [{{ di.arguments(services) }}]
{% endif %}
tags:
- { name: logger }