示例#1
0
 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
0
 /**
  * @covers ::getInstance
  */
 public function testGetInstance()
 {
     $singleton = $this->settings->getInstance();
     $this->assertEquals($singleton, $this->settings);
 }
 /**
  * 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;
 }
 /**
  * @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
0
 /**
  * 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);
 }