getBins example

$this->defaultBin = 'render';
    $this->defaultValue = $this->randomMachineName(10);

    parent::setUp();
  }

  /** * Tests drupal_flush_all_caches(). */
  public function testFlushAllCaches() {
    // Create cache entries for each flushed cache bin.     $bins = Cache::getBins();
    $this->assertNotEmpty($bins, 'Cache::getBins() returned bins to flush.');
    foreach ($bins as $bin => $cache_backend) {
      $cid = 'test_cid_clear' . $bin;
      $cache_backend->set($cid$this->defaultValue);
    }

    // Remove all caches then make sure that they are cleared.     drupal_flush_all_caches();

    foreach ($bins as $bin => $cache_backend) {
      $cid = 'test_cid_clear' . $bin;
      

  protected function refreshVariables() {
    // Clear the tag cache.     \Drupal::service('cache_tags.invalidator')->resetChecksums();
    foreach (Cache::getBins() as $backend) {
      if (is_callable([$backend, 'reset'])) {
        $backend->reset();
      }
    }

    \Drupal::service('config.factory')->reset();
    \Drupal::service('state')->resetCache();
  }

}
/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    foreach ($this->mapper->getConfigNames() as $name) {
      $this->languageManager->getLanguageConfigOverride($this->language->getId()$name)->delete();
    }

    // Flush all persistent caches.     $this->moduleHandler->invokeAll('cache_flush');
    foreach (Cache::getBins() as $cache_backend) {
      $cache_backend->deleteAll();
    }

    $this->messenger()->addStatus($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
    // fastCGI which executes ::destruct() after the Module uninstallation page     // was sent already.     \Drupal::service('router.builder')->rebuild();

    // Let other modules react.     $this->moduleHandler->invokeAll('modules_uninstalled', [$module_list$sync_status]);

    // Flush all persistent caches.     // Any cache entry might implicitly depend on the uninstalled modules,     // so clear all of them explicitly.     $this->moduleHandler->invokeAll('cache_flush');
    foreach (Cache::getBins() as $cache_backend) {
      $cache_backend->deleteAll();
    }

    return TRUE;
  }

  /** * Helper method for removing all cache bins registered by a given module. * * @param string $module * The name of the module for which to remove all registered cache bins. */
Home | Imprint | This part of the site doesn't use cookies.