Skip to content

Commit

Permalink
Add botman:cache:clear command (#26)
Browse files Browse the repository at this point in the history
rashidlaasri authored and mpociot committed Sep 12, 2018
1 parent e4484a7 commit c34e49b
Showing 2 changed files with 52 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/Console/Commands/BotManCacheClear.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace BotMan\Studio\Console\Commands;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Console\GeneratorCommand;

class BotManCacheClear extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'botman:cache:clear';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Remove all cached conversations.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @return mixed
*/
public function handle(Filesystem $files)
{
$cacheFolder = storage_path('botman');

if ($files->exists($cacheFolder)) {
$files->cleanDirectory($cacheFolder);
}

$this->info('BotMan cache cleared!');
}
}
2 changes: 2 additions & 0 deletions src/Providers/StudioServiceProvider.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
use Illuminate\Support\ServiceProvider;
use TheCodingMachine\Discovery\Discovery;
use BotMan\Studio\Console\Commands\BotManMakeTest;
use BotMan\Studio\Console\Commands\BotManCacheClear;
use BotMan\Studio\Console\Commands\BotManListDrivers;
use BotMan\Studio\Console\Commands\BotManInstallDriver;
use BotMan\Studio\Console\Commands\BotManMakeMiddleware;
@@ -23,6 +24,7 @@ public function register()
BotManMakeMiddleware::class,
BotManMakeConversation::class,
BotManMakeTest::class,
BotManCacheClear::class,
]);

$this->discoverCommands();

0 comments on commit c34e49b

Please sign in to comment.