Skip to content

Commit c34e49b

Browse files
rashidlaasrimpociot
authored andcommitted
Add botman:cache:clear command (#26)
1 parent e4484a7 commit c34e49b

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace BotMan\Studio\Console\Commands;
4+
5+
use Illuminate\Filesystem\Filesystem;
6+
use Illuminate\Console\GeneratorCommand;
7+
8+
class BotManCacheClear extends GeneratorCommand
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'botman:cache:clear';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Remove all cached conversations.';
23+
24+
/**
25+
* Create a new command instance.
26+
*
27+
* @return void
28+
*/
29+
public function __construct()
30+
{
31+
parent::__construct();
32+
}
33+
34+
/**
35+
* Execute the console command.
36+
*
37+
* @param \Illuminate\Filesystem\Filesystem $files
38+
* @return mixed
39+
*/
40+
public function handle(Filesystem $files)
41+
{
42+
$cacheFolder = storage_path('botman');
43+
44+
if ($files->exists($cacheFolder)) {
45+
$files->cleanDirectory($cacheFolder);
46+
}
47+
48+
$this->info('BotMan cache cleared!');
49+
}
50+
}

src/Providers/StudioServiceProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Support\ServiceProvider;
66
use TheCodingMachine\Discovery\Discovery;
77
use BotMan\Studio\Console\Commands\BotManMakeTest;
8+
use BotMan\Studio\Console\Commands\BotManCacheClear;
89
use BotMan\Studio\Console\Commands\BotManListDrivers;
910
use BotMan\Studio\Console\Commands\BotManInstallDriver;
1011
use BotMan\Studio\Console\Commands\BotManMakeMiddleware;
@@ -23,6 +24,7 @@ public function register()
2324
BotManMakeMiddleware::class,
2425
BotManMakeConversation::class,
2526
BotManMakeTest::class,
27+
BotManCacheClear::class,
2628
]);
2729

2830
$this->discoverCommands();

0 commit comments

Comments
 (0)