-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from JakyeRU/feature/custom-callback
Custom Callback
- Loading branch information
Showing
10 changed files
with
264 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Jakyeru\Larascord\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class PublishCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'larascord:publish | ||
{--force : Overwrite any existing files.}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Use this command to publish Larascord\'s settings.'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
// Checking if the configuration has already been published. | ||
if (file_exists(config_path('larascord.php')) && !$this->option('force')) { | ||
$this->error('The configuration file has already been published.'); | ||
$this->error('If you want to overwrite the existing file, use the --force option.'); | ||
|
||
return; | ||
} | ||
|
||
// Checking if the command should be run forcefully. | ||
if ($this->option('force')) { | ||
$this->warn('This command is running in force mode. Any existing configuration file will be overwritten.'); | ||
} | ||
|
||
// Publish the configuration file. | ||
try { | ||
shell_exec('php artisan vendor:publish --provider="Jakyeru\Larascord\LarascordServiceProvider" --tag=config' . ($this->option('force') ? ' --force' : '')); | ||
} catch (\Exception $e) { | ||
$this->error('Could not publish the configuration file.'); | ||
$this->error($e->getMessage()); | ||
} | ||
|
||
// Inform the user that the command has finished. | ||
$this->info('Larascord\'s settings have been published successfully.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.