Results
12.10.2022
test_helpers 1.0.0-alpha6 ::
src/Stub/CacheFactoryStub.php
namespace Drupal\test_helpers\Stub;
use Drupal\Core\Cache\CacheFactory;
use Drupal\Core\Site\Settings;
use Drupal\test_helpers\TestHelpers;
/**
* A stub of the Drupal's core CacheFactory class.
*
* @package TestHelpers\DrupalServiceStubs
*/
class CacheFactoryStub extends CacheFactory {
/**
* {@inheritdoc}
*/
public function __construct(Settings $settings, array $default_bin_backends = []) {
$cacheSettings = $settings->get('cache'); 12.10.2022
test_helpers 1.0.0-alpha6 ::
src/TestHelpers.php
use Drupal\Core\TypedData\TypedDataInterface; use Drupal\test_helpers\Stub\CacheContextsManagerStub; use Drupal\test_helpers\Stub\CacheFactoryStub; use Drupal\test_helpers\Stub\ConfigFactoryStub; use Drupal\test_helpers\Stub\ConfigurableLanguageManagerStub; use Drupal\test_helpers\Stub\ContainerAwareEventDispatcherStub; use Drupal\test_helpers\Stub\DatabaseConnectionStub\Connection; use Drupal\test_helpers\Stub\DatabaseStorageStub; use Drupal\test_helpers\Stub\DateFormatterStub;
'cache.bootstrap' => MemoryBackendStub::class,
'cache.config' => MemoryBackendStub::class,
'cache_factory' => CacheFactoryStub::class,
'class_resolver' => [self::class, 'getClassResolverStub'],
'config.factory' => ConfigFactoryStub::class,
'config.storage.active' => DatabaseStorageStub::class,
'config.storage.snapshot' => DatabaseStorageStub::class,
'database' => [Connection::class, 'stubGetConnection'],
'date.formatter' => DateFormatterStub::class, 12.10.2022
test_helpers 1.0.0-alpha6 ::
tests/src/Unit/Stub/CacheFactoryStubTest.php
namespace Drupal\Tests\test_helpers\Unit\Stub; use Drupal\test_helpers\Stub\CacheFactoryStub; use Drupal\Tests\UnitTestCase; use Drupal\test_helpers\TestHelpers; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group;
/**
* Tests CacheFactoryStub class.
*/
#[CoversClass(CacheFactoryStub::class)]
#[Group('test_helpers')]
#[CoversMethod(CacheFactoryStub::class, '__construct')]
class CacheFactoryStubTest extends UnitTestCase {
/**
* Tests the CacheFactoryStub service.
*/
public function testService() {
$cacheStatic = TestHelpers::service('cache.static', NULL, NULL, NULL, NULL, TRUE);
$cacheConfig = TestHelpers::service('cache.config');
$cacheDefault = TestHelpers::service('cache.default'); 25.10.2018
toolshed 8.x-1.x-dev ::
src/Discovery/AttributeDiscovery.php
use Drupal\Component\Discovery\DiscoverableInterface; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\FileCache\FileCacheInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\toolshed\Strategy\Attribute\StrategyInterface; /**
public function __construct(protected ModuleHandlerInterface $moduleHandler, string $subdir, protected string $attribute) {
$this->subdir = trim($subdir, DIRECTORY_SEPARATOR);
$this->fileCache = FileCacheFactory::get('attribute_discovery:' . str_replace('/', '_', $attribute));
}
/**
* {@inheritdoc}
*/
public function findAll(): array { 28.11.2020
twilio 8.x-1.x-dev ::
src/Services/TwilioBase.php
namespace Drupal\twilio\Services; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Twilio\Rest\Client; /** * Service class for Twilio API commands. */
* The cache factory service. * * @var \Drupal\Core\Cache\CacheFactoryInterface */ protected $cacheFactory; /** * Twilio client. * * @var \Twilio\Rest\Client */
* Initialize properties.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler, CacheFactoryInterface $cacheFactory) {
$this->configFactory = $config_factory;
$this->moduleHandler = $moduleHandler;
$this->cacheFactory = $cacheFactory;
$this->sid = $this->getSid();
$this->token = $this->getToken();
$this->number = $this->getNumber();
}
/** 28.11.2020
twilio 8.x-1.x-dev ::
src/Services/Numbers.php
namespace Drupal\twilio\Services; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; /** * Service class for Twilio phone number handling. */
* Initialize properties.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler, CacheFactoryInterface $cacheFactory) {
parent::__construct($config_factory, $moduleHandler, $cacheFactory);
$this->bin = $this->cacheFactory->get('twilio');
}
/**
* Get all purchased numbers.
*/
public function getAllNumbers(): Numbers { 19.01.2023
user_dashboard_bootstrap 1.0.2 ::
src/Hook/UserDashboardHooks.php
/** @var \Drupal\Core\Queue\QueueFactory $queue_factory */
$queue_factory = \Drupal::service('queue');
$cacheFactory = \Drupal::cache();
if ($cache = $cacheFactory->get($cid)) {
$lastRunTime = $cache->data;
}
else {
$lastRunTime = strtotime('today midnight');
$cacheFactory->set($cid, $lastRunTime);
}
$cronHour = $config->get('cron_hour') ?: '00:00';
$scheduledRunTime = strtotime(date('Y-m-d') . ' ' . $cronHour);
$now = strtotime('now');
// @todo check time with cron_hour.
if ($now >= $scheduledRunTime && $lastRunTime < $scheduledRunTime) {
// @todo check time with cron_hour.
if ($now >= $scheduledRunTime && $lastRunTime < $scheduledRunTime) {
$cacheFactory->set($cid, $now);
}
else {
// Do nothing if e-mail sent during the day.
$queue = $queue_factory->get($queueName);
if ($queue) {
while ($item = $queue->claimItem()) { 08.05.2020
variationcache 8.x-1.0 ::
src/Old/Cache/VariationCacheFactory.php
namespace Drupal\variationcache\Old\Cache; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Cache\Context\CacheContextsManager; use Symfony\Component\HttpFoundation\RequestStack; /** * Defines the variation cache factory. *
* @ingroup cache
*/
class VariationCacheFactory implements VariationCacheFactoryInterface {
/**
* Instantiated variation cache bins.
*
* @var \Drupal\variationcache\Cache\VariationCacheInterface[]
*/
* The cache factory. * * @var \Drupal\Core\Cache\CacheFactoryInterface */ protected $cacheFactory; /** * The cache contexts manager. * * @var \Drupal\Core\Cache\Context\CacheContextsManager */
/**
* Constructs a new VariationCacheFactory object.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
* @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
* The cache factory.
* @param \Drupal\Core\Cache\Context\CacheContextsManager $cache_contexts_manager
* The cache contexts manager.
*/
public function __construct(RequestStack $request_stack, CacheFactoryInterface $cache_factory, CacheContextsManager $cache_contexts_manager) {
$this->requestStack = $request_stack;
$this->cacheFactory = $cache_factory;
$this->cacheContextsManager = $cache_contexts_manager;
}
/**
* {@inheritdoc}
*/
public function get($bin) {
if (!isset($this->bins[$bin])) {
$this->bins[$bin] = new VariationCache($this->requestStack, $this->cacheFactory->get($bin), $this->cacheContextsManager);
}
return $this->bins[$bin];
}
} 08.05.2020
variationcache 8.x-1.0 ::
src/Old/Cache/VariationCacheFactoryInterface.php
* @ingroup cache
*/
interface VariationCacheFactoryInterface {
/**
* Gets a variation cache backend for a given cache bin.
*
* @param string $bin
* The cache bin for which a variation cache backend should be returned. 08.05.2020
variationcache 8.x-1.0 ::
src/Cache/VariationCacheFactory.php
* and the module file hasn't been loaded yet at that point.
*/
if (!class_exists('\Drupal\Core\Cache\VariationCacheFactory')) {
@class_alias('\Drupal\variationcache\Old\Cache\VariationCacheFactory', '\Drupal\variationcache\Cache\VariationCacheFactory');
}
else {
@class_alias('\Drupal\Core\Cache\VariationCacheFactory', '\Drupal\variationcache\Cache\VariationCacheFactory');
} 08.05.2020
variationcache 8.x-1.0 ::
src/Cache/VariationCacheFactoryInterface.php
* and the module file hasn't been loaded yet at that point.
*/
if (!class_exists('\Drupal\Core\Cache\VariationCacheFactoryInterface')) {
@class_alias('\Drupal\variationcache\Old\Cache\VariationCacheFactoryInterface', '\Drupal\variationcache\Cache\VariationCacheFactoryInterface');
}
else {
@class_alias('\Drupal\Core\Cache\VariationCacheFactoryInterface', '\Drupal\variationcache\Cache\VariationCacheFactoryInterface');
} 08.05.2020
variationcache 8.x-1.0 ::
variationcache.module
use Drupal\variationcache\Old\Cache\CacheRedirect; use Drupal\variationcache\Old\Cache\VariationCache; use Drupal\variationcache\Old\Cache\VariationCacheFactory; use Drupal\variationcache\Old\Cache\VariationCacheFactoryInterface; use Drupal\variationcache\Old\Cache\VariationCacheInterface; /** * @file * Contains class aliases to keep old code functioning now that this module has * been integrated into Drupal 10.2 and higher. If you are running on this core
@class_alias(CacheRedirect::class, '\Drupal\variationcache\Cache\CacheRedirect');
@class_alias(VariationCache::class, '\Drupal\variationcache\Cache\VariationCache');
@class_alias(VariationCacheFactory::class, '\Drupal\variationcache\Cache\VariationCacheFactory');
@class_alias(VariationCacheFactoryInterface::class, '\Drupal\variationcache\Cache\VariationCacheFactoryInterface');
@class_alias(VariationCacheInterface::class, '\Drupal\variationcache\Cache\VariationCacheInterface');
}
else {
@class_alias('\Drupal\Core\Cache\CacheRedirect', '\Drupal\variationcache\Cache\CacheRedirect');
@class_alias('\Drupal\Core\Cache\VariationCache', '\Drupal\variationcache\Cache\VariationCache');
@class_alias('\Drupal\Core\Cache\VariationCacheFactory', '\Drupal\variationcache\Cache\VariationCacheFactory');
@class_alias('\Drupal\Core\Cache\VariationCacheFactoryInterface', '\Drupal\variationcache\Cache\VariationCacheFactoryInterface');
@class_alias('\Drupal\Core\Cache\VariationCacheInterface', '\Drupal\variationcache\Cache\VariationCacheInterface');
} 08.05.2020
variationcache 8.x-1.0 ::
variationcache.services.yml
services:
variation_cache_factory:
class: Drupal\variationcache\Cache\VariationCacheFactory
arguments: ['@request_stack', '@cache_factory', '@cache_contexts_manager'] 20.07.2018
varnish 8.x-1.x-dev ::
src/Cache/VarnishBackendFactory.php
namespace Drupal\varnish\Cache;
use Drupal\Core\Cache\CacheFactoryInterface;
class VarnishBackendFactory implements CacheFactoryInterface{
/**
* Instantiated varnish cache bins.
*
* @var \Drupal\varnish\Cache\VarnishBackend[]
*/ 03.06.2022
webprofiler 10.0.x-dev ::
src/Cache/CacheFactoryWrapper.php
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\webprofiler\DataCollector\CacheDataCollector;
/**
* Wraps a cache factory to register all calls to the cache system.
*/
class CacheFactoryWrapper implements CacheFactoryInterface {
/**
* All wrapped cache backends.
*
* @var \Drupal\webprofiler\Cache\CacheBackendWrapper[]
*/
/**
* Creates a new CacheFactoryWrapper instance.
*
* @param \Drupal\Core\Cache\CacheFactoryInterface $cacheFactory
* The cache factory.
* @param \Drupal\webprofiler\DataCollector\CacheDataCollector $cacheDataCollector
* The cache data collector.
*/
public function __construct(
protected readonly CacheFactoryInterface $cacheFactory,
protected readonly CacheDataCollector $cacheDataCollector,
) {
}
/**
* {@inheritdoc}
public function get($bin): CacheBackendInterface {
if (!isset($this->cacheBackends[$bin])) {
$cache_backend = $this->cacheFactory->get($bin);
$this->cacheBackends[$bin] = new CacheBackendWrapper($this->cacheDataCollector, $cache_backend, $bin);
}
return $this->cacheBackends[$bin];
} 03.06.2022
webprofiler 10.0.x-dev ::
webprofiler.services.yml
webprofiler.debug.cache_factory:
class: Drupal\webprofiler\Cache\CacheFactoryWrapper
public: false
decorates: cache_factory
arguments: ['@webprofiler.debug.cache_factory.inner', '@webprofiler.cache']
webprofiler.debug.state:
class: Drupal\webprofiler\State\StateWrapper 30.04.2021
wse 1.0.x-dev ::
modules/wse_config/src/Cache/WseChainedFastBackendFactory.php
namespace Drupal\wse_config\Cache; use Drupal\Core\Cache\CacheFactoryInterface; use Drupal\Core\Installer\InstallerKernel; use Drupal\Core\Site\Settings; use Drupal\wse_config\WorkspaceIdDetector; use Symfony\Component\DependencyInjection\ContainerInterface; /**
* Implements the factory for the workspace aware fast chained cache backends.
*/
class WseChainedFastBackendFactory implements CacheFactoryInterface {
/**
* The decorated cache backend factory.
*
* @var \Drupal\Core\Cache\CacheFactoryInterface
*/
protected $innerFactory;
/**
* The workspace ID detector.
*
* Constructs the DatabaseBackendFactory object. * * @param \Drupal\Core\Cache\CacheFactoryInterface $inner_factory * The inner cache backend factory. * @param \Drupal\wse_config\WorkspaceIdDetector $workspace_id_detector * The workspace ID detector. * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The decorated cache backend factory. * @param \Drupal\Core\Site\Settings $settings
* @throws \BadMethodCallException
*/
public function __construct(CacheFactoryInterface $inner_factory, WorkspaceIdDetector $workspace_id_detector, ContainerInterface $container, Settings $settings, $consistent_service_name = NULL, $fast_service_name = NULL) {
$this->innerFactory = $inner_factory;
$this->workspaceIdDetector = $workspace_id_detector;
$this->setContainer($container);
// Default the consistent backend to the site's default backend.
if (!isset($consistent_service_name)) { 30.04.2021
wse 1.0.x-dev ::
modules/wse_config/src/Cache/WseCacheBackendFactory.php
namespace Drupal\wse_config\Cache;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\wse_config\WorkspaceIdDetector;
/**
* Implements the factory for workspace specific cache backends.
*/
class WseCacheBackendFactory implements CacheFactoryInterface {
/**
* The decorated cache backend factory.
*
* @var \Drupal\Core\Cache\CacheFactoryInterface
*/
protected $innerFactory;
/**
* The workspace ID detector.
*
* Constructs the DatabaseBackendFactory object. * * @param \Drupal\Core\Cache\CacheFactoryInterface $inner_factory * The decorated cache backend factory. * @param \Drupal\wse_config\WorkspaceIdDetector $workspace_id_detector * The workspace id detector. * * @throws \BadMethodCallException */
* @throws \BadMethodCallException
*/
public function __construct(CacheFactoryInterface $inner_factory, WorkspaceIdDetector $workspace_id_detector) {
$this->innerFactory = $inner_factory;
$this->workspaceIdDetector = $workspace_id_detector;
}
/**
* {@inheritdoc} 30.04.2021
wse 1.0.x-dev ::
modules/wse_config/src/DecorateCacheFactoriesPass.php
$interfaces = class_implements($service_class);
if (in_array('Drupal\Core\Cache\CacheFactoryInterface', $interfaces) && $service_class != 'Drupal\Core\Cache\CacheFactory') {
$decorated_service_id = $service_id . '.wse';
if (!in_array($decorated_service_id, $services)) {
if ($service_id == 'cache.backend.chainedfast') {
$container->register($decorated_service_id, WseChainedFastBackendFactory::class)
->setDecoratedService($service_id)
->setArguments([ 17.10.2020
xero 8.x-2.x-dev ::
tests/src/Unit/XeroDataTestTrait.php
namespace Drupal\Tests\xero\Unit; use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\Plugin\Discovery\AttributeClassDiscovery; use Drupal\Core\TypedData\Attribute\DataType; use Drupal\Core\TypedData\ComplexDataDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\ListDataDefinition;
$this->typedDataManagerProphet = $this->prophesize('\Drupal\Core\TypedData\TypedDataManagerInterface');
FileCacheFactory::setPrefix(FileCacheFactory::DISABLE_CACHE);
// There is no good method to figure out the app root so make two educated
// guesses: directly under modules or under modules/contrib (qa.drupal.org).
$root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)));
if (!realpath($root . '/core')) {
$root = dirname($root); 