本文整理汇总了PHP中Drupal\Component\FileCache\FileCacheFactory::setConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP FileCacheFactory::setConfiguration方法的具体用法?PHP FileCacheFactory::setConfiguration怎么用?PHP FileCacheFactory::setConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Component\FileCache\FileCacheFactory
的用法示例。
在下文中一共展示了FileCacheFactory::setConfiguration方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetSetConfiguration
/**
* @covers ::getConfiguration
* @covers ::setConfiguration
*/
public function testGetSetConfiguration()
{
$configuration = FileCacheFactory::getConfiguration();
$configuration['test_foo_bar'] = ['bar' => 'llama'];
FileCacheFactory::setConfiguration($configuration);
$configuration = FileCacheFactory::getConfiguration();
$this->assertEquals(['bar' => 'llama'], $configuration['test_foo_bar']);
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Ensure that an instantiated container in the global state of \Drupal from
// a previous test does not leak into this test.
\Drupal::unsetContainer();
// Ensure that the NullFileCache implementation is used for the FileCache as
// unit tests should not be relying on caches implicitly.
FileCacheFactory::setConfiguration(['default' => ['class' => '\\Drupal\\Component\\FileCache\\NullFileCache']]);
$this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
}
示例3: getPackageManager
/**
* Returns a \Drupal\composer_manager\PackageManager instance.
*/
public static function getPackageManager() {
$root = getcwd();
require $root . '/autoload.php';
// The module classes aren't in the autoloader at this point.
require __DIR__ . '/../ExtensionDiscovery.php';
require __DIR__ . '/../JsonFile.php';
require __DIR__ . '/../PackageManagerInterface.php';
require __DIR__ . '/../PackageManager.php';
// YAML discovery in core uses FileCache which is not available.
FileCacheFactory::setConfiguration(['default' => ['class' => '\Drupal\Component\FileCache\NullFileCache']]);
return new PackageManager($root);
}
示例4: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Ensure that an instantiated container in the global state of \Drupal from
// a previous test does not leak into this test.
\Drupal::unsetContainer();
// Ensure that the NullFileCache implementation is used for the FileCache as
// unit tests should not be relying on caches implicitly.
FileCacheFactory::setConfiguration([FileCacheFactory::DISABLE_CACHE => TRUE]);
// Ensure that FileCacheFactory has a prefix.
FileCacheFactory::setPrefix('prefix');
$this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
}
示例5: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Ensure that an instantiated container in the global state of \Drupal from
// a previous test does not leak into this test.
\Drupal::unsetContainer();
// Ensure that the NullFileCache implementation is used for the FileCache as
// unit tests should not be relying on caches implicitly.
FileCacheFactory::setConfiguration(['default' => ['class' => '\\Drupal\\Component\\FileCache\\NullFileCache']]);
$this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
// Reset the static list of SafeStrings to prevent bleeding between tests.
$reflected_class = new \ReflectionClass('\\Drupal\\Component\\Utility\\SafeMarkup');
$reflected_property = $reflected_class->getProperty('safeStrings');
$reflected_property->setAccessible(true);
$reflected_property->setValue([]);
}
示例6: getContainerDefinition
/**
* {@inheritdoc}
*/
public function getContainerDefinition()
{
FileCacheFactory::setConfiguration(array('default' => array('class' => '\\Drupal\\Component\\FileCache\\NullFileCache')));
$container_builder = new ContainerBuilder();
$yaml_loader = new YamlFileLoader($container_builder);
foreach (module_list() as $module) {
$filename = drupal_get_filename('module', $module);
$services = dirname($filename) . "/{$module}.services.yml";
if (file_exists($services)) {
$yaml_loader->load($services);
}
}
// Disabled for now.
// $container_builder->compile();
$dumper = new PhpArrayDumper($container_builder);
return $dumper->getArray();
}
示例7: getPackageManager
/**
* Returns a \Drupal\composer_manager\PackageManager instance.
*/
public static function getPackageManager()
{
// The command is running inside Composer, which gives the autoloader
// access to Drupal's classes but not the module classes.
require __DIR__ . '/../ExtensionDiscovery.php';
require __DIR__ . '/../JsonFile.php';
require __DIR__ . '/../PackageManagerInterface.php';
require __DIR__ . '/../PackageManager.php';
require __DIR__ . '/../RootPackageBuilderInterface.php';
require __DIR__ . '/../RootPackageBuilder.php';
// YAML discovery in core uses FileCache which is not available.
FileCacheFactory::setConfiguration(['default' => ['class' => '\\Drupal\\Component\\FileCache\\NullFileCache']]);
// Composer runs in core/, so the root is one directory above.
$root = realpath(getcwd() . '/../');
$root_package_builder = new \Drupal\composer_manager\RootPackageBuilder($root);
$package_manager = new \Drupal\composer_manager\PackageManager($root, $root_package_builder);
return $package_manager;
}
示例8: 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('apcu_fetch')) {
$configuration['default']['cache_backend_class'] = '\\Drupal\\Component\\FileCache\\ApcuFileCacheBackend';
}
}
FileCacheFactory::setConfiguration($configuration);
FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
$this->bootstrapContainer = new $this->bootstrapContainerClass(Settings::get('bootstrap_container_definition', $this->defaultBootstrapContainerDefinition));
// Initialize the container.
$this->initializeContainer();
$this->booted = TRUE;
return $this;
}
示例9: 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));
}
示例10: __construct
/**
* Creates the discovery object.
*
* @param string|bool $subdir
* The plugin's subdirectory, for example Plugin/views/filter.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param string|null $plugin_interface
* (optional) The interface each plugin should implement.
* @param string $plugin_definition_annotation_name
* (optional) The name of the annotation that contains the plugin definition.
* Defaults to 'Drupal\Component\Annotation\Plugin'.
*/
public function __construct($subdir, \Traversable $namespaces, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin')
{
$this->subdir = $subdir;
$this->namespaces = $namespaces;
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
$this->pluginInterface = $plugin_interface;
// Add the file cache prefix.
$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);
$identifier = 'file_cache';
FileCacheFactory::setPrefix('drupal.' . $identifier . '.' . hash_hmac('sha256', $identifier, drupal_get_hash_salt()));
}
示例11: 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;
}