Commit 554b89cf authored by Nicolas Widart's avatar Nicolas Widart

Add 'Modules/Workshop/' from commit 'becb654d'

git-subtree-dir: Modules/Workshop
git-subtree-mainline: 42db03db
git-subtree-split: becb654d
parents 42db03db becb654d
<?php namespace Modules\Workshop\Composers;
use Modules\Workshop\Manager\ModuleManager;
class MigrateViewComposer
{
/**
* @var ModuleManager
*/
private $module;
public function __construct(ModuleManager $module)
{
$this->module = $module;
}
public function compose($view)
{
$view->modules = $this->module->enabled();
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Composers;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Request;
class SidebarViewComposer
{
public function compose($view)
{
$view->items->put('workbench', Collection::make([
[
'weight' => '1',
'request' => Request::is("*/{$view->prefix}/modules*") or Request::is("*/{$view->prefix}/workbench*"),
'route' => '#',
'icon-class' => 'fa fa-cogs',
'title' => 'Workshop',
],
[
'request' => "*/{$view->prefix}/modules*",
'route' => 'dashboard.modules.index',
'icon-class' => 'fa fa-cog',
'title' => 'Modules',
],
[
'request' => "*/{$view->prefix}/workbench*",
'route' => 'dashboard.workbench.index',
'icon-class' => 'fa fa-terminal',
'title' => 'Workbench',
]
]));
}
}
\ No newline at end of file
<?php
return [
'modules' => [
'index',
'store',
],
'workbench' => [
'index',
'generate',
'migrate',
'install',
'seed',
]
];
\ No newline at end of file
<?php namespace Modules\Workshop\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class WorkshopDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Controllers;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Workshop\Http\Requests\ModulesRequest;
use Modules\Workshop\Manager\ModuleManager;
class ModulesController extends AdminBaseController
{
/**
* @var ModuleManager
*/
private $moduleManager;
public function __construct(ModuleManager $moduleManager)
{
parent::__construct();
$this->moduleManager = $moduleManager;
}
public function index()
{
$modules = $this->moduleManager->all();
$coreModules = $this->moduleManager->getCoreModules();
return View::make('workshop::admin.modules.index', compact('modules', 'coreModules'));
}
public function store(ModulesRequest $request)
{
$enabledModules = $this->moduleManager->getFlippedEnabledModules();
$modules = $request->modules;
foreach ($modules as $module => $value) {
if (isset($enabledModules[$module])) {
unset($enabledModules[$module]);
unset($modules[$module]);
}
}
$this->moduleManager->disableModules($enabledModules);
$this->moduleManager->enableModules($modules);
Flash::success('Modules configuration saved!');
return Redirect::route('dashboard.modules.index');
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Controllers;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Workshop\Http\Requests\GenerateModuleRequest;
use Modules\Workshop\Http\Requests\InstallModuleRequest;
use Modules\Workshop\Http\Requests\MigrateModuleRequest;
use Modules\Workshop\Http\Requests\SeedModuleRequest;
use Symfony\Component\Console\Output\BufferedOutput;
class WorkbenchController extends AdminBaseController
{
public function __construct()
{
parent::__construct();
}
/**
* Show the index view
* @return mixed
*/
public function index()
{
return View::make('workshop::admin.workbench.index');
}
/**
* Generate a module given its name
* @param GenerateModuleRequest $request
* @return mixed
*/
public function generate(GenerateModuleRequest $request)
{
$output = new BufferedOutput;
Artisan::call('module:make', ['name' => $request->name], $output);
Flash::message($output->fetch());
return Redirect::route('dashboard.workbench.index');
}
/**
* Run the migration for the given module
* @param MigrateModuleRequest $request
* @return mixed
*/
public function migrate(MigrateModuleRequest $request)
{
$output = new BufferedOutput;
Artisan::call('module:migrate', ['module' => $request->module], $output);
Flash::message($output->fetch());
return Redirect::route('dashboard.workbench.index');
}
/**
* Run the install command for the given vendor/module
* @param InstallModuleRequest $request
* @return mixed
*/
public function install(InstallModuleRequest $request)
{
$output = new BufferedOutput;
$arguments['name'] = $request->vendorName;
if ($request->subtree) {
$arguments['--tree'] = '';
}
Artisan::call('module:install', $arguments, $output);
Flash::message($output->fetch());
return Redirect::route('dashboard.workbench.index');
}
/**
* Run the seed command for the given module
* @param SeedModuleRequest $request
* @return mixed
*/
public function seed(SeedModuleRequest $request)
{
$output = new BufferedOutput;
Artisan::call('module:seed', ['module' => $request->module], $output);
Flash::message($output->fetch());
return Redirect::route('dashboard.workbench.index');
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class GenerateModuleRequest extends FormRequest
{
public function rules()
{
return [
'name' => 'required'
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class InstallModuleRequest extends FormRequest
{
public function rules()
{
return [
'vendorName' => 'required'
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MigrateModuleRequest extends FormRequest
{
public function rules()
{
return [
'module' => 'required'
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ModulesRequest extends FormRequest
{
public function rules()
{
return [];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class SeedModuleRequest extends FormRequest
{
public function rules()
{
return [
'module' => 'required'
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
<?php
Route::group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin|permissions'], function()
{
Route::group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Workshop\Http\Controllers'],
function () {
Route::get('modules', ['as' => 'dashboard.modules.index', 'uses' => 'ModulesController@index']);
Route::post('modules', ['as' => 'dashboard.modules.store', 'uses' => 'ModulesController@store']);
# Workbench
Route::get('workbench', ['as' => 'dashboard.workbench.index', 'uses' => 'WorkbenchController@index']);
Route::post('generate', ['as' => 'dashboard.workbench.generate.index', 'uses' => 'WorkbenchController@generate']);
Route::post('migrate', ['as' => 'dashboard.workbench.migrate.index', 'uses' => 'WorkbenchController@migrate']);
Route::post('install', ['as' => 'dashboard.workbench.install.index', 'uses' => 'WorkbenchController@install']);
Route::post('seed', ['as' => 'dashboard.workbench.seed.index', 'uses' => 'WorkbenchController@seed']);
}
);
});
<?php namespace Modules\Workshop\Manager;
use Illuminate\Config\Repository as Config;
use Pingpong\Modules\Module;
class ModuleManager
{
/**
* @var Module
*/
private $module;
/**
* @var Config
*/
private $config;
/**
* @param Module $module
* @param Config $config
*/
public function __construct(Module $module, Config $config)
{
$this->module = $module;
$this->config = $config;
}
/**
* Return all modules
* @return array
*/
public function all()
{
return $this->module->all();
}
/**
* Return all the enabled modules
* @return array
*/
public function enabled()
{
return $this->module->enabled();
}
/**
* Get the core modules that shouldn't be disabled
* @return array|mixed
*/
public function getCoreModules()
{
$coreModules = $this->config->get('core::config.CoreModules');
$coreModules = array_flip($coreModules);
return $coreModules;
}
/**
* Get the enabled modules, with the module name as the key
* @return array
*/
public function getFlippedEnabledModules()
{
$enabledModules = $this->module->enabled();
$enabledModules = array_flip($enabledModules);
return $enabledModules;
}
/**
* Disable the given modules
* @param $enabledModules
*/
public function disableModules($enabledModules)
{
$coreModules = $this->getCoreModules();
foreach ($enabledModules as $moduleToDisable => $value) {
if (isset($coreModules[$moduleToDisable])) {
continue;
}
$this->module->disable($moduleToDisable);
}
}
/**
* Enable the given modules
* @param $modules
*/
public function enableModules($modules)
{
foreach ($modules as $moduleToEnable => $value) {
$this->module->enable($moduleToEnable);
}
}
}
\ No newline at end of file
<?php namespace Modules\Workshop\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
class WorkshopServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* The filters base class name.
*
* @var array
*/
protected $filters = [
'Core' => [
'permissions' => 'PermissionFilter'
]
];
/**
* Register the filters.
*
* @param Router $router
* @return void
*/
public function registerFilters(Router $router)
{
foreach ($this->filters as $module => $filters) {
foreach ($filters as $name => $filter) {
$class = "Modules\\{$module}\\Http\\Filters\\{$filter}";
$router->filter($name, $class);
}
}
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->booted(function ($app) {
$this->registerFilters($app['router']);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array();
}
}
<?php
return [
'title' => 'Module Management',
'breadcrumb' => [
'modules' => 'Modules'
],
'tab' => [
'module list' => 'Module list'
],
'button' => [
'save module configuration' => 'Save module configuration'
]
];
<?php
return [
'title' => 'Module helpers',
'subtitle' => [
'generate new module' => 'Generate a new module',
'install new module by vendor name' => 'Install a module by vendor/name',
],
'tab' => [
'generators' => 'Generators',
'migrations' => 'Migrations',
'seeds' => 'Seeds',
],
'form' => [
'module name' => 'Module name',
'vendor name of the module' => 'Vendor/name of the module',
'install as subtree' => 'Install as a subtree?',
],
'button' => [
'generate new module' => 'Generate new module',
'install new module' => 'Install new module',
'migrate' => 'Migrate',
'seed' => 'Seed',
]
];
<?php
return [
'title' => 'Gérer les modules',
'breadcrumb' => [
'modules' => 'Modules'
],
'tab' => [
'module list' => 'Liste de modules'
],
'button' => [
'save module configuration' => 'Sauvez la configuration de modules'
]
];
<?php
return [
'title' => 'Aide au modules',
'subtitle' => [
'generate new module' => 'Générer un nouveau module',
'install new module by vendor name' => 'Installer un nouveau module par son vendor/name',
],
'tab' => [
'generators' => 'Generators',
'migrations' => 'Migrations',
'seeds' => 'Seeds',
],
'form' => [
'module name' => 'Nom du module',
'vendor name of the module' => 'Vendor/name du module',
'install as subtree' => 'Installer en tant que subtree?',
],
'button' => [
'generate new module' => 'Generer le module',
'install new module' => 'Installer le module',
'migrate' => 'Migrer',
'seed' => 'Seed',
]
];
@extends('core::layouts.master')
@section('content-header')
<h1>
{{ trans('workshop::modules.title') }}
</h1>
<ol class="breadcrumb">
<li><a href="{{ URL::route('dashboard.index') }}"><i class="fa fa-dashboard"></i> {{ trans('user::users.breadcrumb.home') }}</a></li>
<li class="active">{{ trans('workshop::modules.breadcrumb.modules') }}</li>
</ol>
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
{!! Form::open(['route' => 'dashboard.modules.store', 'method' => 'post']) !!}
<div class="row">
<div class="col-md-12">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab_1-1" data-toggle="tab">{{ trans('workshop::modules.tab.module list') }}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_1-1">
@include('flash::message')
<ul>
@foreach($modules as $module)
<li>
<div class="checkbox">
<label for="{{ $module }}">
<input id="{{ $module }}" name="modules[{{ $module }}]" type="checkbox" class="flat-blue" <?php echo Module::active($module) ? 'checked' : '' ?> <?php echo isset($coreModules[$module]) ? 'disabled' : ''; ?> value="true" /> {{ $module }}
</label>
</div>
</li>
@endforeach
</ul>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('workshop::modules.button.save module configuration') }}</button>
</div>
</div>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
@stop
@section('scripts')
<script>
$( document ).ready(function() {
$('input[type="checkbox"].flat-blue, input[type="radio"].flat-blue').iCheck({
checkboxClass: 'icheckbox_flat-blue',
radioClass: 'iradio_flat-blue'
});
});
</script>
@stop
\ No newline at end of file
@extends('core::layouts.master')
@section('content-header')
<h1>
{{ trans('workshop::workbench.title') }}
</h1>
<ol class="breadcrumb">
<li><a href="{{ URL::route('dashboard.index') }}"><i class="fa fa-dashboard"></i> {{ trans('user::users.breadcrumb.home') }}</a></li>
<li class="active">{{ trans('workshop::workbench.title') }}</li>
</ol>
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
<div class="row">
<div class="col-md-12">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab_1-1" data-toggle="tab">{{ trans('workshop::workbench.tab.generators') }}</a></li>
<li><a href="#tab_2-2" data-toggle="tab">{{ trans('workshop::workbench.tab.migrations') }}</a></li>
<li><a href="#tab_3-3" data-toggle="tab">{{ trans('workshop::workbench.tab.seeds') }}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_1-1">
@include('workshop::admin.workbench.tabs.generate')
</div>
<div class="tab-pane" id="tab_2-2">
@include('workshop::admin.workbench.tabs.migrate')
</div>
<div class="tab-pane" id="tab_3-3">
@include('workshop::admin.workbench.tabs.seed')
</div>
</div>
</div>
</div>
</div>
@stop
@section('scripts')
<script>
$( document ).ready(function() {
$('input[type="checkbox"].flat-blue, input[type="radio"].flat-blue').iCheck({
checkboxClass: 'icheckbox_flat-blue',
radioClass: 'iradio_flat-blue'
});
});
</script>
@stop
\ No newline at end of file
@include('flash::message')
<div class="row">
<div class="col-md-6">
{!! Form::open(['route' => 'dashboard.workbench.generate.index', 'method' => 'post']) !!}
<div class="box-body">
<h4>{{ trans('workshop::workbench.subtitle.generate new module') }}</h4>
<div class='form-group{{ $errors->has('name') ? ' has-error' : '' }}'>
{!! Form::label('name', trans('workshop::workbench.form.module name')) !!}
{!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => trans('workshop::workbench.form.module name')]) !!}
{!! $errors->first('name', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('workshop::workbench.button.generate new module') }}</button>
</div>
{!! Form::close() !!}
</div>
<div class="col-md-6">
{!! Form::open(['route' => 'dashboard.workbench.install.index', 'method' => 'post']) !!}
<div class="box-body">
<h4>{{ trans('workshop::workbench.subtitle.install new module by vendor name') }}</h4>
<div class='form-group{{ $errors->has('vendorName') ? ' has-error' : '' }}'>
{!! Form::label('vendorName', trans('workshop::workbench.form.vendor name of the module')) !!}
{!! Form::text('vendorName', Input::old('vendorName'), ['class' => 'form-control', 'placeholder' => trans('workshop::workbench.form.vendor name of the module')]) !!}
{!! $errors->first('vendorName', '<span class="help-block">:message</span>') !!}
</div>
<div class="checkbox">
<label for="subtree">
<input id="subtree" name="subtree" type="checkbox" class="flat-blue" value="true" /> {{ trans('workshop::workbench.form.install as subtree') }}
</label>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('workshop::workbench.button.install new module') }}</button>
</div>
{!! Form::close() !!}
</div>
</div>
\ No newline at end of file
@include('flash::message')
{!! Form::open(['route' => 'dashboard.workbench.migrate.index', 'method' => 'post']) !!}
<div class="box-body">
<div class='form-group{{ $errors->has('module') ? ' has-error' : '' }}'>
{!! Form::label('module', trans('workshop::workbench.form.module name')) !!}
{!! Form::select('module', $modules, null, ['class' => 'form-control']) !!}
{!! $errors->first('module', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('workshop::workbench.button.migrate') }}</button>
</div>
{!! Form::close() !!}
\ No newline at end of file
@include('flash::message')
{!! Form::open(['route' => 'dashboard.workbench.seed.index', 'method' => 'post']) !!}
<div class="box-body">
<div class='form-group{{ $errors->has('module') ? ' has-error' : '' }}'>
{!! Form::label('module', trans('workshop::workbench.form.module name')) !!}
{!! Form::select('module', $modules, null, ['class' => 'form-control']) !!}
{!! $errors->first('module', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('workshop::workbench.button.seed') }}</button>
</div>
{!! Form::close() !!}
\ No newline at end of file
<?php
View::composer('core::partials.sidebar-nav', 'Modules\Workshop\Composers\SidebarViewComposer');
View::composer([
'workshop::admin.workbench.tabs.migrate',
'workshop::admin.workbench.tabs.seed',
], 'Modules\Workshop\Composers\MigrateViewComposer');
{
"name": "Workshop",
"alias": "workshop",
"description": "",
"keywords": [
],
"active": 1,
"providers": [
"Modules\\Workshop\\Providers\\WorkshopServiceProvider"
]
}
\ No newline at end of file
<?php
/*
|--------------------------------------------------------------------------
| Register The Module Namespaces
|--------------------------------------------------------------------------
|
| Here is you can register the namespace for this module.
| You may to edit this namespace if you want.
|
*/
View::addNamespace('workshop', __DIR__ . '/Resources/views/');
Lang::addNamespace('workshop', __DIR__ . '/Resources/lang/');
Config::addNamespace('workshop', __DIR__ . '/Config/');
/*
|--------------------------------------------------------------------------
| Require The Routes file.
|--------------------------------------------------------------------------
|
| Next, this module will load filters and routes file.
|
*/
require __DIR__ . '/Http/routes.php';
require __DIR__ . '/composers.php';
\ No newline at end of file
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