forked from area17/twill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c8cc69
commit 52aa2a0
Showing
14 changed files
with
741 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
### General | ||
trailingComma: all | ||
printWidth: 80 | ||
tabWidth: 4 | ||
useTabs: false | ||
singleQuote: true | ||
trailingCommaPHP: php5 | ||
braceStyle: psr-2 | ||
requirePragma: false | ||
insertPragma: false | ||
semi: false | ||
|
||
### PHP | ||
trailingCommaPHP: true | ||
braceStyle: psr-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
return [ | ||
'path' => app_path('Twill/Capsules'), | ||
|
||
'list' => [ | ||
// ['name' => 'Posts', 'enabled' => true], | ||
], | ||
]; | ||
|
||
/// To fully override this config: | ||
/// | ||
//[ | ||
// 'modules' => [ | ||
// 'path' => app_path('Twill/Modules'), | ||
// | ||
// 'loaded' = true, | ||
// | ||
// 'list' => [ | ||
// [ | ||
// "name" => "Post", | ||
// "enabled" => true, | ||
// "psr4_path" => "/app-path/app/Twill/Modules/Post/app", | ||
// "namespace" => "App\Twill\Modules\Post", | ||
// "root_path" => "/app-path/app/Twill/Modules/Post", | ||
// "migrations_dir" => "/app-path/app/Twill/Modules/Post/database/migrations", | ||
// "views_dir" => "/app-path/app/Twill/Modules/Post/resources/views", | ||
// "view_prefix" => "Post.resources.views.admin", | ||
// "routes_file" => "/app-path/app/Twill/Modules/Post/routes/admin.php", | ||
// "model" => "App\Twill\Modules\Post\Data\Models\Post", | ||
// "translation" => "App\Twill\Modules\Post\Data\Models\PostTranslation", | ||
// "slug" => "App\Twill\Modules\Post\Data\Models\PostSlug", | ||
// "revision" => "App\Twill\Modules\Post\Data\Models\PostRevision", | ||
// "repository" => "App\Twill\Modules\Post\Data\Repositories\PostRepository", | ||
// "controller" => "App\Twill\Modules\Post\Http\Controllers\PostController", | ||
// "formRequest" => "App\Twill\Modules\Post\Http\Requests\PostRequest", | ||
// ], | ||
// ], | ||
// ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
namespace A17\Twill; | ||
|
||
use Illuminate\Routing\Router; | ||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Support\ServiceProvider; | ||
use A17\Twill\Services\Capsules\Manager; | ||
use A17\Twill\Services\Routing\HasRoutes; | ||
use A17\Twill\Services\Capsules\HasCapsules; | ||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider; | ||
|
||
class CapsulesServiceProvider extends RouteServiceProvider | ||
{ | ||
use HasRoutes, HasCapsules; | ||
|
||
protected function mergeTwillConfig() | ||
{ | ||
$this->mergeConfigFrom( | ||
__DIR__ . '/../config/capsules.php', | ||
'twill.capsules' | ||
); | ||
|
||
$this->app | ||
->make('config') | ||
->set('twill.capsules.list', $this->getCapsuleList()); | ||
|
||
$this->app->make('config')->set('twill.capsules.loaded', true); | ||
} | ||
|
||
public function register() | ||
{ | ||
$this->registerConfig(); | ||
} | ||
|
||
protected function registerConfig() | ||
{ | ||
$this->mergeTwillConfig(); | ||
|
||
$this->registerCapsules(); | ||
|
||
$this->registerViewPaths(); | ||
|
||
$this->registerManager(); | ||
} | ||
|
||
public function registerCapsules() | ||
{ | ||
$this->getCapsuleList()->map(function ($capsule) { | ||
$this->registerCapsule($capsule); | ||
}); | ||
} | ||
|
||
protected function registerCapsule($capsule) | ||
{ | ||
$this->loadMigrationsFrom($capsule['migrations_dir']); | ||
} | ||
|
||
public function map(Router $router) | ||
{ | ||
$this->getCapsuleList()->each(function ($capsule) use ($router) { | ||
$this->registerCapsuleRoutes($router, $capsule); | ||
}); | ||
} | ||
|
||
public function registerCapsuleRoutes($router, $capsule) | ||
{ | ||
$this->registerRoutes( | ||
$router, | ||
$this->getRouteGroupOptions(), | ||
$this->getRouteMiddleware(), | ||
$this->supportSubdomainRouting(), | ||
"{$capsule['namespace']}\Http\Controllers", | ||
$capsule['routes_file'] | ||
); | ||
} | ||
|
||
public function registerViewPaths() | ||
{ | ||
$this->callAfterResolving('view', function ($view) { | ||
$view->addLocation(config('twill.capsules.path')); | ||
}); | ||
} | ||
|
||
public function registerManager() | ||
{ | ||
$this->app->instance('twill.capsules.manager', new Manager()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.