Results
21.07.2021
prometheusio_exporter 8.x-1.x-dev ::
modules/prometheusio_exporter_cache/src/Cache/CacheFactoryWrapper.php
namespace Drupal\prometheusio_exporter_cache\Cache; use Drupal\Core\Cache\CacheFactoryInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Decorates cache_factory. */
* Decorates cache_factory.
*/
class CacheFactoryWrapper implements CacheFactoryInterface, ContainerAwareInterface {
use ContainerAwareTrait;
/**
* The decorated cache factory.
*
* The decorated cache factory. * * @var \Drupal\Core\Cache\CacheFactoryInterface */ protected $cacheFactory; /** * The bins to exclude from our work. * * @var array */
/**
* Creates a new CacheFactoryWrapper instance.
*
* @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
* The cache factory.
* @param string[] $binsBlacklist
* A list of cache bins to exclude.
*/
public function __construct(
CacheFactoryInterface $cache_factory,
array $binsBlacklist
) {
$this->cacheFactory = $cache_factory;
$this->binsBlacklist = $binsBlacklist;
$this->cacheBackends = [];
}
/**
* {@inheritdoc}
if (!$this->isEnabled($bin)) {
// If disabled, return an unwrapped backend.
return $this->cacheFactory->get($bin);
}
if (!isset($this->cacheBackends[$bin])) {
$cache_backend = $this->cacheFactory->get($bin);
$this->cacheBackends[$bin] = new CacheBackendWrapper($cache_backend, $bin, $this->container->get('prometheusio_exporter.prometheus_bridge'));
}
return $this->cacheBackends[$bin];
}
/** 21.07.2021
prometheusio_exporter 8.x-1.x-dev ::
modules/prometheusio_exporter_cache/prometheusio_exporter_cache.services.yml
services:
prometheusio_exporter_cache.cache_factory:
class: Drupal\prometheusio_exporter_cache\Cache\CacheFactoryWrapper
public: false
decorates: cache_factory
arguments:
- '@prometheusio_exporter_cache.cache_factory.inner'
- '%prometheusio_exporter_cache.bins.blacklist%'
properties: 16.10.2020
qtools_profiler 8.x-1.x-dev ::
modules/qtools_cache_profiler/src/PlaceholderingRenderCacheWrapper.php
use Drupal\Core\Render\PlaceholderGeneratorInterface; use Drupal\Core\Render\PlaceholderingRenderCache; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Cache\Context\CacheContextsManager; use Symfony\Component\HttpFoundation\RequestStack; /** * Class PlaceholderingRenderCacheWrapper. *
public function __construct(
RequestStack $request_stack,
CacheFactoryInterface $cache_factory,
CacheContextsManager $cache_contexts_manager,
PlaceholderGeneratorInterface $placeholder_generator,
PerformanceService $performanceService
) {
parent::__construct($request_stack, $cache_factory, $cache_contexts_manager, $placeholder_generator);
$this->performanceService = $performanceService; 28.09.2020
redis 8.x-1.x-dev ::
src/Cache/CacheBackendFactory.php
use Drupal\Component\Serialization\SerializationInterface; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Cache\CacheTagsChecksumInterface; use Drupal\redis\ClientFactory; /** * A cache backend factory responsible for the construction of redis cache bins. */
* A cache backend factory responsible for the construction of redis cache bins.
*/
class CacheBackendFactory implements CacheFactoryInterface {
/**
* List of cache bins.
*
* Renderer and possibly other places fetch backends directly from the
* factory. Avoid that the backend objects have to fetch meta information like 04.04.2020
search_api_attachments 8.x-1.0-beta16 ::
src/Form/TextExtractorFormSettings.php
* The cache factory.
*
* @var \Drupal\search_api_attachments\Cache\AttachmentsCacheFactory
*/
protected $cacheFactory;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->entityTypeManager = $container->get('entity_type.manager');
$instance->moduleExtensionList = $container->get('extension.list.module');
$instance->cacheFactory = $container->get('search_api_attachments.cache_factory');
return $instance;
}
/**
* {@inheritdoc}
*/
'#description' => $this->t('Select the caching method you want to use.'),
'#empty_value' => '',
'#options' => $this->cacheFactory->getOptions(),
'#default_value' => $config->get('cache_backend'),
'#required' => TRUE,
];
$scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE); 04.04.2020
search_api_attachments 8.x-1.0-beta16 ::
src/EventSubscriber/ConfigEventsSubscriber.php
use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; use Drupal\search_api_attachments\Cache\AttachmentsCacheFactory; use Drupal\search_api_attachments\TextExtractorPluginBase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Subscribes to config crud events. */
class ConfigEventsSubscriber implements EventSubscriberInterface {
public function __construct(protected AttachmentsCacheFactory $attachmentsCacheFactory) {}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
if (!empty($service_name)) {
try {
$this->attachmentsCacheFactory->getById($service_name)->clearAll();
}
catch (\Exception) {
// Ignore errors in case the old cache backend is not valid.
}
}
} 04.04.2020
search_api_attachments 8.x-1.0-beta16 ::
src/Cache/AttachmentsCacheFactory.php
* Defines the attachments cache factory.
*/
class AttachmentsCacheFactory {
/**
* Module config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/ 04.04.2020
search_api_attachments 8.x-1.0-beta16 ::
search_api_attachments.services.yml
Drupal\search_api_attachments\Cache\AttachmentsCacheInterface: '@search_api_attachments.cache'
search_api_attachments.cache_factory:
class: Drupal\search_api_attachments\Cache\AttachmentsCacheFactory
tags:
- { name: service_collector, tag: search_api_attachments_cache, call: addCacheBackend }
Drupal\search_api_attachments\Cache\AttachmentsCacheFactory: '@search_api_attachments.cache_factory'
search_api_attachments.cache_files:
class: Drupal\search_api_attachments\Cache\Files
tags:
- { name: search_api_attachments_cache }
search_api_attachments.cache_keyvalue:
class: Drupal\search_api_attachments\Cache\KeyValue 05.10.2020
sendgrid_integration 8.x-1.x-dev ::
modules/sendgrid_integration_reports/src/Api.php
use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Cache\CacheFactoryInterface; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Class SendGridReportsController.
* The cache factory service. * * @var \Drupal\Core\Cache\CacheFactoryInterface */ protected $cacheFactory; /** * Api constructor. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler service.
* @param \Drupal\Core\Cache\CacheFactoryInterface $cacheFactory
* The cache factory service.
*/
public function __construct(ConfigFactoryInterface $config_factory, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, ModuleHandlerInterface $moduleHandler, CacheFactoryInterface $cacheFactory) {
$this->configFactory = $config_factory;
$this->messenger = $messenger;
$this->loggerFactory = $logger_factory;
$this->moduleHandler = $moduleHandler;
$this->cacheFactory = $cacheFactory;
// Load key from variables and throw errors if not there.
$key_secret = $this->configFactory
->get('sendgrid_integration.settings')
->get('apikey');
public function getStats($cid, array $categories = [], $start_date = NULL, $end_date = NULL, $refresh = FALSE, $subuser = '') {
if (!$refresh && $cache = $this->cacheFactory->get($this->bin)->get($cid)) {
return $cache->data;
}
// Load key from variables and throw errors if not there.
if (empty($this->apiKey)) {
return [];
protected function setCache($cid, array $data) {
if (!empty($data)) {
$this->cacheFactory->get($this->bin)->set($cid, $data);
}
}
/**
* Returns browser stats.
*/
public function getStatsBrowser($subuser = '') {
$cid = 'sendgrid_reports_browsers:' . ($subuser ? $subuser : 'global');
if ($cache = $this->cacheFactory->get($this->bin)->get($cid)) {
return $cache->data;
}
// Load key from variables and throw errors if not there.
if (empty($this->apiKey)) {
return [];
public function getStatsDevices($subuser = '') {
$cid = 'sendgrid_reports_devices:' . ($subuser ? $subuser : 'global');
if ($cache = $this->cacheFactory->get($this->bin)->get($cid)) {
return $cache->data;
}
// Load key from variables and throw errors if not there.
if (empty($this->apiKey)) {
return FALSE;
public function getBouncesBySubuser($startTime = 0, $endTime = 0, $subuser = '') {
$cid = 'sendgrid_reports_bounces';
if ($cache = $this->cacheFactory->get($this->bin)->get($cid)) {
return $cache->data;
}
$path = 'suppression/bounces';
$query = [
'start_time' => $startTime ? $startTime : strtotime('-1 month'),
'end_time' => $endTime ? $endTime : time(),
public function getSubusers() {
$cid = 'sendgrid_reports_subusers';
if ($cache = $this->cacheFactory->get($this->bin)->get($cid)) {
return $cache->data;
}
$path = 'subusers';
$query = [
'limit' => 500,
'offset' => 0, 14.08.2020
service_injector 8.x-1.x-dev ::
src/Service/CacheFactoryServiceTrait.php
namespace Drupal\service_injector\Service; use Drupal\Core\Cache\CacheFactory; /** * Injection utility for the Drupal Cache Factory service. * * @see \Drupal\service_injector\Constant\CoreServices::CACHE_FACTORY */
* @see \Drupal\service_injector\Constant\CoreServices::CACHE_FACTORY
*/
trait CacheFactoryServiceTrait {
/**
* The Drupal Cache Factory service.
*
* @var \Drupal\Core\Cache\CacheFactory
*/
private CacheFactory $cacheFactoryService;
/**
* Gets the Drupal Cache Factory service.
*
* @return \Drupal\Core\Cache\CacheFactory
* The Drupal Cache Factory service.
*/
public function cacheFactoryService() : CacheFactory {
return $this->cacheFactoryService;
}
/**
* Sets the Drupal Cache Factory service.
*
* @param \Drupal\Core\Cache\CacheFactory $service
* The service to be set.
*/
public function setCacheFactoryService(CacheFactory $service) : void {
$this->cacheFactoryService = $service;
}
} 14.08.2020
service_injector 8.x-1.x-dev ::
src/Constant/CoreServices.php
* The Drupal Cache Factory service ID. * * @see \Drupal\Core\Cache\CacheFactory * @see \Drupal\service_injector\Service\CacheFactoryServiceTrait */ public const CACHE_FACTORY = 'cache_factory'; /** * The Drupal Cache Contexts Manager service ID. *
12.07.2022
sessionless 1.x-dev ::
tests/src/Unit/WebTokenServiceUnitTest.php
namespace Drupal\Tests\sessionless\Unit; use Drupal\Core\Cache\MemoryCache\MemoryCacheFactory; use Drupal\Core\Cache\NullBackend; use Drupal\Core\KeyValueStore\KeyValueMemoryFactory; use Drupal\Core\Lock\NullLockBackend; use Drupal\Core\State\State; use Drupal\sessionless\KeyStorage\KeyStorage; use Drupal\sessionless\KeyStorage\KeyStorageInterface;
$serializer = new JsonSafeCompressedPhpSerialization();
$time = new FakeTime();
$cacheFactory = new MemoryCacheFactory($time);
$cache = $cacheFactory->get('sessionless');
if ($encrypt) {
$tokenService = new SessionlessEncryptAndSign($keyStorage, $serializer, $cache);
}
else {
$tokenService = new SessionlessOnlySign($keyStorage, $serializer, $cache);
} 12.06.2023
sidekick 1.0.x-dev ::
src/SidekickService.php
/** * CacheFactory. * * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $cacheFactory; /** * The time service. * * @var \Drupal\Component\Datetime\TimeInterface */
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $factory * The LoggerChannelFactoryInterface object. * @param \Drupal\Core\Cache\CacheBackendInterface $cacheFactory * Cache backend instance to use. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. * @param \Drupal\Core\Messenger\MessengerInterface $messenger * The messenger service. */
Renderer $renderer,
LoggerChannelFactoryInterface $factory,
CacheBackendInterface $cacheFactory,
TimeInterface $time,
MessengerInterface $messenger,
) {
$this->httpClient = $httpClient;
$this->currentUser = $currentUser;
$this->configFactory = $configFactory;
$this->renderer = $renderer;
$this->loggerFactory = $factory;
$this->cacheFactory = $cacheFactory;
$this->keyStatusApi = 'https://assistant.ai-sidekick.app/api/v1/apikey-status';
$this->accountApi = 'https://assistant.ai-sidekick.app/api/v1/accounts/current';
$this->accountUsageApi = 'https://assistant.ai-sidekick.app/api/v1/accounts/usage';
$this->modulesListApi = 'https://assistant.ai-sidekick.app/api/v1/modules';
$this->languagesListApi = 'https://assistant.ai-sidekick.app/api/v1/languages';
$this->writingStyleListApi = 'https://assistant.ai-sidekick.app/api/v1/writing-styles';
$data = $this->cacheFactory->get('key_status');
if (!$reset_cache && $data) {
$keyStatus = $data->data;
}
else {
try {
$response = $this->httpClient->post(
];
$this->cacheFactory->set(
'key_status',
$keyStatus,
$this->time->getRequestTime() + 86400
// Set Cache for day.
);
}
*/
public function getModules($language_code) {
$data = $this->cacheFactory->get('module_list');
if ($data) {
$modules = $data->data;
}
else {
try {
$response = $this->httpClient->get(
];
$this->cacheFactory->set(
'module_list',
$modules,
$this->time->getRequestTime() + 86400
// Set Cache for day.
);
}
public function getLanguages($language_code) {
try {
if ($cache = $this->cacheFactory->get('language_list')) {
return $cache->data;
}
else {
$response = $this->httpClient->get(
$this->languagesListApi, [
'headers' => [
];
$this->cacheFactory->set(
'language_list',
$data,
$this->time->getRequestTime() + 86400
// Set Cache for day.
);
public function getWritingStyles($language_code) {
try {
if ($cache = $this->cacheFactory->get('writing_style')) {
return $cache->data;
}
else {
$response = $this->httpClient->get(
$this->writingStyleListApi,
[
];
$this->cacheFactory->set(
'writing_style',
$data,
$this->time->getRequestTime() + 86400
// Set Cache for day.
); 11.12.2018
sir_trevor 8.x-1.x-dev ::
tests/src/Unit/Plugin/SirTrevorPluginManagerTest.php
namespace Drupal\sir_trevor\Tests\Unit\Plugin; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\sir_trevor\Plugin\SirTrevorBlock; use Drupal\sir_trevor\Plugin\SirTrevorBlockPlugin; use Drupal\sir_trevor\Plugin\SirTrevorMixin; use Drupal\sir_trevor\Plugin\SirTrevorPlugin; use Drupal\sir_trevor\Plugin\SirTrevorPluginManager; use Drupal\Tests\sir_trevor\Unit\TestDoubles\ImmutableConfigMock;
*/
public function setUp() {
FileCacheFactory::setPrefix('prefix');
$this->moduleHandler = new ModuleHandlerMock();
$directories = [
'module_a' => __DIR__ . '/fixtures/yml/module_a',
'module_b' => __DIR__ . '/fixtures/yml/module_b',
'module_c' => __DIR__ . '/fixtures/yml/module_c',
]; 10.09.2020
sitemap_status 1.0.0-alpha4 ::
src/Cache/CacheFactory.php
namespace Drupal\sitemap_status\Cache;
use Drupal\Core\Cache\CacheFactory as CoreCacheFactory;
/**
* Defines the cache factory.
*/
class CacheFactory extends CoreCacheFactory {
/**
* {@inheritdoc}
*/
public function get($bin) {
$service_name = 'cache.backend.database.sitemap_status'; 10.09.2020
sitemap_status 1.0.0-alpha4 ::
sitemap_status.services.yml
arguments: [sitemap_status]
sitemap_status.cache_factory:
class: Drupal\sitemap_status\Cache\CacheFactory
arguments: ['@settings', '%cache_default_bin_backends%']
calls:
- [setContainer, ['@service_container']]
cache.backend.database.sitemap_status:
class: Drupal\sitemap_status\Cache\DatabaseBackendFactory
arguments: ['@database', '@cache_tags.invalidator.checksum', '@settings'] 22.04.2022
sitewide_alerts 1.0.0 ::
src/Form/SiteAlertSettingsForm.php
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityDisplayRepository; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface;
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory * The cache factory. * @param \Drupal\Core\State\StateInterface $state * The state. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
public function __construct(
ConfigFactoryInterface $config_factory,
CacheFactoryInterface $cache_factory,
StateInterface $state,
EntityTypeManagerInterface $entity_type_manager,
LanguageManagerInterface $language_manager,
EntityDisplayRepository $entity_display_repository
) {
parent::__construct($config_factory); 22.04.2022
sitewide_alerts 1.0.0 ::
src/Form/TwitterSettingsForm.php
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityDisplayRepository; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface;
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory * The cache factory. * @param \Drupal\Core\State\StateInterface $state * The state. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
public function __construct(
ConfigFactoryInterface $config_factory,
CacheFactoryInterface $cache_factory,
StateInterface $state,
EntityTypeManagerInterface $entity_type_manager,
LanguageManagerInterface $language_manager,
EntityDisplayRepository $entity_display_repository
) {
parent::__construct($config_factory); 22.04.2022
sitewide_alerts 1.0.0 ::
src/SiteAlertService.php
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ImmutableConfig; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandler;
* @param \Drupal\Core\Config\ConfigFactoryInterface $config * The config. * @param \Drupal\Core\Cache\CacheFactoryInterface $cache * The cache factory. * @param \Drupal\Component\Datetime\TimeInterface $time * The time. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. * @param \Drupal\Core\State\State $state
public function __construct(
ConfigFactoryInterface $config,
CacheFactoryInterface $cache,
TimeInterface $time,
EntityTypeManagerInterface $entity_type_manager,
State $state,
AdminContext $admin_context,
Connection $database,
ModuleHandler $module_handler 31.08.2022
symfony_translation 1.0.0-alpha1 ::
src/ProxyClass/Translator/Translator.php
* {@inheritdoc}
*/
public function setConfigCacheFactory(\Symfony\Component\Config\ConfigCacheFactoryInterface $configCacheFactory)
{
return $this->lazyLoadItself()->setConfigCacheFactory($configCacheFactory);
}
/**
* {@inheritdoc}
*/
public function addLoader(string $format, \Symfony\Component\Translation\Loader\LoaderInterface $loader)
* {@inheritdoc}
*/
public function setConfigCacheFactory(\Symfony\Component\Config\ConfigCacheFactoryInterface $configCacheFactory)
{
return $this->lazyLoadItself()->setConfigCacheFactory($configCacheFactory);
}
/**
* {@inheritdoc}
*/
public function addLoader($format, \Symfony\Component\Translation\Loader\LoaderInterface $loader) 