fca98a7167d9983fc6598a3160ee9887890f7da6
[yaffs-website] / vendor / drush / drush / commands / core / drupal / cache_8.inc
1 <?php
2 /**
3  * @file
4  *   Engine for the cache commands.
5  */
6
7 use Drupal\Core\Cache\Cache;
8
9 function _drush_cache_command_get($cid, $bin) {
10   if (is_null($bin)) {
11     $bin = _drush_cache_bin_default();
12   }
13   return \Drupal::cache($bin)->get($cid);
14 }
15
16 /**
17  * The default bin.
18  *
19  * @return string
20  */
21 function _drush_cache_bin_default() {
22   return 'default';
23 }
24
25 function _drush_cache_command_set($cid, $data, $bin, $expire, $tags) {
26   if (is_null($bin)) {
27     $bin = _drush_cache_bin_default();
28   }
29
30   // Convert the "expire" argument to a valid value for Drupal's cache_set().
31   if ($expire == 'CACHE_TEMPORARY') {
32     $expire = Cache::TEMPORARY;
33   }
34   if (!isset($expire) || $expire == 'CACHE_PERMANENT') {
35     $expire = Cache::PERMANENT;
36   }
37
38   return \Drupal::cache($bin)->set($cid, $data, $expire, $tags);
39 }
40
41 function _drush_cache_clear_types($include_bootstrapped_types) {
42   $types = array(
43     'drush' => 'drush_cache_clear_drush',
44   );
45   if ($include_bootstrapped_types) {
46     $types += array(
47       'theme-registry' => 'drush_cache_clear_theme_registry',
48       'router' => 'drush_cache_clear_router',
49       'css-js' => 'drush_cache_clear_css_js',
50       'module-list' => 'drush_get_modules',
51       'theme-list' => 'drush_get_themes',
52       'render' => 'drush_cache_clear_render',
53     );
54   }
55   return $types;
56 }
57
58 function drush_cache_clear_theme_registry() {
59   \Drupal::service('theme.registry')->reset();
60 }
61
62 function drush_cache_clear_router() {
63   /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
64   $router_builder = \Drupal::service('router.builder');
65   $router_builder->rebuild();
66 }
67
68 function drush_cache_clear_css_js() {
69   _drupal_flush_css_js();
70   drupal_clear_css_cache();
71   drupal_clear_js_cache();
72 }
73
74 /**
75  * Clear the cache of the block output.
76  */
77 function drush_cache_clear_block() {
78   // There is no distinct block cache in D8. See https://github.com/drush-ops/drush/issues/1531.
79   // \Drupal::cache('block')->deleteAll();
80 }
81
82 /**
83  * Clears the render cache entries.
84  */
85 function drush_cache_clear_render() {
86   Cache::invalidateTags(['rendered']);
87 }