Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agus #271

Open
wants to merge 60 commits into
base: 2.0
Choose a base branch
from
Open

agus #271

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
e386eec
use develop version
Jun 4, 2015
ed8291d
remove branch aliases
Jun 4, 2015
2e0a925
merge branch 2.0 into 2.1
Jun 5, 2015
461f987
merge branch 2.0 into 2.1
Jun 5, 2015
848b7f3
Merge branch '2.0' into 2.1
Jun 9, 2015
9b37d34
Merge branch '2.0' into 2.1
Jun 14, 2015
377676e
upgrade to laravel 5.1
Jun 14, 2015
9eceef2
change custom exception class with global exception class. ref: #177
Jun 18, 2015
5574489
Merge branch '2.0' into 2.1
Jun 22, 2015
c6edbfa
Merge commit '8cd17285caa166b9c54120bbb0298abde8433f66' into 2.1
Jun 22, 2015
b46f7a5
remove FileMissingException class
Jun 27, 2015
afcf6d3
require stable version
Jun 27, 2015
00c8d86
update module's view path
Jun 30, 2015
0649359
Bugfix: When installing a package via git, the process Installer chec…
Jul 23, 2015
f6dc01f
Added publishing group tag for config file
syahzul Aug 17, 2015
b4ed681
Merge pull request #198 from syahzul/syahzul-config-tag
gravitano Aug 17, 2015
4b74850
fixed missing stub replacements
noxify Aug 20, 2015
f5a3233
Merge pull request #201 from Pseudoagentur/master
gravitano Aug 20, 2015
8218796
Updated stub to use all the paths of view finder
blackakula Sep 9, 2015
fbb16d2
Fixed view paths to be get from config
blackakula Sep 10, 2015
a90f915
fix command module:migrate-rollback to run modules in reverse order
Oct 23, 2015
8b2a9a8
Merge pull request #218 from RossTsachev/fix_migrate-rollback_command
gravitano Oct 24, 2015
e990804
Order boot provider, supports the lang module
prhost Oct 27, 2015
941f6c8
Merge pull request #220 from prhost/patch-1
gravitano Oct 27, 2015
0c5ca60
Added --all option to module:seed
Nov 4, 2015
0cd4986
Fix the module without seed class issue
Nov 4, 2015
58df48a
Remove -all option and remove user module option
Nov 4, 2015
bc232d7
Merge pull request #222 from briba/master
gravitano Nov 6, 2015
4c78c47
Merge branch 'master' into 2.1
Nov 6, 2015
cc2b4bd
CS fixes
Nov 6, 2015
1597689
Fix namespace path of Controller
f0ntana Nov 16, 2015
02672d7
Merge pull request #226 from f0ntana/fix-namespace
gravitano Nov 18, 2015
396d5e9
Fix caching problem.
Nov 23, 2015
22d1bc6
Fix getting dependencies from composer.json file with module:update c…
Nov 30, 2015
2661e74
Merge pull request #227 from mahmutbayri/2.1
gravitano Dec 7, 2015
073f43f
reverse array
Dec 23, 2015
5cfe969
Merge pull request #210 from blackakula/patch-1
gravitano Dec 23, 2015
020b5b8
Merge pull request #191 from mtisi/master
gravitano Dec 23, 2015
f10f5ad
Merge branch 'master' of github.com:pingpong-labs/modules
Dec 23, 2015
8895b24
upgrade requirements for support laravel 5.2
Dec 23, 2015
fbed30d
Fixing deprecated method bindShared
moston Dec 23, 2015
6c40173
Merge pull request #234 from moston/2.2
gravitano Jan 4, 2016
575d9f6
use stable version
Jan 6, 2016
dd814a1
Fix for php artisan module:seed command
sonus Jan 8, 2016
05186d8
update base controller class
Jan 11, 2016
6668489
fix view name
Jan 11, 2016
c3836e2
add web middleware
Jan 11, 2016
002f20e
Merge pull request #238 from sonus/patch-1
gravitano Jan 11, 2016
6c2f018
fix module name
Jan 11, 2016
c9901ba
allow to install module from github via https
Jan 11, 2016
cefe62e
fix wrong paths in service provider
Jan 29, 2016
8ee9dfc
Merge pull request #242 from ptcong/fix-wrong-res-paths-in-service
gravitano Jan 29, 2016
f9e515a
Update index.stub
Jastkast May 16, 2016
b746e2e
Merge pull request #256 from Jastkast/patch-1
gravitano May 18, 2016
0622ad7
Allow caching of the json file
nWidart Jun 22, 2016
7d9d6da
Merge branch '2.2'
Aug 30, 2016
a7d1646
upgrade to laravel 5.3
Aug 30, 2016
ad25066
update readme
Sep 8, 2016
6df3f24
Merge pull request #264 from nWidart/2.2
gravitano Sep 8, 2016
1f7d78c
Merge branch '2.2'
Sep 8, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Commands/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/controller.stub', [
'MODULENAME' => $module->getStudlyName(),
'CONTROLLERNAME' => $this->getControllerName(),
'CLASS' => $this->getClass(),
'NAMESPACE' => $module->getLowername(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
'MODULENAME' => $module->getStudlyName(),
'CONTROLLERNAME' => $this->getControllerName(),
'NAMESPACE' => $module->getStudlyName(),
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getModuleName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
9 changes: 7 additions & 2 deletions Commands/GenerateFilterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/filter.stub', [
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $this->getFileName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
13 changes: 10 additions & 3 deletions Commands/GenerateProviderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/'.$stub.'.stub', [
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'PATH_VIEWS' => $this->laravel['config']->get('modules.paths.generator.views'),
'PATH_LANG' => $this->laravel['config']->get('modules.paths.generator.lang'),
'PATH_CONFIG' => $this->laravel['config']->get('modules.paths.generator.config')
]))->render();
}

Expand Down
12 changes: 9 additions & 3 deletions Commands/GenerateRouteProviderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ protected function getArguments()
*/
protected function getTemplateContents()
{
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/route-provider.stub', [
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
12 changes: 7 additions & 5 deletions Commands/MakeRequestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/request.stub', [
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
2 changes: 1 addition & 1 deletion Commands/MigrateResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function fire()
return;
}

foreach ($this->laravel['modules']->all() as $module) {
foreach (array_reverse($this->laravel['modules']->all()) as $module) {
$this->line('Running for module: <info>'.$module->getName().'</info>');

$this->reset($module);
Expand Down
2 changes: 1 addition & 1 deletion Commands/MigrateRollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function fire()
return;
}

foreach ($this->laravel['modules']->all() as $module) {
foreach (array_reverse($this->laravel['modules']->all()) as $module) {
$this->line('Running for module: <info>'.$module->getName().'</info>');

$this->rollback($module);
Expand Down
3 changes: 1 addition & 2 deletions Commands/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pingpong\Modules\Commands;

use Illuminate\Support\Str;
use Pingpong\Generators\Exceptions\InvalidMigrationNameException;
use Pingpong\Generators\Migrations\NameParser;
use Pingpong\Generators\Migrations\SchemaParser;
use Pingpong\Support\Stub;
Expand Down Expand Up @@ -102,7 +101,7 @@ protected function getTemplateContents()
]);
}

throw new InvalidMigrationNameException();
throw new \InvalidArgumentException('Invalid migration name');
}

/**
Expand Down
14 changes: 8 additions & 6 deletions Commands/ModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/model.stub', [
'MODULE' => $this->getModuleName(),
'NAME' => $this->getModelName(),
'FILLABLE' => $this->getFillable(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAME' => $this->getModelName(),
'FILLABLE' => $this->getFillable(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
30 changes: 21 additions & 9 deletions Commands/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,31 @@ public function fire()
{
$this->module = $this->laravel['modules'];

$module = Str::studly($this->argument('module')) ?: $this->getModuleName();
$name = $this->argument('module');

if ($module) {
if ($this->module->has($module)) {
$this->dbseed($module);

return $this->info("Module [$module] seeded.");
if ($name) {
if (!$this->module->has(Str::studly($name))) {
return $this->error("Module [$name] does not exists.");
}

return $this->error("Module [$module] does not exists.");
$class = $this->getSeederName($name);
if (class_exists($class)) {
$this->dbseed($name);

return $this->info("Module [$name] seeded.");
} else {
return $this->error("Class [$class] does not exists.");
}
}

foreach ($this->module->all() as $name) {
$this->dbseed($name);
foreach ($this->module->getOrdered() as $module) {
$name = $module->getName();

if (class_exists($this->getSeederName($name))) {
$this->dbseed($name);

$this->info("Module [$name] seeded.");
}
}

return $this->info('All modules seeded.');
Expand Down Expand Up @@ -111,6 +122,7 @@ protected function getOptions()
{
return array(
array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', null),
array('all', null, InputOption::VALUE_NONE, 'Whether or not we should seed all modules.'),
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'),
);
}
Expand Down
1 change: 1 addition & 0 deletions Commands/SeedMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected function getTemplateContents()
'NAME' => $this->getSeederName(),
'MODULE' => $this->getModuleName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),

]))->render();
}

Expand Down
2 changes: 1 addition & 1 deletion Commands/stubs/controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class $CLASS$ extends Controller {

public function index()
{
return view('$NAMESPACE$::index');
return view('$LOWER_NAME$::index');
}

}
2 changes: 1 addition & 1 deletion Commands/stubs/routes.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

Route::group(['prefix' => '$LOWER_NAME$', 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'], function()
Route::group(['middleware' => 'web', 'prefix' => '$LOWER_NAME$', 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'], function()
{
Route::get('/', '$STUDLY_NAME$Controller@index');
});
26 changes: 14 additions & 12 deletions Commands/stubs/scaffold/provider.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class $CLASS$ extends ServiceProvider {

/**
* Boot the application events.
*
*
* @return void
*/
public function boot()
{
$this->registerConfig();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
}

Expand All @@ -29,46 +29,48 @@ class $CLASS$ extends ServiceProvider {
* @return void
*/
public function register()
{
{
//
}

/**
* Register config.
*
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/../Config/config.php' => config_path('$LOWER_NAME$.php'),
__DIR__.'/../$PATH_CONFIG$/config.php' => config_path('$LOWER_NAME$.php'),
]);
$this->mergeConfigFrom(
__DIR__.'/../Config/config.php', '$LOWER_NAME$'
__DIR__.'/../$PATH_CONFIG$/config.php', '$LOWER_NAME$'
);
}

/**
* Register views.
*
*
* @return void
*/
public function registerViews()
{
$viewPath = base_path('views/modules/$LOWER_NAME$');
$viewPath = base_path('resources/views/modules/$LOWER_NAME$');

$sourcePath = __DIR__.'/../Resources/views';
$sourcePath = __DIR__.'/../$PATH_VIEWS$';

$this->publishes([
$sourcePath => $viewPath
]);

$this->loadViewsFrom([$viewPath, $sourcePath], '$LOWER_NAME$');
$this->loadViewsFrom(array_merge(array_map(function ($path) {
return $path . '/modules/$LOWER_NAME$';
}, \Config::get('view.paths')), [$sourcePath]), '$LOWER_NAME$');
}

/**
* Register translations.
*
*
* @return void
*/
public function registerTranslations()
Expand All @@ -78,7 +80,7 @@ class $CLASS$ extends ServiceProvider {
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, '$LOWER_NAME$');
} else {
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', '$LOWER_NAME$');
$this->loadTranslationsFrom(__DIR__ .'/../$PATH_LANG$', '$LOWER_NAME$');
}
}

Expand Down
2 changes: 1 addition & 1 deletion Commands/stubs/views/index.stub
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
This view is loaded from module: {!! config('$LOWER_NAME$.name') !!}
</p>

@stop
@endsection
7 changes: 0 additions & 7 deletions Exceptions/FileMissingException.php

This file was deleted.

8 changes: 7 additions & 1 deletion Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ public function getContents()
*/
public function getAttributes()
{
return json_decode($this->getContents(), 1);
if (config('modules.cache.enabled') === false) {
return json_decode($this->getContents(), 1);
}

return app('cache')->remember($this->getPath(), config('modules.cache.lifetime'), function () {
return json_decode($this->getContents(), 1);
});
}

/**
Expand Down
21 changes: 19 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,13 @@ protected function registerTranslation()
*
* @return Json
*/
public function json()
public function json($file = null)
{
return new Json($this->getPath().'/module.json', $this->app['files']);
if (is_null($file)) {
$file = 'module.json';
}

return new Json($this->getPath() . '/' . $file, $this->app['files']);
}

/**
Expand All @@ -187,6 +191,19 @@ public function get($key, $default = null)
return $this->json()->get($key, $default);
}

/**
* Get a specific data from composer.json file by given the key.
*
* @param $key
* @param null $default
*
* @return mixed
*/
public function getComposerAttr($key, $default = null)
{
return $this->json('composer.json')->get($key, $default);
}

/**
* Register the module.
*/
Expand Down
6 changes: 4 additions & 2 deletions ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ protected function registerNamespaces()
{
$configPath = __DIR__.'/src/config/config.php';
$this->mergeConfigFrom($configPath, 'modules');
$this->publishes([$configPath => config_path('modules.php')]);
$this->publishes([
$configPath => config_path('modules.php')
], 'config');
}

/**
Expand All @@ -88,7 +90,7 @@ protected function registerHtml()
*/
protected function registerServices()
{
$this->app->bindShared('modules', function ($app) {
$this->app->singleton('modules', function ($app) {
$path = $app['config']->get('modules.paths.modules');

return new Repository($app, $path);
Expand Down
Loading