public function PcbCommands::flush in Permanent Cache Bin 8
Same name and namespace in other branches
- 8.2 src/Commands/PcbCommands.php \Drupal\pcb\Commands\PcbCommands::flush()
Flush permanent cache bin.
@usage pcb-flush bin Flush cache for particular bin.
@command pcb:flush @aliases pcbf, permanent-cache-bin-flush
Parameters
string $bin: Bin to flush cache of.
File
- src/
Commands/ PcbCommands.php, line 43
Class
- PcbCommands
- A Drush commandfile for pcb module.
Namespace
Drupal\pcb\CommandsCode
public function flush(string $bin) {
try {
$cache = $this->cacheFactory
->get($bin);
if (method_exists($cache, 'deleteAllPermanent')) {
$cache
->deleteAllPermanent();
$this
->logger()
->success(dt('Deleted all cache for @bin.', [
'@bin' => $bin,
]));
}
else {
$this
->logger()
->error(dt('@bin bin is not using pcb.', [
'@bin' => $bin,
]));
}
} catch (\Exception $e) {
$this
->logger()
->error(dt('@bin not a valid cache bin.', [
'@bin' => $bin,
]));
}
}