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


PHP Settings::getAll方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $settingKeys = array_keys($this->settings->getAll());
     $io->newLine();
     $io->info($this->trans('commands.config.settings.debug.messages.current'));
     $io->newLine();
     foreach ($settingKeys as $settingKey) {
         $io->comment($settingKey, false);
         $io->simple(Yaml::encode($this->settings->get($settingKey)));
     }
     $io->newLine();
 }
开发者ID:GDrupal,项目名称:DrupalConsole,代码行数:16,代码来源:SettingsDebugCommand.php

示例2: 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

示例3: 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

示例4: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Empty the PHP storage settings, as KernelTestBase sets it by default.
     $settings = Settings::getAll();
     unset($settings['php_storage']);
     new Settings($settings);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:11,代码来源:PhpStorageFactoryTest.php

示例5: setUp

 function setUp()
 {
     // Add file_private_path setting.
     $settings = Settings::getAll();
     $request = Request::create('/');
     $site_path = DrupalKernel::findSitePath($request);
     $settings['file_private_path'] = $site_path . '/private';
     new Settings($settings + Settings::getAll());
     parent::setUp();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:10,代码来源:StreamWrapperTest.php

示例6: testEmptyTranslation

 /**
  * Tests behaviour if a string is translated to become an empty string.
  */
 public function testEmptyTranslation()
 {
     $settings = Settings::getAll();
     $settings['locale_custom_strings_en'] = ['' => ['test' => '']];
     // Recreate the settings static.
     new Settings($settings);
     $variable = new TranslatableMarkup('test');
     $this->assertEquals('', $this->renderObjectWithTwig($variable));
     $variable = new TranslatableMarkup('test', [], ['langcode' => 'de']);
     $this->assertEquals('<span>test</span>', $this->renderObjectWithTwig($variable));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:14,代码来源:TwigMarkupInterfaceTest.php

示例7: rebootAndPrepareSettings

 /**
  * Reboots the kernel to set custom translations in Settings.
  */
 protected function rebootAndPrepareSettings()
 {
     // Reboot the container so that different services are injected and the new
     // settings are picked.
     $kernel = $this->container->get('kernel');
     $kernel->shutdown();
     $kernel->boot();
     $settings = Settings::getAll();
     $settings['locale_custom_strings_de'] = ['' => ['Example @number' => 'Example @number translated']];
     // Recreate the settings static.
     new Settings($settings);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:15,代码来源:TranslationStringTest.php

示例8: boot

 /**
  * {@inheritdoc}
  */
 public function boot()
 {
     // Ensure that required Settings exist.
     if (!Settings::getAll()) {
         new Settings(array('hash_salt' => 'run-tests'));
     }
     // Remove Drupal's error/exception handlers; they are designed for HTML
     // and there is no storage nor a (watchdog) logger here.
     restore_error_handler();
     restore_exception_handler();
     // In addition, ensure that PHP errors are not hidden away in logs.
     ini_set('display_errors', TRUE);
     parent::boot();
     $this->getContainer()->get('module_handler')->loadAll();
     simpletest_classloader_register();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:19,代码来源:TestRunnerKernel.php

示例9: boot

 /**
  * {@inheritdoc}
  */
 public function boot()
 {
     // Ensure that required Settings exist.
     if (!Settings::getAll()) {
         new Settings(array('hash_salt' => 'run-tests', 'file_public_path' => 'sites/default/files'));
     }
     // Remove Drupal's error/exception handlers; they are designed for HTML
     // and there is no storage nor a (watchdog) logger here.
     restore_error_handler();
     restore_exception_handler();
     // In addition, ensure that PHP errors are not hidden away in logs.
     ini_set('display_errors', TRUE);
     parent::boot();
     $this->getContainer()->get('module_handler')->loadAll();
     simpletest_classloader_register();
     // Create the build/artifacts directory if necessary.
     if (!is_dir('public://simpletest')) {
         mkdir('public://simpletest', 0777, TRUE);
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:23,代码来源:TestRunnerKernel.php

示例10: 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>' . Html::escape($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');
     // Tests caching of inline templates with long content to ensure the
     // generated cache key can be used as a filename.
     $element = [];
     $element['test'] = ['#type' => 'inline_template', '#template' => 'Llamas sometimes spit and wrestle with their {{ llama }}. Kittens are soft and fuzzy and they sometimes say {{ kitten }}. Flamingos have long legs and they are usually {{ flamingo }}. Pandas eat bamboo and they are {{ panda }}. Giraffes have long necks and long tongues and they eat {{ giraffe }}.', '#context' => ['llama' => 'necks', 'kitten' => 'meow', 'flamingo' => 'pink', 'panda' => 'bears', 'giraffe' => 'leaves']];
     $expected = 'Llamas sometimes spit and wrestle with their necks. Kittens are soft and fuzzy and they sometimes say meow. Flamingos have long legs and they are usually pink. Pandas eat bamboo and they are bears. Giraffes have long necks and long tongues and they eat leaves.';
     $element_copy = $element;
     // Render it twice so that twig caching is triggered.
     $this->assertEqual($renderer->renderRoot($element), $expected);
     $this->assertEqual($renderer->renderRoot($element_copy), $expected);
     $name = '{# inline_template_start #}' . $element['test']['#template'];
     $hash = $this->container->getParameter('twig_extension_hash');
     $cache = $environment->getCache();
     $class = $environment->getTemplateClass($name);
     $expected = $hash . '_inline-template' . '_' . hash('sha256', $class);
     $this->assertEqual($expected, $cache->generateKey($name, $class));
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:44,代码来源:TwigEnvironmentTest.php

示例11: testParagraphsRevisions

 /**
  * Tests the revision of paragraphs.
  */
 public function testParagraphsRevisions()
 {
     // Create the paragraph type.
     $paragraph_type = ParagraphsType::create(array('label' => 'test_text', 'id' => 'test_text'));
     $paragraph_type->save();
     $paragraph_type_nested = ParagraphsType::create(array('label' => 'test_nested', 'id' => 'test_nested'));
     $paragraph_type_nested->save();
     // Add a paragraph field to the article.
     $field_storage = FieldStorageConfig::create(array('field_name' => 'nested_paragraph_field', 'entity_type' => 'paragraph', 'type' => 'entity_reference_revisions', 'cardinality' => '-1', 'settings' => array('target_type' => 'paragraph')));
     $field_storage->save();
     $field = FieldConfig::create(array('field_storage' => $field_storage, 'bundle' => 'test_nested'));
     $field->save();
     // Add a paragraph field to the article.
     $field_storage = FieldStorageConfig::create(array('field_name' => 'node_paragraph_field', 'entity_type' => 'node', 'type' => 'entity_reference_revisions', 'cardinality' => '-1', 'settings' => array('target_type' => 'paragraph')));
     $field_storage->save();
     $field = FieldConfig::create(array('field_storage' => $field_storage, 'bundle' => 'article'));
     $field->save();
     // Add a paragraph field to the user.
     $field_storage = FieldStorageConfig::create(array('field_name' => 'user_paragraph_field', 'entity_type' => 'user', 'type' => 'entity_reference_revisions', 'settings' => array('target_type' => 'paragraph')));
     $field_storage->save();
     $field = FieldConfig::create(array('field_storage' => $field_storage, 'bundle' => 'user'));
     $field->save();
     // Create a paragraph.
     $paragraph1 = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_text']);
     $paragraph1->save();
     // Create another paragraph.
     $paragraph2 = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_text']);
     $paragraph2->save();
     // Create another paragraph.
     $paragraph3 = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_text']);
     $paragraph3->save();
     // Create another paragraph.
     $paragraph_nested_children1 = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_text']);
     $paragraph_nested_children1->save();
     // Create another paragraph.
     $paragraph_nested_children2 = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_text']);
     $paragraph_nested_children2->save();
     // Create another paragraph.
     $paragraph4_nested_parent = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_nested', 'nested_paragraph_field' => [$paragraph_nested_children1, $paragraph_nested_children2]]);
     $paragraph4_nested_parent->save();
     // Create another paragraph.
     $paragraph_user_1 = Paragraph::create(['title' => 'Paragraph', 'type' => 'test_text']);
     $paragraph_user_1->save();
     // Create a node with two paragraphs.
     $node = Node::create(['title' => $this->randomMachineName(), 'type' => 'article', 'node_paragraph_field' => array($paragraph1, $paragraph2, $paragraph3, $paragraph4_nested_parent)]);
     $node->save();
     // Create an user with a paragraph.
     $user = User::create(['name' => 'test', 'user_paragraph_field' => $paragraph_user_1]);
     $user->save();
     $settings = Settings::getAll();
     $settings['paragraph_limit'] = 1;
     new Settings($settings);
     // Unset the parent field name, type and id of paragraph1.
     /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
     $paragraph = Paragraph::load($paragraph1->id());
     $paragraph->set('parent_field_name', NULL);
     $paragraph->set('parent_type', NULL);
     $paragraph->set('parent_id', NULL);
     $paragraph->setNewRevision(FALSE);
     $paragraph->save();
     // Unset the parent field name, type and id of paragraph2.
     $paragraph = Paragraph::load($paragraph2->id());
     $paragraph->set('parent_field_name', NULL);
     $paragraph->set('parent_type', NULL);
     $paragraph->set('parent_id', NULL);
     $paragraph->setNewRevision(FALSE);
     $paragraph->save();
     // Unset the parent field name, type and id of $paragraph_nested_parent.
     $paragraph = Paragraph::load($paragraph4_nested_parent->id());
     $paragraph->set('parent_field_name', NULL);
     $paragraph->set('parent_type', NULL);
     $paragraph->set('parent_id', NULL);
     $paragraph->setNewRevision(FALSE);
     $paragraph->save();
     // Unset the parent field name, type and id of $paragraph_nested_children1.
     $paragraph = Paragraph::load($paragraph_nested_children1->id());
     $paragraph->set('parent_field_name', NULL);
     $paragraph->set('parent_type', NULL);
     $paragraph->set('parent_id', NULL);
     $paragraph->setNewRevision(FALSE);
     $paragraph->save();
     // Unset the parent field name, type and id of paragraph_user_1.
     /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
     $paragraph = Paragraph::load($paragraph_user_1->id());
     $paragraph->set('parent_field_name', NULL);
     $paragraph->set('parent_type', NULL);
     $paragraph->set('parent_id', NULL);
     $paragraph->setNewRevision(FALSE);
     $paragraph->save();
     // Create a revision for node.
     /** @var \Drupal\node\Entity\Node $node_revision1 */
     $node_revision1 = Node::load($node->id());
     /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph1_revision1 */
     $paragraph1_revision1 = Paragraph::load($paragraph1->id());
     $paragraph1_revision1->setNewRevision(TRUE);
     $paragraph1_revision1->save();
     /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph2_revision1 */
//.........这里部分代码省略.........
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:101,代码来源:ParagraphsCompositeRelationshipTest.php

示例12: setUp

    /**
     * {@inheritdoc}
     */
    protected function setUp()
    {
        $this->keyValueFactory = new KeyValueMemoryFactory();
        // Back up settings from TestBase::prepareEnvironment().
        $settings = Settings::getAll();
        // Allow for test-specific overrides.
        $directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
        $settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
        $container_yamls = [];
        if (file_exists($settings_services_file)) {
            // Copy the testing-specific service overrides in place.
            $testing_services_file = $directory . '/services.yml';
            copy($settings_services_file, $testing_services_file);
            $container_yamls[] = $testing_services_file;
        }
        $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php';
        if (file_exists($settings_testing_file)) {
            // Copy the testing-specific settings.php overrides in place.
            copy($settings_testing_file, $directory . '/settings.testing.php');
        }
        if (file_exists($directory . '/settings.testing.php')) {
            // Add the name of the testing class to settings.php and include the
            // testing specific overrides
            $hash_salt = Settings::getHashSalt();
            $test_class = get_class($this);
            $container_yamls_export = Variable::export($container_yamls);
            $php = <<<EOD
<?php

\$settings['hash_salt'] = '{$hash_salt}';
\$settings['container_yamls'] = {$container_yamls_export};

\$test_class = '{$test_class}';
include DRUPAL_ROOT . '/' . \$site_path . '/settings.testing.php';
EOD;
            file_put_contents($directory . '/settings.php', $php);
        }
        // Add this test class as a service provider.
        // @todo Remove the indirection; implement ServiceProviderInterface instead.
        $GLOBALS['conf']['container_service_providers']['TestServiceProvider'] = 'Drupal\\simpletest\\TestServiceProvider';
        // Bootstrap a new kernel.
        $class_loader = (require DRUPAL_ROOT . '/autoload.php');
        $this->kernel = new DrupalKernel('testing', $class_loader, FALSE);
        $request = Request::create('/');
        $site_path = DrupalKernel::findSitePath($request);
        $this->kernel->setSitePath($site_path);
        if (file_exists($directory . '/settings.testing.php')) {
            Settings::initialize(DRUPAL_ROOT, $site_path, $class_loader);
        }
        $this->kernel->boot();
        // Ensure database install tasks have been run.
        require_once __DIR__ . '/../../../includes/install.inc';
        $connection = Database::getConnection();
        $errors = db_installer_object($connection->driver())->runTasks();
        if (!empty($errors)) {
            $this->fail('Failed to run installer database tasks: ' . implode(', ', $errors));
        }
        // Reboot the kernel because the container might contain a connection to the
        // database that has been closed during the database install tasks. This
        // prevents any services created during the first boot from having stale
        // database connections, for example, \Drupal\Core\Config\DatabaseStorage.
        $this->kernel->shutdown();
        $this->kernel->boot();
        // Save the original site directory path, so that extensions in the
        // site-specific directory can still be discovered in the test site
        // environment.
        // @see \Drupal\Core\Extension\ExtensionDiscovery::scan()
        $settings['test_parent_site'] = $this->originalSite;
        // Restore and merge settings.
        // DrupalKernel::boot() initializes new Settings, and the containerBuild()
        // method sets additional settings.
        new Settings($settings + Settings::getAll());
        // Create and set new configuration directories.
        $this->prepareConfigDirectories();
        // Set the request scope.
        $this->container = $this->kernel->getContainer();
        $this->container->get('request_stack')->push($request);
        // Re-inject extension file listings into state, unless the key/value
        // service was overridden (in which case its storage does not exist yet).
        if ($this->container->get('keyvalue') instanceof KeyValueMemoryFactory) {
            $this->container->get('state')->set('system.module.files', $this->moduleFiles);
            $this->container->get('state')->set('system.theme.files', $this->themeFiles);
        }
        // Create a minimal core.extension configuration object so that the list of
        // enabled modules can be maintained allowing
        // \Drupal\Core\Config\ConfigInstaller::installDefaultConfig() to work.
        // Write directly to active storage to avoid early instantiation of
        // the event dispatcher which can prevent modules from registering events.
        \Drupal::service('config.storage')->write('core.extension', array('module' => array(), 'theme' => array()));
        // Collect and set a fixed module list.
        $class = get_class($this);
        $modules = array();
        while ($class) {
            if (property_exists($class, 'modules')) {
                // Only add the modules, if the $modules property was not inherited.
                $rp = new \ReflectionProperty($class, 'modules');
                if ($rp->class == $class) {
//.........这里部分代码省略.........
开发者ID:isramv,项目名称:camp-gdl,代码行数:101,代码来源:KernelTestBase.php

示例13: settingsSet

 /**
  * Changes in memory settings.
  *
  * @param $name
  *   The name of the setting to return.
  * @param $value
  *   The value of the setting.
  *
  * @see \Drupal\Core\Site\Settings::get()
  */
 protected function settingsSet($name, $value)
 {
     $settings = Settings::getAll();
     $settings[$name] = $value;
     new Settings($settings);
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:16,代码来源:TestBase.php

示例14: testGetAll

 /**
  * @covers ::getAll
  */
 public function testGetAll()
 {
     $this->assertEquals($this->config, Settings::getAll());
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:7,代码来源:SettingsTest.php

示例15: trim

<?php

$copy = \Drupal\Core\Site\Settings::getAll();
$copy['php_storage']['twig']['class'] = "Drupal\\Component\\PhpStorage\\FileStorage";
$foo = new \Drupal\Core\Site\Settings($copy);
require_once "core/themes/engines/twig/twig.engine";
while ($f = trim(fgets(STDIN))) {
    if (stripos($f, 'tests') === FALSE) {
        twig_render_template(substr($f, 2), []);
    }
}
开发者ID:goragod,项目名称:oss-performance,代码行数:11,代码来源:setup.php


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