drupal_static example


class ResettableStaticTest extends KernelTestBase {

  /** * Tests drupal_static() function. * * Tests that a variable reference returned by drupal_static() gets reset when * drupal_static_reset() is called. */
  public function testDrupalStatic() {
    $name = __CLASS__ . '_' . __METHOD__;
    $var = &drupal_static($name, 'foo');
    $this->assertEquals('foo', $var, 'Variable returned by drupal_static() was set to its default.');

    // Call the specific reset and the global reset each twice to ensure that     // multiple resets can be issued without odd side effects.     $var = 'bar';
    drupal_static_reset($name);
    $this->assertEquals('foo', $var, 'Variable was reset after first invocation of name-specific reset.');
    $var = 'bar';
    drupal_static_reset($name);
    $this->assertEquals('foo', $var, 'Variable was reset after second invocation of name-specific reset.');
    $var = 'bar';
    
// Validate default configuration of the theme. If there is existing       // configuration then stop installing.       $this->configInstaller->checkConfigurationToInstall('theme', $key);

      // The value is not used; the weight is ignored for themes currently. Do       // not check schema when saving the configuration.       $extension_config
        ->set("theme.$key", 0)
        ->save(TRUE);

      // Reset theme settings.       $theme_settings = &drupal_static('theme_get_setting');
      unset($theme_settings[$key]);

      // Reset theme listing.       $this->themeHandler->reset();

      // Only install default configuration if this theme has not been installed       // already.       if (!isset($installed_themes[$key])) {
        // Install default configuration of the theme.         $this->configInstaller->installDefaultConfig('theme', $key);
      }

      
Home | Imprint | This part of the site doesn't use cookies.