本文整理汇总了PHP中Drupal\Core\Site\Settings::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getInstance方法的具体用法?PHP Settings::getInstance怎么用?PHP Settings::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Site\Settings
的用法示例。
在下文中一共展示了Settings::getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setMinimalContainerPreKernel
public function setMinimalContainerPreKernel()
{
// Create a minimal mocked container to support calls to t() in the pre-kernel
// base system verification code paths below. The strings are not actually
// used or output for these calls.
$container = new ContainerBuilder();
$container->setParameter('language.default_values', Language::$defaultValues);
$container->register('language.default', 'Drupal\\Core\\Language\\LanguageDefault')->addArgument('%language.default_values%');
$container->register('string_translation', 'Drupal\\Core\\StringTranslation\\TranslationManager')->addArgument(new Reference('language.default'));
// Register the stream wrapper manager.
$container->register('stream_wrapper_manager', 'Drupal\\Core\\StreamWrapper\\StreamWrapperManager')->addMethodCall('setContainer', array(new Reference('service_container')));
$container->register('file_system', 'Drupal\\Core\\File\\FileSystem')->addArgument(new Reference('stream_wrapper_manager'))->addArgument(Settings::getInstance())->addArgument((new LoggerChannelFactory())->get('file'));
\Drupal::setContainer($container);
}
示例2: testGetInstance
/**
* @covers ::getInstance
*/
public function testGetInstance()
{
$singleton = $this->settings->getInstance();
$this->assertEquals($singleton, $this->settings);
}
示例3: getSettingsService
/**
* Gets the 'settings' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return \Drupal\Core\Site\Settings A Drupal\Core\Site\Settings instance.
*/
protected function getSettingsService()
{
$this->services['settings'] = $instance = \Drupal\Core\Site\Settings::getInstance();
$instance->_serviceId = 'settings';
return $instance;
}
开发者ID:Nouveau,项目名称:gishtips,代码行数:14,代码来源:742b68919a9d7ff14289a2d915b41c1157fde904dd832ad5776c8ad66b5975e8.php
示例4: getSettings
/**
* @return \Drupal\Core\Site\Settings
*/
public function getSettings()
{
if ($settings = $this->getService('settings')) {
return $settings;
}
$kernelHelper = $this->getKernelHelper();
$drupal = $this->getDrupalHelper();
if ($kernelHelper && $drupal) {
Settings::initialize($drupal->getRoot(), $kernelHelper->getSitePath(), $kernelHelper->getClassLoader());
return Settings::getInstance();
}
return null;
}
示例5: setSetting
/**
* Sets an in-memory Settings variable.
*
* @param string $name
* The name of the setting to set.
* @param bool|string|int|array|null $value
* The value to set. Note that array values are replaced entirely; use
* \Drupal\Core\Site\Settings::get() to perform custom merges.
*/
protected function setSetting($name, $value)
{
$settings = Settings::getInstance() ? Settings::getAll() : [];
$settings[$name] = $value;
new Settings($settings);
}