Commit 499751b0 authored by Nicolas Widart's avatar Nicolas Widart

Squashed 'Modules/Setting/' changes from 0f32e1e..20d1cdb

20d1cdb Fixing setting button
efdb7b1 Adding code climate badge
d92e54b Removing unused commented code
48ffe70 Typehinting the router
eca1944 Adding sensiolab config file
abf120c Using new escaping tags
8625dd4 Remove flash msg partial
9837f5c Adding travis config
5851df9 Caching the settings getter
0f5bd46 Removing duplication
417c966 Sending the fieldname

git-subtree-dir: Modules/Setting
git-subtree-split: 20d1cdb3d658f785e17d51836fc26757c4078b32
parent 3d625a2e
rules:
php.interface_has_no_interface_suffix:
enabled: false
language: php
php:
- 5.6
- 5.5
- 5.4
- hhvm
......@@ -3,7 +3,8 @@
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class SettingDatabaseSeeder extends Seeder {
class SettingDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
......@@ -13,8 +14,6 @@ class SettingDatabaseSeeder extends Seeder {
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}
<?php
$router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin'], function($router) {
$router->group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Setting\Http\Controllers'], function($router)
use Illuminate\Routing\Router;
$router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin'], function(Router $router) {
$router->group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Setting\Http\Controllers'], function(Router $router)
{
$router->get('settings/{module}', ['as' => 'dashboard.module.settings', 'uses' => 'Admin\SettingController@getModuleSettings']);
$router->resource('settings', 'Admin\SettingController', ['except' => ['show', 'edit', 'update', 'destroy', 'create'], 'names' => [
......
......@@ -28,7 +28,7 @@ class SettingServiceProvider extends ServiceProvider {
$this->app['setting.settings'] = $this->app->share(function($app)
{
return new Settings($app['Modules\Setting\Repositories\SettingRepository']);
return new Settings($app['Modules\Setting\Repositories\SettingRepository'], $app['cache']);
});
$this->app->booting(function()
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox">
<label for="{{ $settingName }}">
<input id="{{ $settingName }}"
name="{{ $settingName }}"
type="checkbox"
class="flat-blue"
{{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->value == true ? 'checked' : '' }}
{{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->plainValue == true ? 'checked' : '' }}
value="1" />
{{ $moduleInfo['description'] }}
</label>
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName, $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
{!! Form::input('number', $settingName, Input::old($settingName, $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
{!! Form::input('number', $settingName, Input::old($settingName, $dbSettings[$settingName]->plainValue), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?>
{!! Form::input('number', $settingName, Input::old($settingName), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?>
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox">
<?php foreach($moduleInfo['options'] as $value => $optionName): ?>
<label for="{{ $optionName }}">
......@@ -6,7 +5,7 @@
name="{{ $settingName }}"
type="radio"
class="flat-blue"
{{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->value == $value ? 'checked' : '' }}
{{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->plainValue == $value ? 'checked' : '' }}
value="{{ $value }}" />
{{ $optionName }}
</label>
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName, $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName", $moduleInfo['description']) !!}
{!! Form::label($settingName, $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
{!! Form::textarea($settingName", Input::old($settingName", $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
{!! Form::textarea($settingName, Input::old($settingName, $dbSettings[$settingName]->plainValue), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?>
{!! Form::textarea($settingName", Input::old($settingName"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
{!! Form::textarea($settingName, Input::old($settingName), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?>
</div>
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox">
<label for="{{ $settingName . "[$lang]" }}">
<input id="{{ $settingName . "[$lang]" }}"
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox">
<?php foreach($moduleInfo['options'] as $value => $optionName): ?>
<label for="{{ $optionName . "[$lang]" }}">
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
......
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
......
......@@ -12,11 +12,10 @@
@stop
@section('styles')
<link href="{{{ Module::asset('core', 'css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
<link href="{!! Module::asset('core', 'css/vendor/iCheck/flat/blue.css') !!}" rel="stylesheet" type="text/css" />
@stop
@section('content')
@include('flash::message')
{!! Form::open(['route' => ['dashboard.setting.store'], 'method' => 'post']) !!}
<div class="row">
<div class="sidebar-nav col-sm-2">
......@@ -83,7 +82,7 @@
</div>
<?php endif; ?>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('core::core.button.create') }}</button>
<button type="submit" class="btn btn-primary btn-flat">{{ trans('core::core.button.update') }}</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.setting.index')}}"><i class="fa fa-times"></i> {{ trans('core::core.button.cancel') }}</a>
</div>
</div>
......
......@@ -6,5 +6,6 @@
'settings' => $settings,
'setting' => $settingName,
'moduleInfo' => $moduleInfo,
'settingName' => strtolower($currentModule) . '::' . $settingName
])
<?php endforeach;
<?php namespace Modules\Setting\Support;
use Illuminate\Contracts\Cache\Repository;
use Modules\Core\Contracts\Setting;
use Modules\Setting\Repositories\SettingRepository;
......@@ -9,13 +10,19 @@ class Settings implements Setting
* @var SettingRepository
*/
private $setting;
/**
* @var Repository
*/
private $cache;
/**
* @param SettingRepository $setting
* @param Repository $cache
*/
public function __construct(SettingRepository $setting)
public function __construct(SettingRepository $setting, Repository $cache)
{
$this->setting = $setting;
$this->cache = $cache;
}
/**
......@@ -27,7 +34,11 @@ class Settings implements Setting
*/
public function get($name, $locale = null, $default = null)
{
if (!$this->cache->has("setting.$name")) {
$setting = $this->setting->get($name);
$this->cache->put("setting.$name", $setting, '3600');
}
$setting = $this->cache->get("setting.$name");
if ($setting) {
if ($setting->isTranslatable) {
......
......@@ -2,3 +2,4 @@
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/92d544b4-a3ca-4c2a-9ffd-0741c521cb14/mini.png)](https://insight.sensiolabs.com/projects/92d544b4-a3ca-4c2a-9ffd-0741c521cb14)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nWidart-Modules/Setting/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nWidart-Modules/Setting/?branch=master)
[![Code Climate](https://codeclimate.com/github/nWidart-Modules/Setting/badges/gpa.svg)](https://codeclimate.com/github/nWidart-Modules/Setting)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment