Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/PHPUnit-CodeStyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- uses: actions/checkout@v2
- name: Setup PHP
run: |
sudo update-alternatives --set php /usr/bin/php8.1
sudo update-alternatives --set php /usr/bin/php8.3
- name: "Determine composer cache directory"
id: "determine-composer-cache-directory"
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
- name: "Cache dependencies installed with composer"
uses: actions/cache@v2.1.5
uses: actions/cache@v3
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: ${{ runner.os }}-composer-v1-${{ hashFiles('./composer.json') }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Service Utils
(c) 2017-2023 drunomics GmbH
(c) 2017-2025 drunomics GmbH

[![PHPUnit and code style checks](https://github.com/drunomics/service-utils/actions/workflows/PHPUnit-CodeStyle.yml/badge.svg)](https://github.com/drunomics/service-utils/actions/workflows/PHPUnit-CodeStyle.yml)

Expand Down
25 changes: 25 additions & 0 deletions src/Core/Cache/DrupalCacheFactoryTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace drunomics\ServiceUtils\Core\Cache;

use Drupal\Core\Cache\CacheBackendInterface;

/**
* Provides convenient access to Drupal's cache backends.
*/
trait DrupalCacheFactoryTrait {

/**
* Returns a cache backend for the given bin.
*
* @param string $bin
* (optional) The cache bin name. Defaults to "default".
*
* @return \Drupal\Core\Cache\CacheBackendInterface
* The cache backend instance for the given bin.
*/
protected function getCache(string $bin = 'default'): CacheBackendInterface {
return \Drupal::cache($bin);
}

}
Loading