Drupal 8  8.0.2
Settings Class Reference

Public Member Functions

 __construct (array $settings)
 
 __sleep ()
 

Static Public Member Functions

static getInstance ()
 
static get ($name, $default=NULL)
 
static getAll ()
 
static initialize ($app_root, $site_path, &$class_loader)
 
static getHashSalt ()
 
static getApcuPrefix ($identifier, $root, $site_path= '')
 

Detailed Description

Read only settings that are initialized with the class.

Constructor & Destructor Documentation

__construct ( array  $settings)

Constructor.

Parameters
array$settingsArray with the settings.

Member Function Documentation

__sleep ( )

Prevents settings from being serialized.

static get (   $name,
  $default = NULL 
)
static

Returns a setting.

Settings can be set in settings.php in the $settings array and requested by this function. Settings should be used over configuration for read-only, possibly low bootstrap configuration that is environment specific.

Parameters
string$nameThe name of the setting to return.
mixed$default(optional) The default value to use if this setting is not set.
Returns
mixed The value of the setting, the provided default if not set.

Referenced by MetadataBag\__construct(), TwigSandboxPolicy\__construct(), DbUpdateAccessCheck\access(), ServiceProviderTestServiceProvider\alter(), PrivateStream\basePath(), PublicStream\basePath(), PublicStream\baseUrl(), DrupalKernel\boot(), DbUpdateNegotiator\determineActiveTheme(), DrupalKernel\discoverServiceProviders(), ConfigInstaller\drupalGetProfile(), ClientFactory\fromOptions(), BootstrapConfigStorageFactory\get(), PhpStorageFactory\get(), ExtensionInstallStorage\getAllFolders(), DrupalKernel\getContainerCacheKey(), MailFormatHelper\htmlToText(), DrupalKernel\initializeContainer(), DrupalKernel\initializeSettings(), PhpMail\mail(), CoreServiceProvider\register(), DbUpdateController\results(), FinishResponseSubscriber\setResponseCacheable(), ReverseProxyMiddleware\setSettingsOnRequest(), SettingsRewriteTest\testDrupalRewriteSettings(), SettingsTest\testGet(), EntityFileTest\testGetDirectory(), InstallerExistingSettingsNoProfileTest\testInstaller(), EntityFileTest\testIsLocationUnchanged(), UnmanagedMoveTest\testNormal(), UnmanagedCopyTest\testNormal(), UnmanagedCopyTest\testOverwriteSelf(), DrupalKernelSiteTest\testServicesYml(), StreamWrapperTest\testUriFunctions(), HtmlToTextTest\testVeryLongLineWrap(), ReverseProxyMiddlewareTest\trustedHeadersAreSet(), and ConfigImportSubscriber\validateModules().

Here is the caller graph for this function:

static getAll ( )
static

Returns all the settings. This is only used for testing purposes.

Returns
array All the settings.

Referenced by TestRunnerKernel\boot(), TranslationStringTest\rebootAndPrepareSettings(), TestBase\settingsSet(), PhpStorageFactoryTest\setUp(), TwigMarkupInterfaceTest\testEmptyTranslation(), and SettingsTest\testGetAll().

Here is the caller graph for this function:

static getApcuPrefix (   $identifier,
  $root,
  $site_path = '' 
)
static

Generates a prefix for APCu user cache keys.

A standardized prefix is useful to allow visual inspection of an APCu user cache. By default, this method will produce a unique prefix per site using the hash salt. If the setting 'apcu_ensure_unique_prefix' is set to FALSE then if the caller does not provide a $site_path only the Drupal root will be used. This allows WebTestBase to use the same prefix ensuring that the number of APCu items created during a full test run is kept to a minimum. Additionally, if a multi site implementation does not use site specific module directories setting apcu_ensure_unique_prefix would allow the sites to share APCu cache items.

Parameters
$identifierAn identifier for the prefix. For example, 'class_loader' or 'cache_backend'.
Returns
string The prefix for APCu user cache keys.

References Crypt\hashBase64(), and Drupal\VERSION.

Referenced by ApcuBackendFactory\__construct(), DrupalKernel\boot(), and DrupalKernel\initializeSettings().

Here is the call graph for this function:

Here is the caller graph for this function:

static getHashSalt ( )
static

Gets a salt useful for hardening against SQL injection.

Returns
string A salt based on information in settings.php, not in the database.
Exceptions
\RuntimeException

Referenced by CsrfTokenGenerator\computeToken(), PhpStorageFactory\get(), EntityAutocompleteTest\getAutocompleteResult(), ImageStyle\getHashSalt(), EntityAutocompleteController\handleAutocomplete(), PermissionsHashGenerator\hash(), EntityAutocomplete\processEntityAutocomplete(), and EntityAutocompleteTest\testSelectionSettingsHandling().

Here is the caller graph for this function:

static getInstance ( )
static

Returns the settings instance.

A singleton is used because this class is used before the container is available.

Returns
static initialize (   $app_root,
  $site_path,
$class_loader 
)
static

Bootstraps settings.php and the Settings singleton.

Parameters
string$app_rootThe app root.
string$site_pathThe current site path.
\Composer\Autoload\ClassLoader$class_loaderThe class loader that is used for this request. Passed by reference and exposed to the local scope of settings.php, so as to allow it to be decorated with Symfony's ApcClassLoader, for example.
See Also
default.settings.php

References Database\setMultipleConnectionInfo().

Referenced by DrupalKernel\initializeSettings(), WebTestBase\initSettings(), BrowserTestBase\installDrupal(), WebTestBase\prepareSettings(), and InstallerTestBase\setUp().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: