本文整理汇总了PHP中Drupal\Core\Site\Settings::getApcuPrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getApcuPrefix方法的具体用法?PHP Settings::getApcuPrefix怎么用?PHP Settings::getApcuPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Site\Settings
的用法示例。
在下文中一共展示了Settings::getApcuPrefix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs an ApcuBackendFactory object.
*
* @param string $root
* The app root.
* @param string $site_path
* The site path.
* @param \Drupal\Core\Cache\CacheTagsChecksumInterface $checksum_provider
* The cache tags checksum provider.
*/
public function __construct($root, $site_path, CacheTagsChecksumInterface $checksum_provider)
{
$this->sitePrefix = Settings::getApcuPrefix('apcu_backend', $root, $site_path);
$this->checksumProvider = $checksum_provider;
if (version_compare(phpversion('apcu'), '5.0.0', '>=')) {
$this->backendClass = 'Drupal\\Core\\Cache\\ApcuBackend';
} else {
$this->backendClass = 'Drupal\\Core\\Cache\\Apcu4Backend';
}
}
示例2: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
// @todo Extra hack to avoid test fails, remove this once
// https://www.drupal.org/node/2553661 is fixed.
FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
parent::setUp();
$this->logger = $this->container->get('logger.channel.rules');
// Clear the log from any stale entries that are bleeding over from previous
// tests.
$this->logger->clearLogs();
$this->expressionManager = $this->container->get('plugin.manager.rules_expression');
$this->conditionManager = $this->container->get('plugin.manager.condition');
$this->typedDataManager = $this->container->get('typed_data_manager');
}
示例3: __construct
/**
* Constructs an ApcuBackendFactory object.
*
* @param string $root
* The app root.
* @param string $site_path
* The site path.
* @param \Drupal\Core\Cache\CacheTagsChecksumInterface $checksum_provider
* The cache tags checksum provider.
*/
public function __construct($root, $site_path, CacheTagsChecksumInterface $checksum_provider)
{
$this->sitePrefix = Settings::getApcuPrefix('apcu_backend', $root, $site_path);
$this->checksumProvider = $checksum_provider;
}
示例4: initializeSettings
/**
* Locate site path and initialize settings singleton.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* In case the host name in the request is not trusted.
*/
protected function initializeSettings(Request $request)
{
$site_path = static::findSitePath($request);
$this->setSitePath($site_path);
$class_loader_class = get_class($this->classLoader);
Settings::initialize($this->root, $site_path, $this->classLoader);
// Initialize our list of trusted HTTP Host headers to protect against
// header attacks.
$host_patterns = Settings::get('trusted_host_patterns', array());
if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
throw new BadRequestHttpException('The provided host name is not valid for this server.');
}
}
// If the class loader is still the same, possibly upgrade to the APC class
// loader.
if ($class_loader_class == get_class($this->classLoader) && Settings::get('class_loader_auto_detect', TRUE) && function_exists('apcu_fetch')) {
$prefix = Settings::getApcuPrefix('class_loader', $this->root);
$apc_loader = new ApcClassLoader($prefix, $this->classLoader);
$this->classLoader->unregister();
$apc_loader->register();
$this->classLoader = $apc_loader;
}
}
示例5: initFileCache
/**
* Initializes the FileCache component.
*
* We can not use the Settings object in a component, that's why we have to do
* it here instead of \Drupal\Component\FileCache\FileCacheFactory.
*/
protected function initFileCache()
{
$configuration = Settings::get('file_cache');
// Provide a default configuration, if not set.
if (!isset($configuration['default'])) {
$configuration['default'] = ['class' => FileCache::class, 'cache_backend_class' => NULL, 'cache_backend_configuration' => []];
// @todo Use extension_loaded('apcu') for non-testbot
// https://www.drupal.org/node/2447753.
if (function_exists('apcu_fetch')) {
$configuration['default']['cache_backend_class'] = ApcuFileCacheBackend::class;
}
}
FileCacheFactory::setConfiguration($configuration);
FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
}
示例6: boot
/**
* {@inheritdoc}
*/
public function boot()
{
if ($this->booted) {
return $this;
}
// Ensure that findSitePath is set.
if (!$this->sitePath) {
throw new \Exception('Kernel does not have site path set before calling boot()');
}
// Initialize the FileCacheFactory component. We have to do it here instead
// of in \Drupal\Component\FileCache\FileCacheFactory because we can not use
// the Settings object in a component.
$configuration = Settings::get('file_cache');
// Provide a default configuration, if not set.
if (!isset($configuration['default'])) {
$configuration['default'] = ['class' => '\\Drupal\\Component\\FileCache\\FileCache', 'cache_backend_class' => NULL, 'cache_backend_configuration' => []];
// @todo Use extension_loaded('apcu') for non-testbot
// https://www.drupal.org/node/2447753.
if (function_exists('apc_fetch')) {
$configuration['default']['cache_backend_class'] = '\\Drupal\\Component\\FileCache\\ApcuFileCacheBackend';
}
}
FileCacheFactory::setConfiguration($configuration);
FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
// Initialize the container.
$this->initializeContainer();
// Ensure mt_rand() is reseeded to prevent random values from one page load
// being exploited to predict random values in subsequent page loads.
$seed = unpack("L", Crypt::randomBytes(4));
mt_srand($seed[1]);
$this->booted = TRUE;
return $this;
}