Skip to content

Commit

Permalink
Merge pull request #3 from TerranetMD/master
Browse files Browse the repository at this point in the history
PSR-4 and minor fixes
  • Loading branch information
Eduard committed Dec 27, 2020
2 parents b3b43dc + dc70faf commit bb94b90
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 10 deletions.
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@
"psr-0": {
"Terranet\\Options": "src/"
},
"psr-4": {
"Terranet\\Options\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"extra": {
"laravel": {
"providers": [
"Terranet\\Options\\ServiceProvider"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Exception;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Composer;
use Symfony\Component\Console\Input\InputArgument;
use Terranet\Options\Manager;

Expand All @@ -13,6 +15,32 @@ class OptionMakeCommand extends Command

protected $description = 'Insert new option';

/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;

/**
* @var \Illuminate\Support\Composer
*/
protected $composer;

/**
* Create a new session table command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\Support\Composer $composer
*/
public function __construct(Filesystem $files, Composer $composer)
{
parent::__construct();

$this->files = $files;
$this->composer = $composer;
}

public function handle()
{
$name = $this->argument('name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Terranet\Options\Console;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Composer;
use Symfony\Component\Console\Input\InputArgument;

class OptionRemoveCommand extends Command
Expand All @@ -11,6 +13,32 @@ class OptionRemoveCommand extends Command

protected $description = 'Remove an option';

/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;

/**
* @var \Illuminate\Support\Composer
*/
protected $composer;

/**
* Create a new session table command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\Support\Composer $composer
*/
public function __construct(Filesystem $files, Composer $composer)
{
parent::__construct();

$this->files = $files;
$this->composer = $composer;
}

public function handle()
{
$name = $this->argument('name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class OptionsTableCommand extends Command
protected $files;

/**
* @var \Illuminate\Foundation\Composer
* @var \Illuminate\Support\Composer
*/
protected $composer;

/**
* Create a new session table command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\Foundation\Composer $composer
* @param \Illuminate\Support\Composer $composer
*/
public function __construct(Filesystem $files, Composer $composer)
{
Expand All @@ -57,7 +57,7 @@ public function handle()
{
$fullPath = $this->createBaseMigration();

$this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/options.stub'));
$this->files->put($fullPath, $this->files->get(__DIR__ . '/stubs/options.stub'));

$this->info('Migration created successfully!');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions src/Terranet/Options/Manager.php → src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public function createEloquentOptionsDriver()

public function createDatabaseOptionsDriver()
{
return new DatabaseOptionsDriver(
$this->app['db']->connection(),
'options'
);
$db = $this->container->get('db');
return new DatabaseOptionsDriver($db->connection(), 'options');
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public function boot()
define('_TERRANET_OPTIONS_', 1);
}

$baseDir = realpath(__DIR__ . '/../../../');
$this->publishes(["{$baseDir}/src/routes.php" => app_path('Http/Terranet/Options/routes.php')], 'routes');
$baseDir = realpath(__DIR__ . '/');
$this->publishes(["{$baseDir}/routes.php" => app_path('Http/Terranet/Options/routes.php')], 'routes');

if (! $this->app->routesAreCached()) {
if (file_exists($routes = app_path('Http/Terranet/Options/routes.php'))) {
/** @noinspection PhpIncludeInspection */
require_once $routes;
} else {
/** @noinspection PhpIncludeInspection */
require_once "{$baseDir}/src/routes.php";
require_once "{$baseDir}/routes.php";
}
}
}
Expand Down

0 comments on commit bb94b90

Please sign in to comment.