Skip to content

Commit

Permalink
Adjusting namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
lagbox committed Aug 31, 2016
1 parent f7f6520 commit cc345cc
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 33 deletions.
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lagbox/settings",
"name": "lagbox/laravel-settings",
"description": "Laravel persistent settings",
"license": "MIT",
"keywords": ["laravel", "settings"],
Expand All @@ -11,16 +11,18 @@
],
"require": {
"php": ">=5.6",
"illuminate/support": "5.2.*",
"illuminate/cache": "5.2.*",
"illuminate/events": "5.2.*"
"illuminate/contracts": "5.1.*|5.2.*|5.3.*",
"illuminate/support": "5.1.*|5.2.*|5.3.*",
"illuminate/cache": "5.1.*|5.2.*|5.3.*",
"illuminate/events": "5.1.*|5.2.*|5.3.*",
"illuminate/database": "5.1.*|5.2.*|5.3.*"
},
"require-dev": {
"phpunit/phpunit": "4.0.*"
},
"autoload": {
"psr-4": {
"lagbox\\settings\\": "src"
"lagbox\\Settings\\": "src"
},
"files": [
"src/helpers.php"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Events/SettingsSaved.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace lagbox\settings\Events;
namespace lagbox\Settings\Events;

class SettingsSaved
{
Expand Down
18 changes: 18 additions & 0 deletions src/Facades/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace lagbox\Settings\Facades;

use Illuminate\Support\Facades\Facade;

class Settings extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'settings';
}
}
6 changes: 3 additions & 3 deletions src/Listeners/SettingsListener.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace lagbox\settings\Listeners;
namespace lagbox\Settings\Listeners;

use lagbox\settings\Setting;
use lagbox\settings\Events\SettingsSaved;
use lagbox\Settings\Setting;
use lagbox\Settings\Events\SettingsSaved;
use Illuminate\Contracts\Cache\Repository as Cache;

class SettingsListener
Expand Down
2 changes: 1 addition & 1 deletion src/Setting.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace lagbox\settings;
namespace lagbox\Settings;

use Illuminate\Database\Eloquent\Model;

Expand Down
10 changes: 5 additions & 5 deletions src/Settings.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace lagbox\settings;
namespace lagbox\Settings;

use lagbox\settings\Setting;
use lagbox\settings\Events\SettingsSaved;
use lagbox\Settings\Setting;
use lagbox\Settings\Events\SettingsSaved;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Events\Dispatcher as Event;
use Illuminate\Contracts\Config\Repository as Config;
Expand All @@ -30,7 +30,7 @@ class Settings

/**
* Setting model
* @var \lagbox\settings\Setting
* @var \lagbox\Settings\Setting
*/
protected $setting;

Expand Down Expand Up @@ -64,7 +64,7 @@ class Settings
* @param \Illuminate\Contracts\Cache\Repository $cache
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Events\Dispatcher $event
* @param \lagbox\settings\Setting $setting
* @param \lagbox\Settings\Setting $setting
*/
public function __construct(Cache $cache, Config $config, Event $event, Setting $setting)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SettingsMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace lagbox\settings;
namespace lagbox\Settings;

use Closure;

Expand Down
21 changes: 18 additions & 3 deletions src/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?php

namespace lagbox\settings;
namespace lagbox\Settings;

use Illuminate\Support\ServiceProvider;
use lagbox\settings\Events\SettingsSaved;
use lagbox\settings\Listeners\SettingsListener;
use lagbox\Settings\Events\SettingsSaved;
use lagbox\Settings\Listeners\SettingsListener;

class SettingsServiceProvider extends ServiceProvider
{
/**
* Bootstrap anything needed.
*
* @return void
*/
public function boot()
{
$this->publishes();
Expand All @@ -19,6 +24,11 @@ public function boot()
$this->app['events']->listen(SettingsSaved::class, SettingsListener::class);
}

/**
* Register any bindings with the container.
*
* @return void
*/
public function register()
{
$this->app->singleton('settings', function ($app) {
Expand All @@ -33,6 +43,11 @@ public function register()
$this->app->alias('settings', Settings::class);
}

/**
* Assets to publish.
*
* @return void
*/
protected function publishes()
{
$this->publishes([
Expand Down
26 changes: 14 additions & 12 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/**
* Helper method for getting and setting settings
*
* @return mixed
*/
function settings(...$args)
{
$settings = Illuminate\Support\Facades\App::make('settings');
if (! function_exists('settings')) {
/**
* Helper method for getting and setting settings
*
* @return mixed
*/
function settings(...$args)
{
$settings = Illuminate\Support\Facades\App::make('settings');

if (empty($args)) {
return $settings;
}
if (empty($args)) {
return $settings;
}

return $settings(...$args);
return $settings(...$args);
}
}
4 changes: 2 additions & 2 deletions src/tests/SettingsTest.php → tests/SettingsTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace lagbox\settings\tests;
namespace lagbox\Settings\tests;

use Tests\TestCase;
use Illuminate\Support\Arr;
use lagbox\settings\Setting;
use lagbox\Settings\Setting;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

Expand Down

0 comments on commit cc345cc

Please sign in to comment.