Skip to content

Commit

Permalink
Adding publish command
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Jan 9, 2016
1 parent 29b2bf8 commit 3c16452
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Console/PublishCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php namespace Arcanesoft\Settings\Console;

use Arcanedev\Support\Bases\Command;

/**
* Class PublishCommand
*
* @package Arcanesoft\Auth\Console
* @author ARCANEDEV <[email protected]>
*/
class PublishCommand extends Command
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'settings:publish';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Publish settings config, migrations.';

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Execute the console command.
*/
public function handle()
{
$this->call('vendor:publish', [
'--provider' => \Arcanesoft\Settings\SettingsServiceProvider::class,
]);
}
}
55 changes: 55 additions & 0 deletions src/Providers/CommandServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php namespace Arcanesoft\Settings\Providers;

use Arcanedev\Support\Providers\CommandServiceProvider as ServiceProvider;

/**
* Class CommandServiceProvider
*
* @package Arcanesoft\Settings\Providers
* @author ARCANEDEV <[email protected]>
*/
class CommandServiceProvider extends ServiceProvider
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Register the service provider.
*/
public function register()
{
$this->registerPublishCommand();

$this->commands($this->commands);
}

/**
* Get the provided commands.
*
* @return array
*/
public function provides()
{
return [
'arcanesoft.settings.commands.publish',
];
}

/* ------------------------------------------------------------------------------------------------
| Command Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Register the publish command.
*/
private function registerPublishCommand()
{
$this->app->singleton(
'arcanesoft.settings.commands.publish',
\Arcanesoft\Settings\Console\PublishCommand::class
);

$this->commands[] = \Arcanesoft\Settings\Console\PublishCommand::class;
}
}
4 changes: 4 additions & 0 deletions src/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public function register()
{
$this->registerConfig();
$this->registerSettingsManager();

if ($this->app->runningInConsole()) {
$this->app->register(Providers\CommandServiceProvider::class);
}
}

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/Console/PublishCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php namespace Arcanesoft\Settings\Tests\Console;

use Arcanesoft\Settings\Tests\TestCase;

/**
* Class PublishCommandTest
*
* @package Arcanesoft\Auth\Tests\Console
* @author ARCANEDEV <[email protected]>
*/
class PublishCommandTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
*/
/** @test */
public function it_can_publish()
{
$this->assertEquals(0, $this->artisan('settings:publish'));
}
}

0 comments on commit 3c16452

Please sign in to comment.