本文整理汇总了PHP中Drupal\Core\Cache\CacheBackendInterface::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheBackendInterface::deleteAll方法的具体用法?PHP CacheBackendInterface::deleteAll怎么用?PHP CacheBackendInterface::deleteAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Cache\CacheBackendInterface
的用法示例。
在下文中一共展示了CacheBackendInterface::deleteAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$this->cssCollectionOptimizer->deleteAll();
$this->jsCollectionOptimizer->deleteAll();
// This form allows page compression settings to be changed, which can
// invalidate cached pages in the render cache, so it needs to be cleared on
// form submit.
$this->renderCache->deleteAll();
$this->config('system.performance')->set('cache.page.use_internal', $form_state->getValue('cache'))->set('cache.page.max_age', $form_state->getValue('page_cache_maximum_age'))->set('response.gzip', $form_state->getValue('page_compression'))->set('css.preprocess', $form_state->getValue('preprocess_css'))->set('js.preprocess', $form_state->getValue('preprocess_js'))->save();
parent::submitForm($form, $form_state);
}
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state)
{
drupal_clear_css_cache();
drupal_clear_js_cache();
// This form allows page compression settings to be changed, which can
// invalidate cached pages in the render cache, so it needs to be cleared on
// form submit.
$this->renderCache->deleteAll();
$this->config('system.performance')->set('cache.page.use_internal', $form_state['values']['cache'])->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age'])->set('response.gzip', $form_state['values']['page_compression'])->set('css.preprocess', $form_state['values']['preprocess_css'])->set('js.preprocess', $form_state['values']['preprocess_js'])->save();
parent::submitForm($form, $form_state);
}
示例3: cacheClearing
/**
* Submit handler to demonstrate the various uses of cache_clear_all().
*/
public function cacheClearing($form, &$form_state)
{
switch ($form_state->getValue('cache_clear_type')) {
case 'expire':
// Here we'll remove all cache keys in the 'cache' bin that have
// expired.
$this->cacheBackend->garbageCollection();
drupal_set_message($this->t('\\Drupal::cache()->garbageCollection() was called, removing any expired cache items.'));
break;
case 'remove_all':
// This removes all keys in a bin using a super-wildcard. This
// has nothing to do with expiration. It's just brute-force removal.
$this->cacheBackend->deleteAll();
drupal_set_message($this->t('ALL entries in the "cache" bin were removed with \\Drupal::cache()->deleteAll().'));
break;
case 'remove_tag':
// This removes cache entries with the tag "cache_example" set to 1 in
// the "cache".
$tags = array('cache_example:1');
Cache::invalidateTags($tags);
drupal_set_message($this->t('Cache entries with the tag "cache_example" set to 1 in the "cache" bin were invalidated with \\Drupal\\Core\\Cache\\Cache::invalidateTags($tags).'));
break;
}
}
示例4: selection
/**
* Renders a list of available database updates.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return array
* A render array.
*/
protected function selection(Request $request)
{
// Make sure there is no stale theme registry.
$this->cache->deleteAll();
$count = 0;
$incompatible_count = 0;
$build['start'] = array('#tree' => TRUE, '#type' => 'details');
// Ensure system.module's updates appear first.
$build['start']['system'] = array();
$starting_updates = array();
$incompatible_updates_exist = FALSE;
$updates_per_module = [];
foreach (['update', 'post_update'] as $update_type) {
switch ($update_type) {
case 'update':
$updates = update_get_update_list();
break;
case 'post_update':
$updates = $this->postUpdateRegistry->getPendingUpdateInformation();
break;
}
foreach ($updates as $module => $update) {
if (!isset($update['start'])) {
$build['start'][$module] = array('#type' => 'item', '#title' => $module . ' module', '#markup' => $update['warning'], '#prefix' => '<div class="messages messages--warning">', '#suffix' => '</div>');
$incompatible_updates_exist = TRUE;
continue;
}
if (!empty($update['pending'])) {
$updates_per_module += [$module => []];
$updates_per_module[$module] = array_merge($updates_per_module[$module], $update['pending']);
$build['start'][$module] = array('#type' => 'hidden', '#value' => $update['start']);
// Store the previous items in order to merge normal updates and
// post_update functions together.
$build['start'][$module] = array('#theme' => 'item_list', '#items' => $updates_per_module[$module], '#title' => $module . ' module');
if ($update_type === 'update') {
$starting_updates[$module] = $update['start'];
}
}
if (isset($update['pending'])) {
$count = $count + count($update['pending']);
}
}
}
// Find and label any incompatible updates.
foreach (update_resolve_dependencies($starting_updates) as $data) {
if (!$data['allowed']) {
$incompatible_updates_exist = TRUE;
$incompatible_count++;
$module_update_key = $data['module'] . '_updates';
if (isset($build['start'][$module_update_key]['#items'][$data['number']])) {
if ($data['missing_dependencies']) {
$text = $this->t('This update will been skipped due to the following missing dependencies:') . '<em>' . implode(', ', $data['missing_dependencies']) . '</em>';
} else {
$text = $this->t("This update will be skipped due to an error in the module's code.");
}
$build['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
}
// Move the module containing this update to the top of the list.
$build['start'] = array($module_update_key => $build['start'][$module_update_key]) + $build['start'];
}
}
// Warn the user if any updates were incompatible.
if ($incompatible_updates_exist) {
drupal_set_message($this->t('Some of the pending updates cannot be applied because their dependencies were not met.'), 'warning');
}
if (empty($count)) {
drupal_set_message($this->t('No pending updates.'));
unset($build);
$build['links'] = array('#theme' => 'links', '#links' => $this->helpfulLinks($request));
// No updates to run, so caches won't get flushed later. Clear them now.
drupal_flush_all_caches();
} else {
$build['help'] = array('#markup' => '<p>' . $this->t('The version of Drupal you are updating from has been automatically detected.') . '</p>', '#weight' => -5);
if ($incompatible_count) {
$build['start']['#title'] = $this->formatPlural($count, '1 pending update (@number_applied to be applied, @number_incompatible skipped)', '@count pending updates (@number_applied to be applied, @number_incompatible skipped)', array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count));
} else {
$build['start']['#title'] = $this->formatPlural($count, '1 pending update', '@count pending updates');
}
// @todo Simplify with https://www.drupal.org/node/2548095
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
$url = (new Url('system.db_update', array('op' => 'run')))->setOption('base_url', $base_url);
$build['link'] = array('#type' => 'link', '#title' => $this->t('Apply pending updates'), '#attributes' => array('class' => array('button', 'button--primary')), '#weight' => 5, '#url' => $url, '#access' => $url->access($this->currentUser()));
}
return $build;
}
示例5: deleteAll
/**
* {@inheritdoc}
*/
public function deleteAll()
{
$this->markAsOutdated();
$this->consistentBackend->deleteAll();
}
示例6: deleteAll
/**
* {@inheritdoc}
*/
public function deleteAll()
{
return $this->decorated->deleteAll();
}
示例7: selection
/**
* Renders a list of available database updates.
*
* @return array
* A render array.
*/
protected function selection()
{
// Make sure there is no stale theme registry.
$this->cache->deleteAll();
$count = 0;
$incompatible_count = 0;
$build['start'] = array('#tree' => TRUE, '#type' => 'details');
// Ensure system.module's updates appear first.
$build['start']['system'] = array();
$updates = update_get_update_list();
$starting_updates = array();
$incompatible_updates_exist = FALSE;
foreach ($updates as $module => $update) {
if (!isset($update['start'])) {
$build['start'][$module] = array('#type' => 'item', '#title' => $module . ' module', '#markup' => $update['warning'], '#prefix' => '<div class="messages messages--warning">', '#suffix' => '</div>');
$incompatible_updates_exist = TRUE;
continue;
}
if (!empty($update['pending'])) {
$starting_updates[$module] = $update['start'];
$build['start'][$module] = array('#type' => 'hidden', '#value' => $update['start']);
$build['start'][$module . '_updates'] = array('#theme' => 'item_list', '#items' => $update['pending'], '#title' => $module . ' module');
}
if (isset($update['pending'])) {
$count = $count + count($update['pending']);
}
}
// Find and label any incompatible updates.
foreach (update_resolve_dependencies($starting_updates) as $data) {
if (!$data['allowed']) {
$incompatible_updates_exist = TRUE;
$incompatible_count++;
$module_update_key = $data['module'] . '_updates';
if (isset($build['start'][$module_update_key]['#items'][$data['number']])) {
if ($data['missing_dependencies']) {
$text = $this->t('This update will been skipped due to the following missing dependencies:') . '<em>' . implode(', ', $data['missing_dependencies']) . '</em>';
} else {
$text = $this->t("This update will be skipped due to an error in the module's code.");
}
$build['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
}
// Move the module containing this update to the top of the list.
$build['start'] = array($module_update_key => $build['start'][$module_update_key]) + $build['start'];
}
}
// Warn the user if any updates were incompatible.
if ($incompatible_updates_exist) {
drupal_set_message($this->t('Some of the pending updates cannot be applied because their dependencies were not met.'), 'warning');
}
// If there are entity definition updates, display their summary.
if ($this->entityDefinitionUpdateManager->needsUpdates()) {
$entity_build = array();
$summary = $this->entityDefinitionUpdateManager->getChangeSummary();
foreach ($summary as $entity_type_id => $items) {
$entity_update_key = 'entity_type_updates_' . $entity_type_id;
$entity_build[$entity_update_key] = array('#theme' => 'item_list', '#items' => $items, '#title' => $entity_type_id . ' entity type');
$count++;
}
// Display these above the module updates, since they will be run first.
$build['start'] = $entity_build + $build['start'];
}
if (empty($count)) {
drupal_set_message($this->t('No pending updates.'));
unset($build);
$build['links'] = array('#theme' => 'links', '#links' => $this->helpfulLinks());
// No updates to run, so caches won't get flushed later. Clear them now.
drupal_flush_all_caches();
} else {
$build['help'] = array('#markup' => '<p>' . $this->t('The version of Drupal you are updating from has been automatically detected.') . '</p>', '#weight' => -5);
if ($incompatible_count) {
$build['start']['#title'] = $this->formatPlural($count, '1 pending update (@number_applied to be applied, @number_incompatible skipped)', '@count pending updates (@number_applied to be applied, @number_incompatible skipped)', array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count));
} else {
$build['start']['#title'] = $this->formatPlural($count, '1 pending update', '@count pending updates');
}
$url = new Url('system.db_update', array('op' => 'run'));
$build['link'] = array('#type' => 'link', '#title' => $this->t('Apply pending updates'), '#attributes' => array('class' => array('button', 'button--primary')), '#weight' => 5, '#url' => $url);
}
return $build;
}
示例8: deleteAll
/**
* {@inheritdoc}
*/
public function deleteAll()
{
return $this->cacheBackend->deleteAll();
}