clean install

This commit is contained in:
2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 changed files with 3555714 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
{% import '@lib/di.twig' as di %}
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }};
{% apply sort_namespaces %}
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Symfony\Component\Routing\Route;
{% if services %}
{{ di.use(services) }}
{% endif %}
{% endapply %}
/**
* @todo Add description for the converter.
*
* @DCG
* To use this converter specify parameter type in a relevant route as follows:
* @code
* {{ machine_name }}.{{ parameter_type }}_parameter_converter:
* path: example/{record}
* defaults:
* _controller: '\Drupal\{{ machine_name }}\Controller\{{ controller_class }}::build'
* requirements:
* _access: 'TRUE'
* options:
* parameters:
* record:
* type: {{ parameter_type }}
* @endcode
*
* Note that parameter converter for entities already exists in Drupal core.
* @see \Drupal\Core\ParamConverter\EntityConverter
*/
final class {{ class }} implements ParamConverterInterface {
{% if services %}
/**
* Constructs {{ class|article }} object.
*/
public function __construct(
{{ di.signature(services) }}
) {}
{% endif %}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults): ?string {
// @DCG
// If the converter returns something different rather than strings make
// sure to define an appropriate return type for this method.
return match ($value) {
'1' => 'alpha',
'2' => 'beta',
'3' => 'gamma',
// NULL will trigger 404 HTTP error.
default => NULL,
};
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route): bool {
return isset($definition['type']) && $definition['type'] === 'example';
}
}

View File

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