Initial Drupal 11 with DDEV setup
This commit is contained in:
47
vendor/chi-teck/drupal-code-generator/templates/Service/_cache-context/cache-context.twig
vendored
Normal file
47
vendor/chi-teck/drupal-code-generator/templates/Service/_cache-context/cache-context.twig
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\{{ machine_name }}\Cache\Context;
|
||||
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Cache\Context\{{ interface }};
|
||||
{% if base_class %}
|
||||
use Drupal\Core\Cache\Context\{{ base_class }};
|
||||
{% endif %}
|
||||
|
||||
/**
|
||||
* @todo Add a description for the cache context.
|
||||
*
|
||||
* Cache context ID: '{{ context_id }}'.
|
||||
*
|
||||
* @DCG
|
||||
* Check out the core/lib/Drupal/Core/Cache/Context directory for examples of
|
||||
* cache contexts provided by Drupal core.
|
||||
*/
|
||||
final class {{ class }} {% if base_class %}extends {{ base_class }} {% endif %}implements {{ interface }} {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getLabel(): string {
|
||||
return (string) t('{{ context_label }}');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContext({% if calculated %}$parameter = NULL{% endif %}): string {
|
||||
// @todo Calculate the cache context here.
|
||||
$context = 'some_string_value';
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheableMetadata({% if calculated %}$parameter = NULL{% endif %}): CacheableMetadata {
|
||||
return new CacheableMetadata();
|
||||
}
|
||||
|
||||
}
|
||||
10
vendor/chi-teck/drupal-code-generator/templates/Service/_cache-context/services.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/Service/_cache-context/services.twig
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
services:
|
||||
cache_context.{{ context_id }}:
|
||||
class: Drupal\{{ machine_name }}\Cache\Context\{{ class }}
|
||||
{% if base_class == 'RequestStackCacheContextBase' %}
|
||||
arguments: ['@request_stack']
|
||||
{% elseif base_class == 'UserCacheContextBase' %}
|
||||
arguments: ['@current_user']
|
||||
{% endif %}
|
||||
tags:
|
||||
- { name: cache.context}
|
||||
Reference in New Issue
Block a user