cleaning up the session cli task.
This commit is contained in:
parent
6ced385d20
commit
f27ec7ab95
|
@ -5,9 +5,7 @@
|
||||||
use Laravel\Config;
|
use Laravel\Config;
|
||||||
use Laravel\Session;
|
use Laravel\Session;
|
||||||
use Laravel\CLI\Tasks\Task;
|
use Laravel\CLI\Tasks\Task;
|
||||||
use Laravel\Database\Schema;
|
|
||||||
use Laravel\Session\Drivers\Sweeper;
|
use Laravel\Session\Drivers\Sweeper;
|
||||||
use Laravel\CLI\Tasks\Migrate\Migrator;
|
|
||||||
|
|
||||||
class Manager extends Task {
|
class Manager extends Task {
|
||||||
|
|
||||||
|
@ -37,18 +35,10 @@ public function table($arguments = array())
|
||||||
|
|
||||||
File::put($migration, File::get($stub));
|
File::put($migration, File::get($stub));
|
||||||
|
|
||||||
// By default no session driver is specified in the configuration.
|
// By default no session driver is set within the configuration.
|
||||||
// Since the developer is requesting that the session table be
|
// Since the developer is requesting that the session table be
|
||||||
// created on the database, we'll set the driver.
|
// created on the database, we'll set it.
|
||||||
$config = File::get(path('app').'config/session'.EXT);
|
$this->driver('database');
|
||||||
|
|
||||||
$config = str_replace(
|
|
||||||
"'driver' => '',",
|
|
||||||
"'driver' => 'database',",
|
|
||||||
$config
|
|
||||||
);
|
|
||||||
|
|
||||||
File::put(path('app').'config/session'.EXT, $config);
|
|
||||||
|
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
|
|
||||||
|
@ -65,9 +55,9 @@ public function sweep($arguments = array())
|
||||||
{
|
{
|
||||||
$driver = Session::factory(Config::get('session.driver'));
|
$driver = Session::factory(Config::get('session.driver'));
|
||||||
|
|
||||||
// If the driver implements the "Sweeper" interface, we know that
|
// If the driver implements the "Sweeper" interface, we know that it
|
||||||
// it can sweep expired sessions from storage. Not all drivers
|
// can sweep expired sessions from storage. Not all drivers need be
|
||||||
// need be sweepers since they do their own.
|
// sweepers since they do their own.
|
||||||
if ($driver instanceof Sweeper)
|
if ($driver instanceof Sweeper)
|
||||||
{
|
{
|
||||||
$lifetime = Config::get('session.lifetime');
|
$lifetime = Config::get('session.lifetime');
|
||||||
|
@ -78,4 +68,26 @@ public function sweep($arguments = array())
|
||||||
echo "The session table has been swept!";
|
echo "The session table has been swept!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the session driver to a given value.
|
||||||
|
*
|
||||||
|
* @param string $driver
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function driver($driver)
|
||||||
|
{
|
||||||
|
// By default no session driver is set within the configuration.
|
||||||
|
// This method will replace the empty driver option with the
|
||||||
|
// driver specified in the arguments.
|
||||||
|
$config = File::get(path('app').'config/session'.EXT);
|
||||||
|
|
||||||
|
$config = str_replace(
|
||||||
|
"'driver' => '',",
|
||||||
|
"'driver' => 'database',",
|
||||||
|
$config
|
||||||
|
);
|
||||||
|
|
||||||
|
File::put(path('app').'config/session'.EXT, $config);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue