当前位置: 首页>>代码示例>>PHP>>正文


PHP Site\Settings类代码示例

本文整理汇总了PHP中Drupal\Core\Site\Settings的典型用法代码示例。如果您正苦于以下问题:PHP Settings类的具体用法?PHP Settings怎么用?PHP Settings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructs a PathProcessorLanguage object.
  *
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config
  *   A config factory object for retrieving configuration settings.
  * @param \Drupal\Core\Site\Settings $settings
  *   The settings instance.
  * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager
  *   The configurable language manager.
  * @param \Drupal\language\LanguageNegotiatorInterface
  *   The language negotiator.
  * @param \Drupal\Core\Session\AccountInterface $current_user
  *   The current active user.
  */
 public function __construct(ConfigFactoryInterface $config, Settings $settings, ConfigurableLanguageManagerInterface $language_manager, LanguageNegotiatorInterface $negotiator, AccountInterface $current_user)
 {
     $this->config = $config;
     $this->mixedModeSessions = $settings->get('mixed_mode_sessions', FALSE);
     $this->languageManager = $language_manager;
     $this->negotiator = $negotiator;
     $this->negotiator->setCurrentUser($current_user);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:22,代码来源:PathProcessorLanguage.php

示例2: trustedHeadersAreSet

 /**
  * Tests that trusted header methods are called.
  *
  * \Symfony\Component\HttpFoundation\Request::setTrustedHeaderName() and
  * \Symfony\Component\HttpFoundation\Request::setTrustedProxies() should
  * always be called when reverse proxy settings are enabled.
  *
  * @param \Drupal\Core\Site\Settings $settings
  *   The settings object that holds reverse proxy configuration.
  */
 protected function trustedHeadersAreSet(Settings $settings)
 {
     $middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings);
     $request = new Request();
     $middleware->handle($request);
     $this->assertSame($settings->get('reverse_proxy_header'), $request->getTrustedHeaderName($request::HEADER_CLIENT_IP));
     $this->assertSame($settings->get('reverse_proxy_addresses'), $request->getTrustedProxies());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:18,代码来源:ReverseProxyMiddlewareTest.php

示例3: trustedHeadersAreSet

 /**
  * Tests that trusted header methods are called.
  *
  * \Symfony\Component\HttpFoundation\Request::setTrustedHeaderName() and
  * \Symfony\Component\HttpFoundation\Request::setTrustedProxies() should
  * always be called when reverse proxy settings are enabled.
  *
  * @param \Drupal\Core\Site\Settings $settings
  *   The settings object that holds reverse proxy configuration.
  */
 protected function trustedHeadersAreSet(Settings $settings)
 {
     $subscriber = new ReverseProxySubscriber($settings);
     $request = new Request();
     $event = $this->getMockedEvent($request);
     $subscriber->onKernelRequestReverseProxyCheck($event);
     $this->assertSame($settings->get('reverse_proxy_header'), $request->getTrustedHeaderName($request::HEADER_CLIENT_IP));
     $this->assertSame($settings->get('reverse_proxy_addresses'), $request->getTrustedProxies());
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:ReverseProxySubscriberUnitTest.php

示例4: __construct

 /**
  *  Constructs a new generator object.
  *
  * @param \Drupal\Core\Routing\RouteProviderInterface $provider
  *   The route provider to be searched for routes.
  * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
  *   The path processor to convert the system path to one suitable for urls.
  * @param \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $route_processor
  *   The route processor.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config
  *    The config factory.
  * @param \Drupal\Core\Site\Settings $settings
  *    The read only settings.
  * @param \Psr\Log\LoggerInterface $logger
  *   An optional logger for recording errors.
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   A request stack object.
  */
 public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, ConfigFactoryInterface $config, Settings $settings, LoggerInterface $logger = NULL, RequestStack $request_stack)
 {
     parent::__construct($provider, $logger);
     $this->pathProcessor = $path_processor;
     $this->routeProcessor = $route_processor;
     $this->mixedModeSessions = $settings->get('mixed_mode_sessions', FALSE);
     $allowed_protocols = $config->get('system.filter')->get('protocols') ?: array('http', 'https');
     UrlHelper::setAllowedProtocols($allowed_protocols);
     $this->requestStack = $request_stack;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:28,代码来源:UrlGenerator.php

示例5: __construct

 /**
  * Constructs the factory object.
  *
  * @param \Drupal\Core\Site\Settings $settings
  *   An object with site settings.
  *
  * @throws \Drupal\memcache_storage\DrupalMemcachedInitializeException
  */
 public function __construct(Settings $settings)
 {
     // Validate pecl extension configuration.
     $this->extension = DrupalMemcachedUtils::getPeclExtension();
     if (!class_exists($this->extension) || !in_array($this->extension, ['Memcache', 'Memcached'])) {
         throw new DrupalMemcachedInitializeException('Could not initialize ' . $this->extension . ' PECL extension');
     }
     // Keep memcache_storage settings.
     $this->settings = $settings->get('memcache_storage', []);
     // Get configuration of cache bins per memcached clusters.
     if (!empty($this->settings['bins_clusters'])) {
         $this->bins_clusters = $this->settings['bins_clusters'];
     }
 }
开发者ID:jepster,项目名称:GaiaD8,代码行数:22,代码来源:DrupalMemcachedFactory.php

示例6: __construct

 /**
  * Constructs ChainedFastBackendFactory object.
  *
  * @param \Drupal\Core\Site\Settings|NULL $settings
  *   (optional) The settings object.
  * @param string|NULL $consistent_service_name
  *   (optional) The service name of the consistent backend factory. Defaults
  *   to:
  *   - $settings->get('cache')['default'] (if specified)
  *   - 'cache.backend.database' (if the above isn't specified)
  * @param string|NULL $fast_service_name
  *   (optional) The service name of the fast backend factory. Defaults to:
  *   - 'cache.backend.apcu' (if the PHP process has APCu enabled)
  *   - NULL (if the PHP process doesn't have APCu enabled)
  */
 public function __construct(Settings $settings = NULL, $consistent_service_name = NULL, $fast_service_name = NULL)
 {
     // Default the consistent backend to the site's default backend.
     if (!isset($consistent_service_name)) {
         $cache_settings = isset($settings) ? $settings->get('cache') : array();
         $consistent_service_name = isset($cache_settings['default']) ? $cache_settings['default'] : 'cache.backend.database';
     }
     // Default the fast backend to APCu if it's available.
     if (!isset($fast_service_name) && function_exists('apc_fetch')) {
         $fast_service_name = 'cache.backend.apcu';
     }
     $this->consistentServiceName = $consistent_service_name;
     $this->fastServiceName = $fast_service_name;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:ChainedFastBackendFactory.php

示例7: testServicesYml

    /**
     * Tests services.yml in site directory.
     */
    public function testServicesYml()
    {
        $container_yamls = Settings::get('container_yamls');
        $container_yamls[] = $this->siteDirectory . '/services.yml';
        $this->settingsSet('container_yamls', $container_yamls);
        $this->assertFalse($this->container->has('site.service.yml'));
        // A service provider class always has precedence over services.yml files.
        // KernelTestBase::buildContainer() swaps out many services with in-memory
        // implementations already, so those cannot be tested.
        $this->assertIdentical(get_class($this->container->get('cache.backend.database')), 'Drupal\\Core\\Cache\\DatabaseBackendFactory');
        $class = __CLASS__;
        $doc = <<<EOD
services:
  # Add a new service.
  site.service.yml:
    class: {$class}
  # Swap out a core service.
  cache.backend.database:
    class: Drupal\\Core\\Cache\\MemoryBackendFactory
EOD;
        file_put_contents($this->siteDirectory . '/services.yml', $doc);
        // Rebuild the container.
        $this->container->get('kernel')->rebuildContainer();
        $this->assertTrue($this->container->has('site.service.yml'));
        $this->assertIdentical(get_class($this->container->get('cache.backend.database')), 'Drupal\\Core\\Cache\\MemoryBackendFactory');
    }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:29,代码来源:DrupalKernelSiteTest.php

示例8: testInlineTemplate

 /**
  * Tests inline templates.
  */
 public function testInlineTemplate()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = $this->container->get('renderer');
     /** @var \Drupal\Core\Template\TwigEnvironment $environment */
     $environment = \Drupal::service('twig');
     $this->assertEqual($environment->renderInline('test-no-context'), 'test-no-context');
     $this->assertEqual($environment->renderInline('test-with-context {{ llama }}', array('llama' => 'muuh')), 'test-with-context muuh');
     $element = array();
     $unsafe_string = '<script>alert(\'Danger! High voltage!\');</script>';
     $element['test'] = array('#type' => 'inline_template', '#template' => 'test-with-context <label>{{ unsafe_content }}</label>', '#context' => array('unsafe_content' => $unsafe_string));
     $this->assertEqual($renderer->renderRoot($element), 'test-with-context <label>' . SafeMarkup::checkPlain($unsafe_string) . '</label>');
     // Enable twig_auto_reload and twig_debug.
     $settings = Settings::getAll();
     $settings['twig_debug'] = TRUE;
     $settings['twig_auto_reload'] = TRUE;
     new Settings($settings);
     $this->container = $this->kernel->rebuildContainer();
     \Drupal::setContainer($this->container);
     $element = array();
     $element['test'] = array('#type' => 'inline_template', '#template' => 'test-with-context {{ llama }}', '#context' => array('llama' => 'muuh'));
     $element_copy = $element;
     // Render it twice so that twig caching is triggered.
     $this->assertEqual($renderer->renderRoot($element), 'test-with-context muuh');
     $this->assertEqual($renderer->renderRoot($element_copy), 'test-with-context muuh');
 }
开发者ID:scratch,项目名称:gai,代码行数:29,代码来源:TwigEnvironmentTest.php

示例9: register

 /**
  * {@inheritdoc}
  */
 public function register(ContainerBuilder $container)
 {
     $this->registerUuid($container);
     $this->registerTest($container);
     // Only register the private file stream wrapper if a file path has been set.
     if (Settings::get('file_private_path')) {
         $container->register('stream_wrapper.private', 'Drupal\\Core\\StreamWrapper\\PrivateStream')->addTag('stream_wrapper', ['scheme' => 'private']);
     }
     // Add the compiler pass that lets service providers modify existing
     // service definitions. This pass must come first so that later
     // list-building passes are operating on the post-alter services list.
     $container->addCompilerPass(new ModifyServiceDefinitionsPass());
     $container->addCompilerPass(new BackendCompilerPass());
     $container->addCompilerPass(new StackedKernelPass());
     $container->addCompilerPass(new StackedSessionHandlerPass());
     $container->addCompilerPass(new MainContentRenderersPass());
     // Collect tagged handler services as method calls on consumer services.
     $container->addCompilerPass(new TaggedHandlersPass());
     $container->addCompilerPass(new RegisterStreamWrappersPass());
     // Add a compiler pass for registering event subscribers.
     $container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
     $container->addCompilerPass(new RegisterAccessChecksPass());
     $container->addCompilerPass(new RegisterLazyRouteEnhancers());
     $container->addCompilerPass(new RegisterLazyRouteFilters());
     // Add a compiler pass for registering services needing destruction.
     $container->addCompilerPass(new RegisterServicesForDestructionPass());
     // Add the compiler pass that will process the tagged services.
     $container->addCompilerPass(new ListCacheBinsPass());
     $container->addCompilerPass(new CacheContextsPass());
     // Register plugin managers.
     $container->addCompilerPass(new PluginManagerPass());
     $container->addCompilerPass(new DependencySerializationTraitPass());
 }
开发者ID:jeyram,项目名称:camp-gdl,代码行数:36,代码来源:CoreServiceProvider.php

示例10: getToken

 public static function getToken($user)
 {
     //@todo, check to see if we have a token stored for this user
     $key = Settings::get('hash_salt');
     $token = array("uid" => $user->id(), "mail" => $user->getEmail());
     return \JWT::encode($token, $key);
 }
开发者ID:voryx,项目名称:ThruwayDrupal,代码行数:7,代码来源:Utils.php

示例11: testDrupalRewriteSettings

    /**
     * Tests the drupal_rewrite_settings() function.
     */
    function testDrupalRewriteSettings()
    {
        include_once \Drupal::root() . '/core/includes/install.inc';
        $site_path = $this->container->get('site.path');
        $tests = array(array('original' => '$no_index_value_scalar = TRUE;', 'settings' => array('no_index_value_scalar' => (object) array('value' => FALSE, 'comment' => 'comment')), 'expected' => '$no_index_value_scalar = false; // comment'), array('original' => '$no_index_value_scalar = TRUE;', 'settings' => array('no_index_value_foo' => array('foo' => array('value' => (object) array('value' => NULL, 'required' => TRUE, 'comment' => 'comment')))), 'expected' => <<<'EXPECTED'
$no_index_value_scalar = TRUE;
$no_index_value_foo['foo']['value'] = NULL; // comment
EXPECTED
), array('original' => '$no_index_value_array = array("old" => "value");', 'settings' => array('no_index_value_array' => (object) array('value' => FALSE, 'required' => TRUE, 'comment' => 'comment')), 'expected' => '$no_index_value_array = array("old" => "value");
$no_index_value_array = false; // comment'), array('original' => '$has_index_value_scalar["foo"]["bar"] = NULL;', 'settings' => array('has_index_value_scalar' => array('foo' => array('bar' => (object) array('value' => FALSE, 'required' => TRUE, 'comment' => 'comment')))), 'expected' => '$has_index_value_scalar["foo"]["bar"] = false; // comment'), array('original' => '$has_index_value_scalar["foo"]["bar"] = "foo";', 'settings' => array('has_index_value_scalar' => array('foo' => array('value' => (object) array('value' => array('value' => 2), 'required' => TRUE, 'comment' => 'comment')))), 'expected' => <<<'EXPECTED'
$has_index_value_scalar["foo"]["bar"] = "foo";
$has_index_value_scalar['foo']['value'] = array (
  'value' => 2,
); // comment
EXPECTED
));
        foreach ($tests as $test) {
            $filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php';
            file_put_contents(\Drupal::root() . '/' . $filename, "<?php\n" . $test['original'] . "\n");
            drupal_rewrite_settings($test['settings'], $filename);
            $this->assertEqual(file_get_contents(\Drupal::root() . '/' . $filename), "<?php\n" . $test['expected'] . "\n");
        }
        // Test that <?php gets added to the start of an empty settings file.
        // Set the array of settings that will be written to the file.
        $test = array('settings' => array('no_index' => (object) array('value' => TRUE, 'required' => TRUE)), 'expected' => '$no_index = true;');
        // Make an empty file.
        $filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php';
        file_put_contents(\Drupal::root() . '/' . $filename, "");
        // Write the setting to the file.
        drupal_rewrite_settings($test['settings'], $filename);
        // Check that the result is just the php opening tag and the settings.
        $this->assertEqual(file_get_contents(\Drupal::root() . '/' . $filename), "<?php\n" . $test['expected'] . "\n");
    }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:36,代码来源:SettingsRewriteTest.php

示例12: testSitesDirectoryHardeningConfig

 /**
  * Tests writable files remain writable when directory hardening is disabled.
  */
 public function testSitesDirectoryHardeningConfig()
 {
     $site_path = $this->kernel->getSitePath();
     $settings_file = $this->settingsFile($site_path);
     // Disable permissions enforcement.
     $settings = Settings::getAll();
     $settings['skip_permissions_hardening'] = TRUE;
     new Settings($settings);
     $this->assertTrue(Settings::get('skip_permissions_hardening'), 'Able to set hardening to true');
     $this->makeWritable($site_path);
     // Manually trigger the requirements check.
     $requirements = $this->checkSystemRequirements();
     $this->assertEqual(REQUIREMENT_WARNING, $requirements['configuration_files']['severity'], 'Warning severity is properly set.');
     $this->assertEqual($this->t('Protection disabled'), (string) $requirements['configuration_files']['description']['#context']['configuration_error_list']['#items'][0], 'Description is properly set.');
     $this->assertTrue(is_writable($site_path), 'Site directory remains writable when automatically fixing permissions is disabled.');
     $this->assertTrue(is_writable($settings_file), 'settings.php remains writable when automatically fixing permissions is disabled.');
     // Re-enable permissions enforcement.
     $settings = Settings::getAll();
     $settings['skip_permissions_hardening'] = FALSE;
     new Settings($settings);
     // Manually trigger the requirements check.
     $this->checkSystemRequirements();
     $this->assertFalse(is_writable($site_path), 'Site directory is protected when automatically fixing permissions is enabled.');
     $this->assertFalse(is_writable($settings_file), 'settings.php is protected when automatically fixing permissions is enabled.');
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:28,代码来源:SitesDirectoryHardeningTest.php

示例13: purlCheckNodeContext

 /**
  * Checks if a node's type requires a redirect.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The event to process.
  */
 public function purlCheckNodeContext(GetResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher_interface)
 {
     $route_options = $this->routeMatch->getRouteObject()->getOptions();
     $isAdminRoute = array_key_exists('_admin_route', $route_options) && $route_options['_admin_route'];
     if (!$isAdminRoute && ($matched = $this->matchedModifiers->getMatched() && ($entity = $this->routeMatch->getParameter('node')))) {
         $node_type = $this->entityStorage->load($entity->bundle());
         $purl_settings = $node_type->getThirdPartySettings('purl');
         if (!isset($purl_settings['keep_context']) || !$purl_settings['keep_context']) {
             $url = \Drupal\Core\Url::fromRoute($this->routeMatch->getRouteName(), $this->routeMatch->getRawParameters()->all(), ['host' => Settings::get('purl_base_domain'), 'absolute' => TRUE]);
             try {
                 $redirect_response = new TrustedRedirectResponse($url->toString());
                 $redirect_response->getCacheableMetadata()->setCacheMaxAge(0);
                 $modifiers = $event->getRequest()->attributes->get('purl.matched_modifiers', []);
                 $new_event = new ExitedContextEvent($event->getRequest(), $redirect_response, $this->routeMatch, $modifiers);
                 $dispatcher_interface->dispatch(PurlEvents::EXITED_CONTEXT, $new_event);
                 $event->setResponse($new_event->getResponse());
                 return;
             } catch (RedirectLoopException $e) {
                 \Drupal::logger('redirect')->warning($e->getMessage());
                 $response = new Response();
                 $response->setStatusCode(503);
                 $response->setContent('Service unavailable');
                 $event->setResponse($response);
                 return;
             }
         }
     }
 }
开发者ID:activelamp,项目名称:purl-d8,代码行数:34,代码来源:PurlNodeContextRoutes.php

示例14: onKernelRequestReverseProxyCheck

 /**
  * Passes reverse proxy settings to current request.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The Event to process.
  */
 public function onKernelRequestReverseProxyCheck(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($this->settings->get('reverse_proxy', 0)) {
         $reverse_proxy_header = $this->settings->get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
         $request::setTrustedHeaderName($request::HEADER_CLIENT_IP, $reverse_proxy_header);
         $reverse_proxy_addresses = $this->settings->get('reverse_proxy_addresses', array());
         $request::setTrustedProxies($reverse_proxy_addresses);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:16,代码来源:ReverseProxySubscriber.php

示例15: get

 /**
  * Instantiates a cache backend class for a given cache bin.
  *
  * By default, this returns an instance of the
  * Drupal\Core\Cache\DatabaseBackend class.
  *
  * Classes implementing Drupal\Core\Cache\CacheBackendInterface can register
  * themselves both as a default implementation and for specific bins.
  *
  * @param string $bin
  *   The cache bin for which a cache backend object should be returned.
  *
  * @return \Drupal\Core\Cache\CacheBackendInterface
  *   The cache backend object associated with the specified bin.
  */
 public function get($bin)
 {
     $cache_settings = $this->settings->get('cache');
     if (isset($cache_settings['bins'][$bin])) {
         $service_name = $cache_settings['bins'][$bin];
     } elseif (isset($cache_settings['default'])) {
         $service_name = $cache_settings['default'];
     } else {
         $service_name = 'cache.backend.database';
     }
     return $this->container->get($service_name)->get($bin);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:27,代码来源:CacheFactory.php


注:本文中的Drupal\Core\Site\Settings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。