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


PHP CacheBackendInterface::deleteAll方法代码示例

本文整理汇总了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);
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:14,代码来源:PerformanceForm.php

示例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);
 }
开发者ID:shumer,项目名称:blog,代码行数:14,代码来源:PerformanceForm.php

示例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;
     }
 }
开发者ID:viljaste,项目名称:viljaste.xyz,代码行数:27,代码来源:CacheExampleForm.php

示例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;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:94,代码来源:DbUpdateController.php

示例5: deleteAll

 /**
  * {@inheritdoc}
  */
 public function deleteAll()
 {
     $this->markAsOutdated();
     $this->consistentBackend->deleteAll();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:8,代码来源:ChainedFastBackend.php

示例6: deleteAll

 /**
  * {@inheritdoc}
  */
 public function deleteAll()
 {
     return $this->decorated->deleteAll();
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:7,代码来源:CacheBackendDecorator.php

示例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;
 }
开发者ID:brstde,项目名称:gap1,代码行数:85,代码来源:DbUpdateController.php

示例8: deleteAll

 /**
  * {@inheritdoc}
  */
 public function deleteAll()
 {
     return $this->cacheBackend->deleteAll();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:CacheBackendWrapper.php


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