use Drupal\Core\Site\Settings;
use Drupal\Core\Cache\Cache;
use Drush\Drush;
+use Drush\Utils\StringUtils;
use Symfony\Component\HttpFoundation\Request;
/*
*
* @command cache:clear
* @param string $type The particular cache to clear. Omit this argument to choose from available types.
+ * @param array $args Additional arguments as might be expected (e.g. bin name).
* @option cache-clear Set to 0 to suppress normal cache clearing; the caller should then clear if needed.
* @hidden-options cache-clear
* @aliases cc,cache-clear
* @bootstrap max
* @notify Caches have been cleared.
+ * @usage drush cc bin entity,bootstrap
+ * Clear the entity and bootstrap cache bins.
*/
- public function clear($type, $options = ['cache-clear' => true])
+ public function clear($type, array $args, $options = ['cache-clear' => true])
{
$boot_manager = Drush::bootstrapManager();
$types = $this->getTypes($boot_manager->hasBootstrapped((DRUSH_BOOTSTRAP_DRUPAL_FULL)));
// Do it.
- drush_op($types[$type]);
+ drush_op($types[$type], $args);
$this->logger()->success(dt("'!name' cache was cleared.", ['!name' => $type]));
}
'router' => [$this, 'clearRouter'],
'css-js' => [$this, 'clearCssJs'],
'render' => [$this, 'clearRender'],
+ 'plugin' => [$this, 'clearPlugin'],
+ 'bin' => [$this, 'clearBins'],
];
}
drush_cache_clear_all(null, 'factory'); // command info from annotated-command library
}
+ /**
+ * Clear one or more cache bins.
+ */
+ public static function clearBins($args = ['default'])
+ {
+ $bins = StringUtils::csvToArray($args);
+ foreach ($bins as $bin) {
+ \Drupal::service("cache.$bin")->deleteAll();
+ }
+ }
+
public static function clearThemeRegistry()
{
\Drupal::service('theme.registry')->reset();
Cache::invalidateTags(['rendered']);
}
+ public static function clearPlugin()
+ {
+ \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
+ }
+
/**
* Loads the Drupal autoloader and returns the instance.
*/