Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 1, 2016
1 parent 969e421 commit 7644977
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Cache/CacheServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function registerCommands()
public function provides()
{
return [
'cache', 'cache.store', 'memcached.connector', 'command.cache.clear', 'command.cache.forget',
'cache', 'cache.store', 'memcached.connector',
'command.cache.clear', 'command.cache.forget',
];
}
}
16 changes: 2 additions & 14 deletions src/Illuminate/Cache/Console/ForgetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Command;
use Illuminate\Cache\CacheManager;
use Symfony\Component\Console\Input\InputArgument;

class ForgetCommand extends Command
{
Expand All @@ -13,7 +12,7 @@ class ForgetCommand extends Command
*
* @var string
*/
protected $name = 'cache:forget';
protected $signature = 'cache:forget {key : The key to remove} {store? : The store to remove the key from}';

/**
* The console command description.
Expand Down Expand Up @@ -51,18 +50,7 @@ public function handle()
{
$this->cache->store($this->argument('store'))
->forget($this->argument('key'));
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['key', InputArgument::REQUIRED, 'The name of the key.'],
['store', InputArgument::OPTIONAL, 'The name of the store.'],
];
$this->info('The ['.$this->argument('key').'] key has been removed from the cache.');
}
}
51 changes: 31 additions & 20 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,37 @@ public function __construct(Container $laravel, Dispatcher $events, $version)
$this->bootstrap();
}

/**
* Format the given command as a fully-qualified executable command.
*
* @param string $string
* @return string
*/
public static function formatCommandString($string)
{
return sprintf('%s %s %s', static::phpBinary(), static::artisanBinary(), $string);
}

/**
* Determine the proper PHP executable.
*
* @return string
*/
public static function phpBinary()
{
return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
}

/**
* Determine the proper Artisan executable.
*
* @return string
*/
public static function artisanBinary()
{
return defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
}

/**
* Bootstrap the console application.
*
Expand Down Expand Up @@ -204,24 +235,4 @@ public function getLaravel()
{
return $this->laravel;
}

/**
* The PHP executable.
*
* @return string
*/
public static function phpBinary()
{
return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
}

/**
* The Artisan executable.
*
* @return string
*/
public static function artisanBinary()
{
return defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
}
}
6 changes: 3 additions & 3 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ public function buildCommand()
$redirect = $this->shouldAppendOutput ? ' >> ' : ' > ';

if ($this->withoutOverlapping) {
$cacheForgetCommand = sprintf('%s %s %s', Application::phpBinary(), Application::artisanBinary(), 'cache:forget');
$forget = Appliation::formatCommandString('cache:forget');

if (windows_os()) {
$command = '('.$this->command.' & '.$cacheForgetCommand.' "'.$this->mutexName().'")'.$redirect.$output.' 2>&1 &';
$command = '('.$this->command.' & '.$forget.' "'.$this->mutexName().'")'.$redirect.$output.' 2>&1 &';
} else {
$command = '('.$this->command.'; '.$cacheForgetCommand.' '.$this->mutexName().')'.$redirect.$output.' 2>&1 &';
$command = '('.$this->command.'; '.$forget.' '.$this->mutexName().')'.$redirect.$output.' 2>&1 &';
}
} else {
$command = $this->command.$redirect.$output.' 2>&1 &';
Expand Down
3 changes: 1 addition & 2 deletions src/Illuminate/Console/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public function command($command, array $parameters = [])
}

return $this->exec(
sprintf('%s %s %s', Application::phpBinary(), Application::artisanBinary(), $command),
$parameters
Application::formatCommandString($command), $parameters
);
}

Expand Down
1 change: 0 additions & 1 deletion tests/Filesystem/tmp/file.txt

This file was deleted.

0 comments on commit 7644977

Please sign in to comment.