composer require itk-dev/drupal_psr6_cache
vendor/bin/drush pm:enable drupal_psr6_cacheor add a composer dependency on itk-dev/drupal_psr6_cache (see below for
details).
Add a dependency on the drupal_psr6_cache module to a module:
# composer.json
{
"name": "drupal/my_module",
…
"require": {
"itk-dev/drupal_psr6_cache": "^1.0"
}
}# my_module.info.yml
…
dependencies:
- drupal:drupal_psr6_cacheInject the cache pool into a service:
# my_module.services.yml
my_module.some_service:
class: Drupal/my_module/SomeService.php
arguments:
- '@drupal_psr6_cache.cache_item_pool'Use the cache pool:
// src/SomeService.php
namespace Drupal/my_module;
use Psr\Cache\CacheItemPoolInterface;
class SomeService {
__construct(CacheItemPoolInterface $cacheItemPool) {
…
}
}@todo
The code must follow the Drupal coding standards.
Check coding standards (run composer install to install the required tools):
composer coding-standards-checkApply coding standards:
composer coding-standards-apply