From 484b5d3e060ad44db0879b29632c9b6b16f2c8a6 Mon Sep 17 00:00:00 2001 From: Marcus Reinhardt Date: Tue, 20 Jan 2015 15:35:28 +0100 Subject: [PATCH 001/357] Revert "Merge pull request #87 from noxify/master" From bde11c1d699a8d3619fcff049fc9c4a85167964a Mon Sep 17 00:00:00 2001 From: Marcus Reinhardt Date: Wed, 21 Jan 2015 16:54:33 +0100 Subject: [PATCH 002/357] added configuration --- .../Modules/Generators/ModuleGenerator.php | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/src/Pingpong/Modules/Generators/ModuleGenerator.php b/src/Pingpong/Modules/Generators/ModuleGenerator.php index 505514a9..7f829123 100644 --- a/src/Pingpong/Modules/Generators/ModuleGenerator.php +++ b/src/Pingpong/Modules/Generators/ModuleGenerator.php @@ -44,34 +44,6 @@ class ModuleGenerator extends Generator { */ protected $module; - /** - * The list of files will be created. - * - * @var array - */ - protected $files = [ - 'start' => 'start.php', - 'routes' => 'Http/routes.php', - 'json' => 'module.json', - 'composer' => 'composer.json', - 'views/index' => 'Resources/views/index.blade.php', - 'views/master' => 'Resources/views/layouts/master.blade.php', - ]; - - /** - * The list of replacement for file generator. - * - * @var array - */ - protected $replacements = [ - 'start' => ['LOWER_NAME'], - 'routes' => ['LOWER_NAME', 'STUDLY_NAME'], - 'json' => ['LOWER_NAME', 'STUDLY_NAME'], - 'composer' => ['LOWER_NAME', 'STUDLY_NAME', 'VENDOR', 'AUTHOR_NAME', 'AUTHOR_EMAIL'], - 'views/index' => ['LOWER_NAME'], - 'views/master' => ['STUDLY_NAME'], - ]; - /** * The constructor. * @@ -90,6 +62,7 @@ public function __construct($name, Repository $module = null, Config $config = n $this->module = $module; } + /** * Get the name of module will created. By default in studly case. * @@ -110,6 +83,8 @@ public function getConfig() return $this->config; } + + /** * Set the laravel config instance. * @@ -209,7 +184,7 @@ public function getFolders() */ public function getFiles() { - return $this->files; + return $this->config->get('modules::stubs.files'); } /** @@ -264,6 +239,7 @@ public function generateGitKeep($path) */ public function generateFiles() { + //var_dump($this->getFiles()); foreach ($this->getFiles() as $stub => $file) { $path = $this->module->getModulePath($this->getName()) . $file; @@ -312,6 +288,13 @@ protected function getStubContents($stub) return new Stub($stub, $this->getReplacement($stub)); } + /** + * get the list for the replacements + */ + public function getReplacements() + { + return $this->config->get('modules::stubs.replacements'); + } /** * Get array replacement for the specified stub. * @@ -320,9 +303,11 @@ protected function getStubContents($stub) */ protected function getReplacement($stub) { - if ( ! isset($this->replacements[$stub])) return []; + $replacements = $this->config->get('modules::stubs.replacements'); + + if ( ! isset($replacements[$stub])) return []; - $keys = $this->replacements[$stub]; + $keys = $replacements[$stub]; $replaces = []; From 01ae27da99cd9f72f4ad098cd875bd16d56ffbe4 Mon Sep 17 00:00:00 2001 From: Marcus Reinhardt Date: Wed, 21 Jan 2015 20:00:15 +0100 Subject: [PATCH 003/357] added enabled flag to disable stub generation --- .../Modules/Generators/ModuleGenerator.php | 16 ++++++++++------ src/config/config.php | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Pingpong/Modules/Generators/ModuleGenerator.php b/src/Pingpong/Modules/Generators/ModuleGenerator.php index 7f829123..c3975d2f 100644 --- a/src/Pingpong/Modules/Generators/ModuleGenerator.php +++ b/src/Pingpong/Modules/Generators/ModuleGenerator.php @@ -201,11 +201,16 @@ public function generate() $this->generateFolders(); - $this->generateFiles(); - - $this->generateResources(); - - $this->console->info("Module [{$name}] created successfully."); + if( $this->config->get('modules::stubs.enabled', false) ) + { + $this->generateFiles(); + $this->generateResources(); + } + + $this->console->info("Module [{$name}] created, successfully."); + + + } /** @@ -239,7 +244,6 @@ public function generateGitKeep($path) */ public function generateFiles() { - //var_dump($this->getFiles()); foreach ($this->getFiles() as $stub => $file) { $path = $this->module->getModulePath($this->getName()) . $file; diff --git a/src/config/config.php b/src/config/config.php index c4e516af..4a3bfbc9 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -3,8 +3,9 @@ return [ 'stubs' => [ - 'path' => base_path().'/vendor/pingpong/modules/src/Pingpong/Modules/Commands/stubs', - 'files' => [ + 'enabled' => false, + 'path' => base_path().'/vendor/pingpong/modules/src/Pingpong/Modules/Commands/stubs', + 'files' => [ 'start' => 'start.php', 'routes' => 'Http/routes.php', 'json' => 'module.json', From 1096507f159aae9cb92ab866139fac3f4f48a7b8 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 11:26:04 +0700 Subject: [PATCH 004/357] Remove changes file --- changes.md | 90 ------------------------------------------------------ 1 file changed, 90 deletions(-) delete mode 100644 changes.md diff --git a/changes.md b/changes.md deleted file mode 100644 index 02b30d3c..00000000 --- a/changes.md +++ /dev/null @@ -1,90 +0,0 @@ -Changes Log -============ - -**1.1.6 to 1.1.7** - -- See [this](https://github.com/pingpong-labs/modules/releases/tag/1.1.7) - -**1.1.5 to 1.1.6** - -- See [#41](https://github.com/pingpong-labs/modules/pull/41) -- Fix [#40](https://github.com/pingpong-labs/modules/pull/40) -- Start from now this package licensed under The BSD 3-Clause License. - -**1.1.4 to 1.1.5** - -See [#39](https://github.com/pingpong-labs/modules/pull/39) - -**1.1.3 to 1.1.4** - -See [#35](https://github.com/pingpong-labs/modules/pull/35) - -**1.1.2 to 1.1.3** - -- Added new controller validator. Please see [this example](https://github.com/pingpong-modules/Admin/blob/master/Http/Controllers/Auth/RegisterController.php). -- Added `--master` option to `module:seed-make` command. -- Fix `module:seed` command - -**1.1.1 to 1.1.2** - -- Added new feature, now every module can require other composer package. you can define the required package in your module.json file. for example : - -```json -{ - "name": "Admin", - "alias": "admin", - "description": "Admin Modules", - "keywords": [ - "admin", - "modules", - "pingpong" - ], - "require": { - "pingpong/trusty": "1.*", - "pingpong/shortcode": "1.*" - }, - "active": 1 -} -``` - -If the `require` key is not empty, then we will install its packages automatically when you install that module. - -**1.1.0 to 1.1.1** - -- Added new artisan commands `module:install`. This command is useful for installing the modules. -For example i have `Admin` modules [here](https://github.com/pingpong-modules/Admin). You can install it using this command. - -``` -php artisan module:install pingpong-modules/Admin -``` - -By default, that module will stored in current modules directory. If you want to store that in other directory or other path, simply specify the `--path` option. For example : -``` -php artisan module:install pingpong-modules/Admin --path=App/Modules -``` - -**1.0.* to 1.1.0** - -See [#32](https://github.com/pingpong-labs/modules/pull/32) - -**1.0.10 to 1.0.11** - -See [#26](https://github.com/pingpong-labs/modules/pull/26) - -**1.0.9 to 1.0.10** - -- Added support for [#13](https://github.com/pingpong-labs/modules/pull/13) : enable and disable module. -- There is new artisan command `module:enable` and `module:disable`. - -**1.0.8 to 1.0.9** - -- Fix `module:seed-make` command when running `module:make` command. -- Command Improvement. - -**1.0.7 to 1.0.8** - -- There is command name changed : - - `php artisan module:migrate:make` to `php artisan module:migration` - - `php artisan module:seed:make` to `php artisan module:seed-make` -- Merged [#8](https://github.com/pingpong-labs/modules/pull/18) : Fix constructor error. -- Package improvement. \ No newline at end of file From 2d11b9b9f51762fec155071717382cba7e0d533b Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 11:43:45 +0700 Subject: [PATCH 005/357] Sync & update file structure for pingpong/modules --- .../Modules/Collection.php => Collection.php | 0 .../Commands => Commands}/CommandCommand.php | 0 .../ControllerCommand.php | 0 .../Commands => Commands}/DisableCommand.php | 0 .../Commands => Commands}/DumpCommand.php | 0 .../Commands => Commands}/EnableCommand.php | 0 .../GenerateFilterCommand.php | 0 .../GenerateProviderCommand.php | 0 .../GenerateRouteProviderCommand.php | 0 .../GeneratorCommand.php | 0 .../Commands => Commands}/InstallCommand.php | 0 .../Commands => Commands}/ListCommand.php | 0 .../Commands => Commands}/MakeCommand.php | 0 .../Commands => Commands}/MigrateCommand.php | 0 .../MigrateRefreshCommand.php | 0 .../MigrateResetCommand.php | 0 .../MigrateRollbackCommand.php | 0 .../MigrationCommand.php | 0 .../Commands => Commands}/ModelCommand.php | 0 .../Commands => Commands}/PublishCommand.php | 0 .../PublishMigrationCommand.php | 0 .../Commands => Commands}/SeedCommand.php | 0 .../Commands => Commands}/SeedMakeCommand.php | 0 .../Commands => Commands}/SetupCommand.php | 0 .../Commands => Commands}/UpdateCommand.php | 0 .../Commands => Commands}/UseCommand.php | 0 .../Commands => Commands}/stubs/command.stub | 0 .../Commands => Commands}/stubs/composer.stub | 0 .../stubs/controller.stub | 0 .../Commands => Commands}/stubs/filter.stub | 0 .../Commands => Commands}/stubs/json.stub | 0 .../stubs/migration/add.stub | 0 .../stubs/migration/create.stub | 0 .../stubs/migration/delete.stub | 0 .../stubs/migration/drop.stub | 0 .../stubs/migration/plain.stub | 0 .../Commands => Commands}/stubs/model.stub | 0 .../Commands => Commands}/stubs/provider.stub | 0 .../stubs/route-provider.stub | 0 .../Commands => Commands}/stubs/routes.stub | 0 .../Commands => Commands}/stubs/seeder.stub | 0 .../Commands => Commands}/stubs/start.stub | 0 .../stubs/views/index.stub | 0 .../stubs/views/master.stub | 0 .../PublisherInterface.php | 0 .../RepositoryInterface.php | 0 .../RunableInterface.php | 0 .../FileMissingException.php | 0 .../ModuleNotFoundException.php | 0 .../Modules/Facades => Facades}/Module.php | 0 .../FileGenerator.php | 0 .../Generators => Generators}/Generator.php | 0 .../ModuleGenerator.php | 0 src/Pingpong/Modules/Json.php => Json.php | 0 src/Pingpong/Modules/Module.php => Module.php | 0 ...Provider.php => ModulesServiceProvider.php | 0 .../Modules/Process => Process}/Installer.php | 0 .../Modules/Process => Process}/Runner.php | 0 .../Modules/Process => Process}/Updater.php | 0 .../ConsoleServiceProvider.php | 0 .../AssetPublisher.php | 0 .../MigrationPublisher.php | 0 .../Publishing => Publishing}/Publisher.php | 0 .../Modules/Repository.php => Repository.php | 0 .../MigrationLoaderTrait.php | 0 .../Traits => Traits}/ModuleCommandTrait.php | 0 composer.json | 82 +++++----- fixture/Modules/Blog/Assets/.gitkeep | 0 fixture/Modules/Blog/Config/.gitkeep | 0 fixture/Modules/Blog/Console/.gitkeep | 0 .../Modules/Blog/Database/Migrations/.gitkeep | 0 .../Modules/Blog/Database/Seeders/.gitkeep | 0 .../Database/Seeders/BlogDatabaseSeeder.php | 20 --- fixture/Modules/Blog/Entities/.gitkeep | 0 .../Modules/Blog/Http/Controllers/.gitkeep | 0 .../Blog/Http/Controllers/BlogController.php | 13 -- fixture/Modules/Blog/Http/Filters/.gitkeep | 0 fixture/Modules/Blog/Http/Requests/.gitkeep | 0 fixture/Modules/Blog/Http/routes.php | 6 - fixture/Modules/Blog/Providers/.gitkeep | 0 .../Blog/Providers/BlogServiceProvider.php | 34 ----- fixture/Modules/Blog/Repositories/.gitkeep | 0 fixture/Modules/Blog/Resources/lang/.gitkeep | 0 fixture/Modules/Blog/Resources/views/.gitkeep | 0 .../Blog/Resources/views/index.blade.php | 7 - .../Resources/views/layouts/master.blade.php | 12 -- fixture/Modules/Blog/Tests/.gitkeep | 0 fixture/Modules/Blog/composer.json | 15 -- fixture/Modules/Blog/module.json | 12 -- fixture/Modules/Blog/start.php | 12 -- fixture/Modules/User/Assets/.gitkeep | 0 fixture/Modules/User/Config/.gitkeep | 0 fixture/Modules/User/Console/.gitkeep | 0 .../Modules/User/Database/Migrations/.gitkeep | 0 .../Modules/User/Database/Seeders/.gitkeep | 0 .../Database/Seeders/UserDatabaseSeeder.php | 20 --- fixture/Modules/User/Entities/.gitkeep | 0 .../Modules/User/Http/Controllers/.gitkeep | 0 .../User/Http/Controllers/UserController.php | 13 -- fixture/Modules/User/Http/Filters/.gitkeep | 0 fixture/Modules/User/Http/Requests/.gitkeep | 0 fixture/Modules/User/Http/routes.php | 6 - fixture/Modules/User/Providers/.gitkeep | 0 .../User/Providers/UserServiceProvider.php | 34 ----- fixture/Modules/User/Repositories/.gitkeep | 0 fixture/Modules/User/Resources/lang/.gitkeep | 0 fixture/Modules/User/Resources/views/.gitkeep | 0 .../User/Resources/views/index.blade.php | 7 - .../Resources/views/layouts/master.blade.php | 12 -- fixture/Modules/User/Tests/.gitkeep | 0 fixture/Modules/User/composer.json | 15 -- fixture/Modules/User/module.json | 12 -- fixture/Modules/User/start.php | 12 -- fixture/app/config/.gitignore | 0 fixture/app/config/app.php | 98 ------------ fixture/app/config/auth.php | 71 --------- fixture/app/config/cache.php | 89 ----------- fixture/app/config/compile.php | 18 --- fixture/app/config/database.php | 124 ---------------- fixture/app/config/mail.php | 124 ---------------- fixture/app/config/queue.php | 85 ----------- fixture/app/config/remote.php | 59 -------- fixture/app/config/services.php | 30 ---- fixture/app/config/session.php | 140 ------------------ fixture/app/config/view.php | 31 ---- fixture/app/config/workbench.php | 31 ---- fixture/app/database/migrations/.gitkeep | 0 fixture/app/database/seeds/.gitkeep | 0 fixture/app/modules/.gitkeep | 0 fixture/app/routes.php | 23 --- fixture/app/start/artisan.php | 2 - fixture/app/start/global.php | 2 - fixture/app/storage/cache/.gitignore | 2 - fixture/app/storage/logs/.gitignore | 0 fixture/app/storage/meta/.gitignore | 2 - fixture/app/storage/sessions/.gitignore | 0 fixture/app/storage/views/.gitignore | 0 fixture/artisan | 75 ---------- fixture/composer.json | 11 -- fixture/public/.gitignore | 0 fixture/public/modules/.gitignore | 2 - tests/.gitkeep | 0 tests/Pingpong/Modules/CliTest.php | 49 ------ tests/Pingpong/Modules/JsonTest.php | 79 ---------- tests/Pingpong/Modules/RepositoryTest.php | 80 ---------- tests/Pingpong/Modules/TestCase.php | 71 --------- tests/Pingpong/Modules/test.json | 8 - 147 files changed, 38 insertions(+), 1612 deletions(-) rename src/Pingpong/Modules/Collection.php => Collection.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/CommandCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/ControllerCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/DisableCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/DumpCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/EnableCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/GenerateFilterCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/GenerateProviderCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/GenerateRouteProviderCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/GeneratorCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/InstallCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/ListCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/MakeCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/MigrateCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/MigrateRefreshCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/MigrateResetCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/MigrateRollbackCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/MigrationCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/ModelCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/PublishCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/PublishMigrationCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/SeedCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/SeedMakeCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/SetupCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/UpdateCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/UseCommand.php (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/command.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/composer.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/controller.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/filter.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/json.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/migration/add.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/migration/create.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/migration/delete.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/migration/drop.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/migration/plain.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/model.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/provider.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/route-provider.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/routes.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/seeder.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/start.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/views/index.stub (100%) rename {src/Pingpong/Modules/Commands => Commands}/stubs/views/master.stub (100%) rename {src/Pingpong/Modules/Contracts => Contracts}/PublisherInterface.php (100%) rename {src/Pingpong/Modules/Contracts => Contracts}/RepositoryInterface.php (100%) rename {src/Pingpong/Modules/Contracts => Contracts}/RunableInterface.php (100%) rename {src/Pingpong/Modules/Exceptions => Exceptions}/FileMissingException.php (100%) rename {src/Pingpong/Modules/Exceptions => Exceptions}/ModuleNotFoundException.php (100%) rename {src/Pingpong/Modules/Facades => Facades}/Module.php (100%) rename {src/Pingpong/Modules/Generators => Generators}/FileGenerator.php (100%) rename {src/Pingpong/Modules/Generators => Generators}/Generator.php (100%) rename {src/Pingpong/Modules/Generators => Generators}/ModuleGenerator.php (100%) rename src/Pingpong/Modules/Json.php => Json.php (100%) rename src/Pingpong/Modules/Module.php => Module.php (100%) rename src/Pingpong/Modules/ModulesServiceProvider.php => ModulesServiceProvider.php (100%) rename {src/Pingpong/Modules/Process => Process}/Installer.php (100%) rename {src/Pingpong/Modules/Process => Process}/Runner.php (100%) rename {src/Pingpong/Modules/Process => Process}/Updater.php (100%) rename {src/Pingpong/Modules/Providers => Providers}/ConsoleServiceProvider.php (100%) rename {src/Pingpong/Modules/Publishing => Publishing}/AssetPublisher.php (100%) rename {src/Pingpong/Modules/Publishing => Publishing}/MigrationPublisher.php (100%) rename {src/Pingpong/Modules/Publishing => Publishing}/Publisher.php (100%) rename src/Pingpong/Modules/Repository.php => Repository.php (100%) rename {src/Pingpong/Modules/Traits => Traits}/MigrationLoaderTrait.php (100%) rename {src/Pingpong/Modules/Traits => Traits}/ModuleCommandTrait.php (100%) delete mode 100644 fixture/Modules/Blog/Assets/.gitkeep delete mode 100644 fixture/Modules/Blog/Config/.gitkeep delete mode 100644 fixture/Modules/Blog/Console/.gitkeep delete mode 100644 fixture/Modules/Blog/Database/Migrations/.gitkeep delete mode 100644 fixture/Modules/Blog/Database/Seeders/.gitkeep delete mode 100644 fixture/Modules/Blog/Database/Seeders/BlogDatabaseSeeder.php delete mode 100644 fixture/Modules/Blog/Entities/.gitkeep delete mode 100644 fixture/Modules/Blog/Http/Controllers/.gitkeep delete mode 100644 fixture/Modules/Blog/Http/Controllers/BlogController.php delete mode 100644 fixture/Modules/Blog/Http/Filters/.gitkeep delete mode 100644 fixture/Modules/Blog/Http/Requests/.gitkeep delete mode 100644 fixture/Modules/Blog/Http/routes.php delete mode 100644 fixture/Modules/Blog/Providers/.gitkeep delete mode 100644 fixture/Modules/Blog/Providers/BlogServiceProvider.php delete mode 100644 fixture/Modules/Blog/Repositories/.gitkeep delete mode 100644 fixture/Modules/Blog/Resources/lang/.gitkeep delete mode 100644 fixture/Modules/Blog/Resources/views/.gitkeep delete mode 100644 fixture/Modules/Blog/Resources/views/index.blade.php delete mode 100644 fixture/Modules/Blog/Resources/views/layouts/master.blade.php delete mode 100644 fixture/Modules/Blog/Tests/.gitkeep delete mode 100644 fixture/Modules/Blog/composer.json delete mode 100644 fixture/Modules/Blog/module.json delete mode 100644 fixture/Modules/Blog/start.php delete mode 100644 fixture/Modules/User/Assets/.gitkeep delete mode 100644 fixture/Modules/User/Config/.gitkeep delete mode 100644 fixture/Modules/User/Console/.gitkeep delete mode 100644 fixture/Modules/User/Database/Migrations/.gitkeep delete mode 100644 fixture/Modules/User/Database/Seeders/.gitkeep delete mode 100644 fixture/Modules/User/Database/Seeders/UserDatabaseSeeder.php delete mode 100644 fixture/Modules/User/Entities/.gitkeep delete mode 100644 fixture/Modules/User/Http/Controllers/.gitkeep delete mode 100644 fixture/Modules/User/Http/Controllers/UserController.php delete mode 100644 fixture/Modules/User/Http/Filters/.gitkeep delete mode 100644 fixture/Modules/User/Http/Requests/.gitkeep delete mode 100644 fixture/Modules/User/Http/routes.php delete mode 100644 fixture/Modules/User/Providers/.gitkeep delete mode 100644 fixture/Modules/User/Providers/UserServiceProvider.php delete mode 100644 fixture/Modules/User/Repositories/.gitkeep delete mode 100644 fixture/Modules/User/Resources/lang/.gitkeep delete mode 100644 fixture/Modules/User/Resources/views/.gitkeep delete mode 100644 fixture/Modules/User/Resources/views/index.blade.php delete mode 100644 fixture/Modules/User/Resources/views/layouts/master.blade.php delete mode 100644 fixture/Modules/User/Tests/.gitkeep delete mode 100644 fixture/Modules/User/composer.json delete mode 100644 fixture/Modules/User/module.json delete mode 100644 fixture/Modules/User/start.php delete mode 100644 fixture/app/config/.gitignore delete mode 100644 fixture/app/config/app.php delete mode 100644 fixture/app/config/auth.php delete mode 100644 fixture/app/config/cache.php delete mode 100644 fixture/app/config/compile.php delete mode 100644 fixture/app/config/database.php delete mode 100644 fixture/app/config/mail.php delete mode 100644 fixture/app/config/queue.php delete mode 100644 fixture/app/config/remote.php delete mode 100644 fixture/app/config/services.php delete mode 100644 fixture/app/config/session.php delete mode 100644 fixture/app/config/view.php delete mode 100644 fixture/app/config/workbench.php delete mode 100644 fixture/app/database/migrations/.gitkeep delete mode 100644 fixture/app/database/seeds/.gitkeep delete mode 100644 fixture/app/modules/.gitkeep delete mode 100644 fixture/app/routes.php delete mode 100644 fixture/app/start/artisan.php delete mode 100644 fixture/app/start/global.php delete mode 100644 fixture/app/storage/cache/.gitignore delete mode 100644 fixture/app/storage/logs/.gitignore delete mode 100644 fixture/app/storage/meta/.gitignore delete mode 100644 fixture/app/storage/sessions/.gitignore delete mode 100644 fixture/app/storage/views/.gitignore delete mode 100644 fixture/artisan delete mode 100644 fixture/composer.json delete mode 100644 fixture/public/.gitignore delete mode 100644 fixture/public/modules/.gitignore delete mode 100644 tests/.gitkeep delete mode 100644 tests/Pingpong/Modules/CliTest.php delete mode 100644 tests/Pingpong/Modules/JsonTest.php delete mode 100644 tests/Pingpong/Modules/RepositoryTest.php delete mode 100644 tests/Pingpong/Modules/TestCase.php delete mode 100644 tests/Pingpong/Modules/test.json diff --git a/src/Pingpong/Modules/Collection.php b/Collection.php similarity index 100% rename from src/Pingpong/Modules/Collection.php rename to Collection.php diff --git a/src/Pingpong/Modules/Commands/CommandCommand.php b/Commands/CommandCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/CommandCommand.php rename to Commands/CommandCommand.php diff --git a/src/Pingpong/Modules/Commands/ControllerCommand.php b/Commands/ControllerCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/ControllerCommand.php rename to Commands/ControllerCommand.php diff --git a/src/Pingpong/Modules/Commands/DisableCommand.php b/Commands/DisableCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/DisableCommand.php rename to Commands/DisableCommand.php diff --git a/src/Pingpong/Modules/Commands/DumpCommand.php b/Commands/DumpCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/DumpCommand.php rename to Commands/DumpCommand.php diff --git a/src/Pingpong/Modules/Commands/EnableCommand.php b/Commands/EnableCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/EnableCommand.php rename to Commands/EnableCommand.php diff --git a/src/Pingpong/Modules/Commands/GenerateFilterCommand.php b/Commands/GenerateFilterCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/GenerateFilterCommand.php rename to Commands/GenerateFilterCommand.php diff --git a/src/Pingpong/Modules/Commands/GenerateProviderCommand.php b/Commands/GenerateProviderCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/GenerateProviderCommand.php rename to Commands/GenerateProviderCommand.php diff --git a/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php b/Commands/GenerateRouteProviderCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php rename to Commands/GenerateRouteProviderCommand.php diff --git a/src/Pingpong/Modules/Commands/GeneratorCommand.php b/Commands/GeneratorCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/GeneratorCommand.php rename to Commands/GeneratorCommand.php diff --git a/src/Pingpong/Modules/Commands/InstallCommand.php b/Commands/InstallCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/InstallCommand.php rename to Commands/InstallCommand.php diff --git a/src/Pingpong/Modules/Commands/ListCommand.php b/Commands/ListCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/ListCommand.php rename to Commands/ListCommand.php diff --git a/src/Pingpong/Modules/Commands/MakeCommand.php b/Commands/MakeCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/MakeCommand.php rename to Commands/MakeCommand.php diff --git a/src/Pingpong/Modules/Commands/MigrateCommand.php b/Commands/MigrateCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/MigrateCommand.php rename to Commands/MigrateCommand.php diff --git a/src/Pingpong/Modules/Commands/MigrateRefreshCommand.php b/Commands/MigrateRefreshCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/MigrateRefreshCommand.php rename to Commands/MigrateRefreshCommand.php diff --git a/src/Pingpong/Modules/Commands/MigrateResetCommand.php b/Commands/MigrateResetCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/MigrateResetCommand.php rename to Commands/MigrateResetCommand.php diff --git a/src/Pingpong/Modules/Commands/MigrateRollbackCommand.php b/Commands/MigrateRollbackCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/MigrateRollbackCommand.php rename to Commands/MigrateRollbackCommand.php diff --git a/src/Pingpong/Modules/Commands/MigrationCommand.php b/Commands/MigrationCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/MigrationCommand.php rename to Commands/MigrationCommand.php diff --git a/src/Pingpong/Modules/Commands/ModelCommand.php b/Commands/ModelCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/ModelCommand.php rename to Commands/ModelCommand.php diff --git a/src/Pingpong/Modules/Commands/PublishCommand.php b/Commands/PublishCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/PublishCommand.php rename to Commands/PublishCommand.php diff --git a/src/Pingpong/Modules/Commands/PublishMigrationCommand.php b/Commands/PublishMigrationCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/PublishMigrationCommand.php rename to Commands/PublishMigrationCommand.php diff --git a/src/Pingpong/Modules/Commands/SeedCommand.php b/Commands/SeedCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/SeedCommand.php rename to Commands/SeedCommand.php diff --git a/src/Pingpong/Modules/Commands/SeedMakeCommand.php b/Commands/SeedMakeCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/SeedMakeCommand.php rename to Commands/SeedMakeCommand.php diff --git a/src/Pingpong/Modules/Commands/SetupCommand.php b/Commands/SetupCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/SetupCommand.php rename to Commands/SetupCommand.php diff --git a/src/Pingpong/Modules/Commands/UpdateCommand.php b/Commands/UpdateCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/UpdateCommand.php rename to Commands/UpdateCommand.php diff --git a/src/Pingpong/Modules/Commands/UseCommand.php b/Commands/UseCommand.php similarity index 100% rename from src/Pingpong/Modules/Commands/UseCommand.php rename to Commands/UseCommand.php diff --git a/src/Pingpong/Modules/Commands/stubs/command.stub b/Commands/stubs/command.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/command.stub rename to Commands/stubs/command.stub diff --git a/src/Pingpong/Modules/Commands/stubs/composer.stub b/Commands/stubs/composer.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/composer.stub rename to Commands/stubs/composer.stub diff --git a/src/Pingpong/Modules/Commands/stubs/controller.stub b/Commands/stubs/controller.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/controller.stub rename to Commands/stubs/controller.stub diff --git a/src/Pingpong/Modules/Commands/stubs/filter.stub b/Commands/stubs/filter.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/filter.stub rename to Commands/stubs/filter.stub diff --git a/src/Pingpong/Modules/Commands/stubs/json.stub b/Commands/stubs/json.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/json.stub rename to Commands/stubs/json.stub diff --git a/src/Pingpong/Modules/Commands/stubs/migration/add.stub b/Commands/stubs/migration/add.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/migration/add.stub rename to Commands/stubs/migration/add.stub diff --git a/src/Pingpong/Modules/Commands/stubs/migration/create.stub b/Commands/stubs/migration/create.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/migration/create.stub rename to Commands/stubs/migration/create.stub diff --git a/src/Pingpong/Modules/Commands/stubs/migration/delete.stub b/Commands/stubs/migration/delete.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/migration/delete.stub rename to Commands/stubs/migration/delete.stub diff --git a/src/Pingpong/Modules/Commands/stubs/migration/drop.stub b/Commands/stubs/migration/drop.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/migration/drop.stub rename to Commands/stubs/migration/drop.stub diff --git a/src/Pingpong/Modules/Commands/stubs/migration/plain.stub b/Commands/stubs/migration/plain.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/migration/plain.stub rename to Commands/stubs/migration/plain.stub diff --git a/src/Pingpong/Modules/Commands/stubs/model.stub b/Commands/stubs/model.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/model.stub rename to Commands/stubs/model.stub diff --git a/src/Pingpong/Modules/Commands/stubs/provider.stub b/Commands/stubs/provider.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/provider.stub rename to Commands/stubs/provider.stub diff --git a/src/Pingpong/Modules/Commands/stubs/route-provider.stub b/Commands/stubs/route-provider.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/route-provider.stub rename to Commands/stubs/route-provider.stub diff --git a/src/Pingpong/Modules/Commands/stubs/routes.stub b/Commands/stubs/routes.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/routes.stub rename to Commands/stubs/routes.stub diff --git a/src/Pingpong/Modules/Commands/stubs/seeder.stub b/Commands/stubs/seeder.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/seeder.stub rename to Commands/stubs/seeder.stub diff --git a/src/Pingpong/Modules/Commands/stubs/start.stub b/Commands/stubs/start.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/start.stub rename to Commands/stubs/start.stub diff --git a/src/Pingpong/Modules/Commands/stubs/views/index.stub b/Commands/stubs/views/index.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/views/index.stub rename to Commands/stubs/views/index.stub diff --git a/src/Pingpong/Modules/Commands/stubs/views/master.stub b/Commands/stubs/views/master.stub similarity index 100% rename from src/Pingpong/Modules/Commands/stubs/views/master.stub rename to Commands/stubs/views/master.stub diff --git a/src/Pingpong/Modules/Contracts/PublisherInterface.php b/Contracts/PublisherInterface.php similarity index 100% rename from src/Pingpong/Modules/Contracts/PublisherInterface.php rename to Contracts/PublisherInterface.php diff --git a/src/Pingpong/Modules/Contracts/RepositoryInterface.php b/Contracts/RepositoryInterface.php similarity index 100% rename from src/Pingpong/Modules/Contracts/RepositoryInterface.php rename to Contracts/RepositoryInterface.php diff --git a/src/Pingpong/Modules/Contracts/RunableInterface.php b/Contracts/RunableInterface.php similarity index 100% rename from src/Pingpong/Modules/Contracts/RunableInterface.php rename to Contracts/RunableInterface.php diff --git a/src/Pingpong/Modules/Exceptions/FileMissingException.php b/Exceptions/FileMissingException.php similarity index 100% rename from src/Pingpong/Modules/Exceptions/FileMissingException.php rename to Exceptions/FileMissingException.php diff --git a/src/Pingpong/Modules/Exceptions/ModuleNotFoundException.php b/Exceptions/ModuleNotFoundException.php similarity index 100% rename from src/Pingpong/Modules/Exceptions/ModuleNotFoundException.php rename to Exceptions/ModuleNotFoundException.php diff --git a/src/Pingpong/Modules/Facades/Module.php b/Facades/Module.php similarity index 100% rename from src/Pingpong/Modules/Facades/Module.php rename to Facades/Module.php diff --git a/src/Pingpong/Modules/Generators/FileGenerator.php b/Generators/FileGenerator.php similarity index 100% rename from src/Pingpong/Modules/Generators/FileGenerator.php rename to Generators/FileGenerator.php diff --git a/src/Pingpong/Modules/Generators/Generator.php b/Generators/Generator.php similarity index 100% rename from src/Pingpong/Modules/Generators/Generator.php rename to Generators/Generator.php diff --git a/src/Pingpong/Modules/Generators/ModuleGenerator.php b/Generators/ModuleGenerator.php similarity index 100% rename from src/Pingpong/Modules/Generators/ModuleGenerator.php rename to Generators/ModuleGenerator.php diff --git a/src/Pingpong/Modules/Json.php b/Json.php similarity index 100% rename from src/Pingpong/Modules/Json.php rename to Json.php diff --git a/src/Pingpong/Modules/Module.php b/Module.php similarity index 100% rename from src/Pingpong/Modules/Module.php rename to Module.php diff --git a/src/Pingpong/Modules/ModulesServiceProvider.php b/ModulesServiceProvider.php similarity index 100% rename from src/Pingpong/Modules/ModulesServiceProvider.php rename to ModulesServiceProvider.php diff --git a/src/Pingpong/Modules/Process/Installer.php b/Process/Installer.php similarity index 100% rename from src/Pingpong/Modules/Process/Installer.php rename to Process/Installer.php diff --git a/src/Pingpong/Modules/Process/Runner.php b/Process/Runner.php similarity index 100% rename from src/Pingpong/Modules/Process/Runner.php rename to Process/Runner.php diff --git a/src/Pingpong/Modules/Process/Updater.php b/Process/Updater.php similarity index 100% rename from src/Pingpong/Modules/Process/Updater.php rename to Process/Updater.php diff --git a/src/Pingpong/Modules/Providers/ConsoleServiceProvider.php b/Providers/ConsoleServiceProvider.php similarity index 100% rename from src/Pingpong/Modules/Providers/ConsoleServiceProvider.php rename to Providers/ConsoleServiceProvider.php diff --git a/src/Pingpong/Modules/Publishing/AssetPublisher.php b/Publishing/AssetPublisher.php similarity index 100% rename from src/Pingpong/Modules/Publishing/AssetPublisher.php rename to Publishing/AssetPublisher.php diff --git a/src/Pingpong/Modules/Publishing/MigrationPublisher.php b/Publishing/MigrationPublisher.php similarity index 100% rename from src/Pingpong/Modules/Publishing/MigrationPublisher.php rename to Publishing/MigrationPublisher.php diff --git a/src/Pingpong/Modules/Publishing/Publisher.php b/Publishing/Publisher.php similarity index 100% rename from src/Pingpong/Modules/Publishing/Publisher.php rename to Publishing/Publisher.php diff --git a/src/Pingpong/Modules/Repository.php b/Repository.php similarity index 100% rename from src/Pingpong/Modules/Repository.php rename to Repository.php diff --git a/src/Pingpong/Modules/Traits/MigrationLoaderTrait.php b/Traits/MigrationLoaderTrait.php similarity index 100% rename from src/Pingpong/Modules/Traits/MigrationLoaderTrait.php rename to Traits/MigrationLoaderTrait.php diff --git a/src/Pingpong/Modules/Traits/ModuleCommandTrait.php b/Traits/ModuleCommandTrait.php similarity index 100% rename from src/Pingpong/Modules/Traits/ModuleCommandTrait.php rename to Traits/ModuleCommandTrait.php diff --git a/composer.json b/composer.json index 2bf68292..5dfceeab 100644 --- a/composer.json +++ b/composer.json @@ -1,46 +1,40 @@ { - "name": "pingpong/modules", - "description": "Laravel Modules", - "keywords": [ - "modules", - "laravel", - "pingpong", - "hmvc", - "module" - ], - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Pingpong Labs", - "email": "pingpong.labs@gmail.com" - } - ], - "require": { - "php": ">=5.4.0", - "laravel/framework": "~4|~5", - "pingpong/generators": "1.*", - "kzykhys/git": "*" - }, - "require-dev": { - "phpunit/phpunit": "~4", - "mockery/mockery": "~0.9", - "pingpong/testing": "1.*" - }, - "autoload": { - "psr-4": { - "Pingpong\\Modules\\": "src/Pingpong/Modules" - } - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.2-dev", - "dev-develop": "1.3-dev" - } - }, - "minimum-stability": "stable" + "name": "pingpong/modules", + "description": "Laravel Modules", + "keywords": [ + "modules", + "laravel", + "pingpong", + "hmvc", + "module" + ], + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Pingpong Labs", + "email": "pingpong.labs@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "laravel/framework": "~4", + "pingpong/generators": "1.*", + "kzykhys/git": "*" + }, + "require-dev": { + "phpunit/phpunit": "~4", + "mockery/mockery": "~0.9", + "pingpong/testing": "1.*" + }, + "autoload": { + "psr-4": { + "Pingpong\\Modules\\": "" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "minimum-stability": "stable" } diff --git a/fixture/Modules/Blog/Assets/.gitkeep b/fixture/Modules/Blog/Assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Config/.gitkeep b/fixture/Modules/Blog/Config/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Console/.gitkeep b/fixture/Modules/Blog/Console/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Database/Migrations/.gitkeep b/fixture/Modules/Blog/Database/Migrations/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Database/Seeders/.gitkeep b/fixture/Modules/Blog/Database/Seeders/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Database/Seeders/BlogDatabaseSeeder.php b/fixture/Modules/Blog/Database/Seeders/BlogDatabaseSeeder.php deleted file mode 100644 index bdd2baf5..00000000 --- a/fixture/Modules/Blog/Database/Seeders/BlogDatabaseSeeder.php +++ /dev/null @@ -1,20 +0,0 @@ -call("OthersTableSeeder"); - } - -} \ No newline at end of file diff --git a/fixture/Modules/Blog/Entities/.gitkeep b/fixture/Modules/Blog/Entities/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Http/Controllers/.gitkeep b/fixture/Modules/Blog/Http/Controllers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Http/Controllers/BlogController.php b/fixture/Modules/Blog/Http/Controllers/BlogController.php deleted file mode 100644 index 82d94a25..00000000 --- a/fixture/Modules/Blog/Http/Controllers/BlogController.php +++ /dev/null @@ -1,13 +0,0 @@ - 'blog', 'namespace' => 'Modules\Blog\Http\Controllers'], function() -{ - Route::get('/', 'BlogController@index'); -}); \ No newline at end of file diff --git a/fixture/Modules/Blog/Providers/.gitkeep b/fixture/Modules/Blog/Providers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/Providers/BlogServiceProvider.php b/fixture/Modules/Blog/Providers/BlogServiceProvider.php deleted file mode 100644 index de68ec5f..00000000 --- a/fixture/Modules/Blog/Providers/BlogServiceProvider.php +++ /dev/null @@ -1,34 +0,0 @@ -Hello World - -@stop \ No newline at end of file diff --git a/fixture/Modules/Blog/Resources/views/layouts/master.blade.php b/fixture/Modules/Blog/Resources/views/layouts/master.blade.php deleted file mode 100644 index 0fb7563e..00000000 --- a/fixture/Modules/Blog/Resources/views/layouts/master.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Module Blog - - - @yield('content') - - \ No newline at end of file diff --git a/fixture/Modules/Blog/Tests/.gitkeep b/fixture/Modules/Blog/Tests/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/Blog/composer.json b/fixture/Modules/Blog/composer.json deleted file mode 100644 index 757977c6..00000000 --- a/fixture/Modules/Blog/composer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "pingpong-modules/blog", - "description": "", - "authors": [ - { - "name": "Pingpong Labs", - "email": "pingpong.labs@gmail.com" - } - ], - "autoload": { - "psr-4": { - "Modules\\Blog\\": "" - } - } -} \ No newline at end of file diff --git a/fixture/Modules/Blog/module.json b/fixture/Modules/Blog/module.json deleted file mode 100644 index e85a50fa..00000000 --- a/fixture/Modules/Blog/module.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Blog", - "alias": "blog", - "description": "", - "keywords": [], - "active": 1, - "priority": 0, - "providers": [], - "files": [ - "start.php" - ] -} \ No newline at end of file diff --git a/fixture/Modules/Blog/start.php b/fixture/Modules/Blog/start.php deleted file mode 100644 index 8ce075d0..00000000 --- a/fixture/Modules/Blog/start.php +++ /dev/null @@ -1,12 +0,0 @@ -call("OthersTableSeeder"); - } - -} \ No newline at end of file diff --git a/fixture/Modules/User/Entities/.gitkeep b/fixture/Modules/User/Entities/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/User/Http/Controllers/.gitkeep b/fixture/Modules/User/Http/Controllers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/User/Http/Controllers/UserController.php b/fixture/Modules/User/Http/Controllers/UserController.php deleted file mode 100644 index 5ababa55..00000000 --- a/fixture/Modules/User/Http/Controllers/UserController.php +++ /dev/null @@ -1,13 +0,0 @@ - 'user', 'namespace' => 'Modules\User\Http\Controllers'], function() -{ - Route::get('/', 'UserController@index'); -}); \ No newline at end of file diff --git a/fixture/Modules/User/Providers/.gitkeep b/fixture/Modules/User/Providers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/User/Providers/UserServiceProvider.php b/fixture/Modules/User/Providers/UserServiceProvider.php deleted file mode 100644 index 29e9ed27..00000000 --- a/fixture/Modules/User/Providers/UserServiceProvider.php +++ /dev/null @@ -1,34 +0,0 @@ -Hello World - -@stop \ No newline at end of file diff --git a/fixture/Modules/User/Resources/views/layouts/master.blade.php b/fixture/Modules/User/Resources/views/layouts/master.blade.php deleted file mode 100644 index 9eb012b4..00000000 --- a/fixture/Modules/User/Resources/views/layouts/master.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Module User - - - @yield('content') - - \ No newline at end of file diff --git a/fixture/Modules/User/Tests/.gitkeep b/fixture/Modules/User/Tests/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/Modules/User/composer.json b/fixture/Modules/User/composer.json deleted file mode 100644 index f1bec113..00000000 --- a/fixture/Modules/User/composer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "pingpong-modules/user", - "description": "", - "authors": [ - { - "name": "Pingpong Labs", - "email": "pingpong.labs@gmail.com" - } - ], - "autoload": { - "psr-4": { - "Modules\\User\\": "" - } - } -} \ No newline at end of file diff --git a/fixture/Modules/User/module.json b/fixture/Modules/User/module.json deleted file mode 100644 index 340ebf41..00000000 --- a/fixture/Modules/User/module.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "User", - "alias": "user", - "description": "", - "keywords": [], - "active": 1, - "priority": 1, - "providers": [], - "files": [ - "start.php" - ] -} \ No newline at end of file diff --git a/fixture/Modules/User/start.php b/fixture/Modules/User/start.php deleted file mode 100644 index 8ce075d0..00000000 --- a/fixture/Modules/User/start.php +++ /dev/null @@ -1,12 +0,0 @@ - false, - - /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | - */ - - 'url' => 'http://localhost', - - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ - - 'timezone' => 'UTC', - - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - - 'locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ - - 'fallback_locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ - - 'key' => 'YourSecretKey!!!', - - 'cipher' => MCRYPT_RIJNDAEL_128, - - /* - |-------------------------------------------------------------------------- - | Service Provider Manifest - |-------------------------------------------------------------------------- - | - | The service provider manifest is used by Laravel to lazy load service - | providers which are not needed for each request, as well to keep a - | list of all of the services. Here, you may set its storage spot. - | - */ - - 'manifest' => storage_path().'/meta', - -); diff --git a/fixture/app/config/auth.php b/fixture/app/config/auth.php deleted file mode 100644 index eacbbfae..00000000 --- a/fixture/app/config/auth.php +++ /dev/null @@ -1,71 +0,0 @@ - 'eloquent', - - /* - |-------------------------------------------------------------------------- - | Authentication Model - |-------------------------------------------------------------------------- - | - | When using the "Eloquent" authentication driver, we need to know which - | Eloquent model should be used to retrieve your users. Of course, it - | is often just the "User" model but you may use whatever you like. - | - */ - - 'model' => 'User', - - /* - |-------------------------------------------------------------------------- - | Authentication Table - |-------------------------------------------------------------------------- - | - | When using the "Database" authentication driver, we need to know which - | table should be used to retrieve your users. We have chosen a basic - | default value but you may easily change it to any table you like. - | - */ - - 'table' => 'users', - - /* - |-------------------------------------------------------------------------- - | Password Reminder Settings - |-------------------------------------------------------------------------- - | - | Here you may set the settings for password reminders, including a view - | that should be used as your password reminder e-mail. You will also - | be able to set the name of the table that holds the reset tokens. - | - | The "expire" time is the number of minutes that the reminder should be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | - */ - - 'reminder' => array( - - 'email' => 'emails.auth.reminder', - - 'table' => 'password_reminders', - - 'expire' => 60, - - ), - -); diff --git a/fixture/app/config/cache.php b/fixture/app/config/cache.php deleted file mode 100644 index ce898423..00000000 --- a/fixture/app/config/cache.php +++ /dev/null @@ -1,89 +0,0 @@ - 'file', - - /* - |-------------------------------------------------------------------------- - | File Cache Location - |-------------------------------------------------------------------------- - | - | When using the "file" cache driver, we need a location where the cache - | files may be stored. A sensible default has been specified, but you - | are free to change it to any other place on disk that you desire. - | - */ - - 'path' => storage_path().'/cache', - - /* - |-------------------------------------------------------------------------- - | Database Cache Connection - |-------------------------------------------------------------------------- - | - | When using the "database" cache driver you may specify the connection - | that should be used to store the cached items. When this option is - | null the default database connection will be utilized for cache. - | - */ - - 'connection' => null, - - /* - |-------------------------------------------------------------------------- - | Database Cache Table - |-------------------------------------------------------------------------- - | - | When using the "database" cache driver we need to know the table that - | should be used to store the cached items. A default table name has - | been provided but you're free to change it however you deem fit. - | - */ - - 'table' => 'cache', - - /* - |-------------------------------------------------------------------------- - | Memcached Servers - |-------------------------------------------------------------------------- - | - | Now you may specify an array of your Memcached servers that should be - | used when utilizing the Memcached cache driver. All of the servers - | should contain a value for "host", "port", and "weight" options. - | - */ - - 'memcached' => array( - - array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100), - - ), - - /* - |-------------------------------------------------------------------------- - | Cache Key Prefix - |-------------------------------------------------------------------------- - | - | When utilizing a RAM based store such as APC or Memcached, there might - | be other applications utilizing the same cache. So, we'll specify a - | value to get prefixed to all our keys so we can avoid collisions. - | - */ - - 'prefix' => 'laravel', - -); diff --git a/fixture/app/config/compile.php b/fixture/app/config/compile.php deleted file mode 100644 index 54d7185b..00000000 --- a/fixture/app/config/compile.php +++ /dev/null @@ -1,18 +0,0 @@ - PDO::FETCH_CLASS, - - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ - - 'default' => 'mysql', - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - - 'connections' => array( - - 'sqlite' => array( - 'driver' => 'sqlite', - 'database' => __DIR__.'/../database/production.sqlite', - 'prefix' => '', - ), - - 'mysql' => array( - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ), - - 'pgsql' => array( - 'driver' => 'pgsql', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - ), - - 'sqlsrv' => array( - 'driver' => 'sqlsrv', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => '', - 'prefix' => '', - ), - - ), - - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - - 'migrations' => 'migrations', - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - - 'redis' => array( - - 'cluster' => false, - - 'default' => array( - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 0, - ), - - ), - -); diff --git a/fixture/app/config/mail.php b/fixture/app/config/mail.php deleted file mode 100644 index dce8c469..00000000 --- a/fixture/app/config/mail.php +++ /dev/null @@ -1,124 +0,0 @@ - 'smtp', - - /* - |-------------------------------------------------------------------------- - | SMTP Host Address - |-------------------------------------------------------------------------- - | - | Here you may provide the host address of the SMTP server used by your - | applications. A default option is provided that is compatible with - | the Mailgun mail service which will provide reliable deliveries. - | - */ - - 'host' => 'smtp.mailgun.org', - - /* - |-------------------------------------------------------------------------- - | SMTP Host Port - |-------------------------------------------------------------------------- - | - | This is the SMTP port used by your application to delivery e-mails to - | users of your application. Like the host we have set this value to - | stay compatible with the Mailgun e-mail applications by default. - | - */ - - 'port' => 587, - - /* - |-------------------------------------------------------------------------- - | Global "From" Address - |-------------------------------------------------------------------------- - | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. - | - */ - - 'from' => array('address' => null, 'name' => null), - - /* - |-------------------------------------------------------------------------- - | E-Mail Encryption Protocol - |-------------------------------------------------------------------------- - | - | Here you may specify the encryption protocol that should be used when - | the application send e-mail messages. A sensible default using the - | transport layer security protocol should provide great security. - | - */ - - 'encryption' => 'tls', - - /* - |-------------------------------------------------------------------------- - | SMTP Server Username - |-------------------------------------------------------------------------- - | - | If your SMTP server requires a username for authentication, you should - | set it here. This will get used to authenticate with your server on - | connection. You may also set the "password" value below this one. - | - */ - - 'username' => null, - - /* - |-------------------------------------------------------------------------- - | SMTP Server Password - |-------------------------------------------------------------------------- - | - | Here you may set the password required by your SMTP server to send out - | messages from your application. This will be given to the server on - | connection so that the application will be able to send messages. - | - */ - - 'password' => null, - - /* - |-------------------------------------------------------------------------- - | Sendmail System Path - |-------------------------------------------------------------------------- - | - | When using the "sendmail" driver to send e-mails, we will need to know - | the path to where Sendmail lives on this server. A default path has - | been provided here, which will work well on most of your systems. - | - */ - - 'sendmail' => '/usr/sbin/sendmail -bs', - - /* - |-------------------------------------------------------------------------- - | Mail "Pretend" - |-------------------------------------------------------------------------- - | - | When this option is enabled, e-mail will not actually be sent over the - | web and will instead be written to your application's logs files so - | you may inspect the message. This is great for local development. - | - */ - - 'pretend' => false, - -); diff --git a/fixture/app/config/queue.php b/fixture/app/config/queue.php deleted file mode 100644 index 63050654..00000000 --- a/fixture/app/config/queue.php +++ /dev/null @@ -1,85 +0,0 @@ - 'sync', - - /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - */ - - 'connections' => array( - - 'sync' => array( - 'driver' => 'sync', - ), - - 'beanstalkd' => array( - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'ttr' => 60, - ), - - 'sqs' => array( - 'driver' => 'sqs', - 'key' => 'your-public-key', - 'secret' => 'your-secret-key', - 'queue' => 'your-queue-url', - 'region' => 'us-east-1', - ), - - 'iron' => array( - 'driver' => 'iron', - 'host' => 'mq-aws-us-east-1.iron.io', - 'token' => 'your-token', - 'project' => 'your-project-id', - 'queue' => 'your-queue-name', - 'encrypt' => true, - ), - - 'redis' => array( - 'driver' => 'redis', - 'queue' => 'default', - ), - - ), - - /* - |-------------------------------------------------------------------------- - | Failed Queue Jobs - |-------------------------------------------------------------------------- - | - | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. - | - */ - - 'failed' => array( - - 'database' => 'mysql', 'table' => 'failed_jobs', - - ), - -); diff --git a/fixture/app/config/remote.php b/fixture/app/config/remote.php deleted file mode 100644 index 2169c434..00000000 --- a/fixture/app/config/remote.php +++ /dev/null @@ -1,59 +0,0 @@ - 'production', - - /* - |-------------------------------------------------------------------------- - | Remote Server Connections - |-------------------------------------------------------------------------- - | - | These are the servers that will be accessible via the SSH task runner - | facilities of Laravel. This feature radically simplifies executing - | tasks on your servers, such as deploying out these applications. - | - */ - - 'connections' => array( - - 'production' => array( - 'host' => '', - 'username' => '', - 'password' => '', - 'key' => '', - 'keyphrase' => '', - 'root' => '/var/www', - ), - - ), - - /* - |-------------------------------------------------------------------------- - | Remote Server Groups - |-------------------------------------------------------------------------- - | - | Here you may list connections under a single group name, which allows - | you to easily access all of the servers at once using a short name - | that is extremely easy to remember, such as "web" or "database". - | - */ - - 'groups' => array( - - 'web' => array('production') - - ), - -); diff --git a/fixture/app/config/services.php b/fixture/app/config/services.php deleted file mode 100644 index 601c11c5..00000000 --- a/fixture/app/config/services.php +++ /dev/null @@ -1,30 +0,0 @@ - array( - 'secret' => '', - ), - - 'mandrill' => array( - 'secret' => '', - ), - - 'stripe' => array( - 'model' => 'User', - 'secret' => '', - ), - -); diff --git a/fixture/app/config/session.php b/fixture/app/config/session.php deleted file mode 100644 index ae343029..00000000 --- a/fixture/app/config/session.php +++ /dev/null @@ -1,140 +0,0 @@ - 'file', - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | - */ - - 'lifetime' => 120, - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ - - 'files' => storage_path().'/sessions', - - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | - */ - - 'connection' => null, - - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ - - 'table' => 'sessions', - - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ - - 'lottery' => array(2, 100), - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ - - 'cookie' => 'laravel_session', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ - - 'domain' => null, - - /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you if it can not be done securely. - | - */ - - 'secure' => false, - -); diff --git a/fixture/app/config/view.php b/fixture/app/config/view.php deleted file mode 100644 index 34b8f387..00000000 --- a/fixture/app/config/view.php +++ /dev/null @@ -1,31 +0,0 @@ - array(__DIR__.'/../views'), - - /* - |-------------------------------------------------------------------------- - | Pagination View - |-------------------------------------------------------------------------- - | - | This view will be used to render the pagination link output, and can - | be easily customized here to show any view you like. A clean view - | compatible with Twitter's Bootstrap is given to you by default. - | - */ - - 'pagination' => 'pagination::slider-3', - -); diff --git a/fixture/app/config/workbench.php b/fixture/app/config/workbench.php deleted file mode 100644 index 87c5e387..00000000 --- a/fixture/app/config/workbench.php +++ /dev/null @@ -1,31 +0,0 @@ - '', - - /* - |-------------------------------------------------------------------------- - | Workbench Author E-Mail Address - |-------------------------------------------------------------------------- - | - | Like the option above, your e-mail address is used when generating new - | workbench packages. The e-mail is placed in your composer.json file - | automatically after the package is created by the workbench tool. - | - */ - - 'email' => '', - -); diff --git a/fixture/app/database/migrations/.gitkeep b/fixture/app/database/migrations/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/app/database/seeds/.gitkeep b/fixture/app/database/seeds/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/app/modules/.gitkeep b/fixture/app/modules/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/app/routes.php b/fixture/app/routes.php deleted file mode 100644 index f6b45cbb..00000000 --- a/fixture/app/routes.php +++ /dev/null @@ -1,23 +0,0 @@ - 'required', - 'password' => 'required' - ]); - - if ($validation->fails()) - { - throw new RuntimeException("Validation failed"); - } - - return Collection::make($data); -}); \ No newline at end of file diff --git a/fixture/app/start/artisan.php b/fixture/app/start/artisan.php deleted file mode 100644 index 4989beae..00000000 --- a/fixture/app/start/artisan.php +++ /dev/null @@ -1,2 +0,0 @@ -setRequestForConsoleEnvironment(); - -$artisan = Illuminate\Console\Application::start($app); - -/* -|-------------------------------------------------------------------------- -| Run The Artisan Application -|-------------------------------------------------------------------------- -| -| When we run the console application, the current CLI command will be -| executed in this console and the response sent back to a terminal -| or another output device for the developers. Here goes nothing! -| -*/ - -$status = $artisan->run(); - -/* -|-------------------------------------------------------------------------- -| Shutdown The Application -|-------------------------------------------------------------------------- -| -| Once Artisan has finished running. We will fire off the shutdown events -| so that any final work may be done by the application before we shut -| down the process. This is the last thing to happen to the request. -| -*/ - -$app->shutdown(); - -exit($status); diff --git a/fixture/composer.json b/fixture/composer.json deleted file mode 100644 index 15ca8a4a..00000000 --- a/fixture/composer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "pingpong-modules-fixture", - "autoload": { - "psr-4": { - "Modules\\": "Modules" - } - }, - "require": { - "pingpong-modules/hello": "dev-master" - } -} diff --git a/fixture/public/.gitignore b/fixture/public/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/fixture/public/modules/.gitignore b/fixture/public/modules/.gitignore deleted file mode 100644 index c96a04f0..00000000 --- a/fixture/public/modules/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/tests/.gitkeep b/tests/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Pingpong/Modules/CliTest.php b/tests/Pingpong/Modules/CliTest.php deleted file mode 100644 index 527b413c..00000000 --- a/tests/Pingpong/Modules/CliTest.php +++ /dev/null @@ -1,49 +0,0 @@ -cleanup(); - - $commandOptions = [ - 'module:setup' => [], - 'module:make' => ['name' => ['Bar']], - 'module:model' => ['model' => 'Baz', 'module' => 'Bar'], - 'module:use' => ['module' => 'Bar'], - 'module:controller' => ['controller' => 'FooController'], - 'module:command' => ['name' => 'FooCommand'], - 'module:disable' => ['module' => 'Bar'], - 'module:enable' => ['module' => 'Bar'], - 'module:provider' => ['name' => 'ConsoleServiceProvider'], - 'module:publish' => ['module' => 'Bar'], - 'module:publish-migration' => ['module' => 'Bar'], - 'module:install' => ['name' => 'pingpong-modules/hello', 'version' => 'dev-master'], - ]; - - foreach ($commandOptions as $command => $options) - { - $this->app['artisan']->call($command, $options); - } - - $this->cleanup(); - } - - public function cleanup() - { - $modules = ['Bar', 'Hello']; - - foreach ($modules as $name) - { - $module = $this->app['modules']->get($name); - - if($module) - { - $module->delete(); - - rmdir($module->getPath()); - } - } - } - -} \ No newline at end of file diff --git a/tests/Pingpong/Modules/JsonTest.php b/tests/Pingpong/Modules/JsonTest.php deleted file mode 100644 index 09dd60b4..00000000 --- a/tests/Pingpong/Modules/JsonTest.php +++ /dev/null @@ -1,79 +0,0 @@ -json = new Json($this->getPath()); - } - - public function tearDown() - { - $this->json->update($this->getDefaultItems()); - } - - public function getPath() - { - return __DIR__ . '/test.json'; - } - - public function getDefaultItems() - { - return [ - 'name' => 'Test', - 'alias' => 'test', - 'dependencies' => [ - 'pingpong/modules' => '1.*', - 'pingpong/admin' => '1.*' - ] - ]; - } - - public function testGetContents() - { - $data = $this->json->getAttributes(); - $this->assertTrue(is_array($data)); - } - - public function testMakeNewInstance() - { - $data = Json::make($this->getPath()); - $this->assertInstanceOf('Pingpong\Modules\Json', $data); - $this->assertTrue(is_array($data->toArray())); - } - - public function testPutOrUpdateItem() - { - $this->assertEquals('Test', $this->json->name); - $this->json->put('name', 'Home'); - $this->assertEquals('Home', $this->json->name); - } - - public function testForgetItem() - { - $this->json->forget('alias'); - $this->assertNull($this->json->alias); - } - - public function testUpdateAndSaveItem() - { - $this->json->name = 'Pingpong'; - $this->json->alias = 'pingpong'; - $this->json->save(); - $this->assertEquals('Pingpong', $this->json->name); - $this->assertEquals('pingpong', $this->json->alias); - } - - public function testUpdateItem() - { - $this->json->update([ - 'name' => 'John', - 'alias' => 'john' - ]); - $this->assertEquals('John', $this->json->name); - $this->assertEquals('john', $this->json->alias); - } - -} \ No newline at end of file diff --git a/tests/Pingpong/Modules/RepositoryTest.php b/tests/Pingpong/Modules/RepositoryTest.php deleted file mode 100644 index b9550454..00000000 --- a/tests/Pingpong/Modules/RepositoryTest.php +++ /dev/null @@ -1,80 +0,0 @@ -repository = new \Pingpong\Modules\Repository($this->app, $this->getPath()); - } - - public function getPath() { return __DIR__ . '/../../../fixture/Modules'; } - - public function testGetAllModules() - { - $this->assertTrue(is_array($modules = $this->repository->all())); - $this->assertEquals($this->repository->count(), 2); - } - - public function testGetCachedModules() - { - $this->assertTrue(is_array($modules = $this->repository->getCached())); - $this->assertEquals($this->repository->count(), 2); - } - - public function testGetOrdered() - { - $this->assertTrue(is_array($modules = $this->repository->getOrdered())); - $this->assertEquals($this->repository->count(), 2); - } - - public function testGetConfig() - { - $this->repository->config('assets'); - $this->repository->config('modules'); - $this->repository->config('migration'); - $this->repository->getAssetsPath(); - } - - public function testGetAssetUrl() - { - $url = $this->repository->asset("user:img/image.png"); - $url2 = $this->repository->asset("blog:articles/foo.png"); - $this->assertEquals("http://localhost/modules/user/img/image.png", $url); - $this->assertEquals("http://localhost/modules/blog/articles/foo.png", $url2); - } - - public function testGetAndSetModuleStatus() - { - $status = $this->repository->active('user'); - $this->assertTrue($status); - - $this->repository->disable('user'); - - $status = $this->repository->active('user'); - $this->assertFalse($status); - - $this->repository->enable('user'); - } - - public function testUsed() - { - $this->repository->setUsed('user'); - $used = $this->repository->getUsed(); - $this->assertEquals('user', $used->getLowerName()); - } - - public function addPath() - { - $this->repository->addLocation(__DIR__ . '/../../../fixture/app/modules'); - $this->repository->addPath(__DIR__ . '/../../../fixture/vendor'); - $this->assertEquals(2, count($this->repository->getPaths())); - } - -} \ No newline at end of file diff --git a/tests/Pingpong/Modules/TestCase.php b/tests/Pingpong/Modules/TestCase.php deleted file mode 100644 index c9bfd037..00000000 --- a/tests/Pingpong/Modules/TestCase.php +++ /dev/null @@ -1,71 +0,0 @@ -createApplication(); - } - - /** - * @return array - */ - protected function getApplicationPaths() - { - $basePath = realpath(__DIR__.'/../../../fixture'); - - return [ - 'app' => "{$basePath}/app", - 'public' => "{$basePath}/public", - 'base' => $basePath, - 'storage' => "{$basePath}/app/storage", - ]; - } - - /** - * Get application timezone. - * - * @return string - */ - protected function getApplicationTimezone() - { - return 'UTC'; - } - - /** - * Get package aliases. - * - * @return array - */ - protected function getPackageAliases() - { - return [ - 'Module' => 'Pingpong\Modules\Facades\Module' - ]; - } - /** - * Get package providers. - * - * @return array - */ - protected function getPackageProviders() - { - return [ - 'Pingpong\Modules\ModulesServiceProvider' - ]; - } - - /** - * @param $app - */ - protected function registerBootedCallback($app) - { - putenv('MODULES_TEST=1'); - - ini_set('display_errors', 1); - - Log::useFiles(storage_path().'/logs/laravel.log'); - } -} \ No newline at end of file diff --git a/tests/Pingpong/Modules/test.json b/tests/Pingpong/Modules/test.json deleted file mode 100644 index b1450c42..00000000 --- a/tests/Pingpong/Modules/test.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "Test", - "dependencies": { - "pingpong\/modules": "1.*", - "pingpong\/admin": "1.*" - }, - "alias": "test" -} \ No newline at end of file From 055bb714398b8eda59e9d132678af791ae1c9d24 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 16:08:20 +0700 Subject: [PATCH 006/357] Fix package path --- ModulesServiceProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ModulesServiceProvider.php b/ModulesServiceProvider.php index 612d1056..f911485c 100644 --- a/ModulesServiceProvider.php +++ b/ModulesServiceProvider.php @@ -21,13 +21,11 @@ class ModulesServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('pingpong/modules'); + $this->package('pingpong/modules', 'modules', __DIR__ . '/src'); $this->app['modules']->boot(); $this->app['modules']->register(); - - Stub::setPath($this->app['config']->get('modules::stubs.path')); } /** From 54a35c6ddc24a550fe44ff993a1f72377ec661c1 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 16:08:44 +0700 Subject: [PATCH 007/357] Reformat code --- Generators/ModuleGenerator.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Generators/ModuleGenerator.php b/Generators/ModuleGenerator.php index c3975d2f..3b7922cd 100644 --- a/Generators/ModuleGenerator.php +++ b/Generators/ModuleGenerator.php @@ -84,7 +84,6 @@ public function getConfig() } - /** * Set the laravel config instance. * @@ -157,7 +156,7 @@ public function getModule() /** * Set the pingpong module instance. * - * @param Module $module + * @param mixed $module * @return $this */ public function setModule($module) @@ -201,16 +200,13 @@ public function generate() $this->generateFolders(); - if( $this->config->get('modules::stubs.enabled', false) ) + if ($this->config->get('modules::stubs.enabled', false)) { $this->generateFiles(); $this->generateResources(); - } - - $this->console->info("Module [{$name}] created, successfully."); - + } - + $this->console->info("Module [{$name}] created successfully."); } /** @@ -299,6 +295,7 @@ public function getReplacements() { return $this->config->get('modules::stubs.replacements'); } + /** * Get array replacement for the specified stub. * From 8f5c6d9023a5ecae7be76b7dce91bcdbcc4d2938 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 16:09:32 +0700 Subject: [PATCH 008/357] Set stub path from module repository class --- Repository.php | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/Repository.php b/Repository.php index 7c77f8b8..45a6c846 100644 --- a/Repository.php +++ b/Repository.php @@ -26,11 +26,16 @@ class Repository implements RepositoryInterface, Countable { /** * The scanned paths. - * + * * @var array */ protected $paths = []; + /** + * @var string + */ + protected $stubPath; + /** * The constructor. * @@ -45,7 +50,7 @@ public function __construct(Application $app, $path = null) /** * Add other module location. - * + * * @param string $path * @return $this */ @@ -58,7 +63,7 @@ public function addLocation($path) /** * Alternative method for "addPath". - * + * * @param string $path * @return $this */ @@ -69,7 +74,7 @@ public function addPath($path) /** * Get all additional paths. - * + * * @return array */ public function getPaths() @@ -85,7 +90,7 @@ public function getPaths() public function getScanPaths() { $paths = $this->paths; - + $paths[] = $this->getPath() . '/*'; if ($this->config('scan.enabled')) @@ -520,4 +525,27 @@ public function install($name, $path = null, $subtree = false) with(new Installer($this))->install($name, $path, $subtree); } + /** + * @return string + */ + public function getStubPath() + { + if ( ! is_null($this->stubPath)) return $this->stubPath; + + if ($this->config('stubs.enabled')) return $this->config('stubs.path'); + + return $this->stubPath; + } + + /** + * @param string $stubPath + * @return $this + */ + public function setStubPath($stubPath) + { + $this->stubPath = $stubPath; + + return $this; + } + } \ No newline at end of file From 926c75aa66181284c03990ff10797ddd1ac97e11 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 16:17:38 +0700 Subject: [PATCH 009/357] Fix module:make command --- Generators/ModuleGenerator.php | 14 +++++++------- ModulesServiceProvider.php | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Generators/ModuleGenerator.php b/Generators/ModuleGenerator.php index 3b7922cd..69877510 100644 --- a/Generators/ModuleGenerator.php +++ b/Generators/ModuleGenerator.php @@ -173,7 +173,7 @@ public function setModule($module) */ public function getFolders() { - return array_values($this->config->get('modules::paths.generator')); + return array_values($this->module->config('paths.generator')); } /** @@ -183,7 +183,9 @@ public function getFolders() */ public function getFiles() { - return $this->config->get('modules::stubs.files'); + $files = $this->module->config('stubs.files'); + var_dump($files); + return $files; } /** @@ -200,11 +202,9 @@ public function generate() $this->generateFolders(); - if ($this->config->get('modules::stubs.enabled', false)) - { - $this->generateFiles(); - $this->generateResources(); - } + $this->generateFiles(); + + $this->generateResources(); $this->console->info("Module [{$name}] created successfully."); } diff --git a/ModulesServiceProvider.php b/ModulesServiceProvider.php index f911485c..026bcf7c 100644 --- a/ModulesServiceProvider.php +++ b/ModulesServiceProvider.php @@ -37,6 +37,11 @@ public function register() { $this->registerServices(); $this->registerProviders(); + + $this->app->booted(function ($app) + { + Stub::setPath(__DIR__ . '/Commands/stubs'); + }); } /** From ae66e3f8630281b134f7c0430c34f5a79fdca869 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 4 Feb 2015 16:27:08 +0700 Subject: [PATCH 010/357] Fix #94 --- composer.json | 2 +- src/Pingpong/Modules/ModulesServiceProvider.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 569c3bbe..bf51f65c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.4.0", "laravel/framework": "5.0.x@dev", "pingpong/generators": "1.*", - "illuminate/html": "master" + "illuminate/html": "5.0.*@dev" }, "require-dev": { "phpunit/phpunit": "~4", diff --git a/src/Pingpong/Modules/ModulesServiceProvider.php b/src/Pingpong/Modules/ModulesServiceProvider.php index 09fc34f2..a809a503 100644 --- a/src/Pingpong/Modules/ModulesServiceProvider.php +++ b/src/Pingpong/Modules/ModulesServiceProvider.php @@ -64,6 +64,7 @@ protected function registerHtml() $aliases = [ 'HTML' => 'Illuminate\Html\HtmlFacade', 'Form' => 'Illuminate\Html\FormFacade', + 'Module' => 'Pingpong\Modules\Facades\Module', ]; AliasLoader::getInstance($aliases)->register(); From b26f16cef99f3489b51c048b38d07f3511ebf5c7 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:32:35 +0700 Subject: [PATCH 011/357] Remove useless stuff --- Process/Installer.php | 12 ------------ composer.json | 3 +-- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Process/Installer.php b/Process/Installer.php index 81bec2c9..e3da5af8 100644 --- a/Process/Installer.php +++ b/Process/Installer.php @@ -1,19 +1,7 @@ =5.4.0", "laravel/framework": "~4", - "pingpong/generators": "1.*", - "kzykhys/git": "*" + "pingpong/generators": "1.*" }, "require-dev": { "phpunit/phpunit": "~4", From f75689114e136965a887288c161fc27d0e32583e Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:52:57 +0700 Subject: [PATCH 012/357] Add pull script --- build/pull.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 build/pull.sh diff --git a/build/pull.sh b/build/pull.sh new file mode 100755 index 00000000..200f809d --- /dev/null +++ b/build/pull.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +git pull origin master +git subtree pull --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git master +git subtree pull --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git master +git subtree pull --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git master +git subtree pull --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git master +git subtree pull --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git master +git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git master +git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master +git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master +git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master \ No newline at end of file From d828abc3e30ba5537d662ec4c6dd0b4063cf6737 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:55:31 +0700 Subject: [PATCH 013/357] Sync pingpong/trusty --- .../Trusty/{src/Pingpong/Trusty => }/Entities/Permission.php | 0 .../Trusty/{src/Pingpong/Trusty => }/Entities/Role.php | 0 .../Pingpong/Trusty => }/Exceptions/ForbiddenException.php | 0 .../Trusty/{src/Pingpong/Trusty => }/Facades/Trusty.php | 0 .../Trusty/{src/Pingpong/Trusty => }/Traits/SlugableTrait.php | 0 .../Trusty/{src/Pingpong/Trusty => }/Traits/TrustyTrait.php | 0 src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Trusty.php | 0 .../{src/Pingpong/Trusty => }/TrustyServiceProvider.php | 0 src/Pingpong/Trusty/composer.json | 4 ++-- {src/Pingpong/Trusty/tests => tests/Trusty}/.gitkeep | 0 {src/Pingpong/Trusty/tests => tests/Trusty}/TrustyTest.php | 0 11 files changed, 2 insertions(+), 2 deletions(-) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Entities/Permission.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Entities/Role.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Exceptions/ForbiddenException.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Facades/Trusty.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Traits/SlugableTrait.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Traits/TrustyTrait.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/Trusty.php (100%) rename src/Pingpong/Trusty/{src/Pingpong/Trusty => }/TrustyServiceProvider.php (100%) rename {src/Pingpong/Trusty/tests => tests/Trusty}/.gitkeep (100%) rename {src/Pingpong/Trusty/tests => tests/Trusty}/TrustyTest.php (100%) diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Entities/Permission.php b/src/Pingpong/Trusty/Entities/Permission.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Entities/Permission.php rename to src/Pingpong/Trusty/Entities/Permission.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Entities/Role.php b/src/Pingpong/Trusty/Entities/Role.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Entities/Role.php rename to src/Pingpong/Trusty/Entities/Role.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Exceptions/ForbiddenException.php b/src/Pingpong/Trusty/Exceptions/ForbiddenException.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Exceptions/ForbiddenException.php rename to src/Pingpong/Trusty/Exceptions/ForbiddenException.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Facades/Trusty.php b/src/Pingpong/Trusty/Facades/Trusty.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Facades/Trusty.php rename to src/Pingpong/Trusty/Facades/Trusty.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Traits/SlugableTrait.php b/src/Pingpong/Trusty/Traits/SlugableTrait.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Traits/SlugableTrait.php rename to src/Pingpong/Trusty/Traits/SlugableTrait.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Traits/TrustyTrait.php b/src/Pingpong/Trusty/Traits/TrustyTrait.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Traits/TrustyTrait.php rename to src/Pingpong/Trusty/Traits/TrustyTrait.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/Trusty.php b/src/Pingpong/Trusty/Trusty.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/Trusty.php rename to src/Pingpong/Trusty/Trusty.php diff --git a/src/Pingpong/Trusty/src/Pingpong/Trusty/TrustyServiceProvider.php b/src/Pingpong/Trusty/TrustyServiceProvider.php similarity index 100% rename from src/Pingpong/Trusty/src/Pingpong/Trusty/TrustyServiceProvider.php rename to src/Pingpong/Trusty/TrustyServiceProvider.php diff --git a/src/Pingpong/Trusty/composer.json b/src/Pingpong/Trusty/composer.json index cec0076e..d2383f4e 100644 --- a/src/Pingpong/Trusty/composer.json +++ b/src/Pingpong/Trusty/composer.json @@ -21,8 +21,8 @@ "mockery/mockery": "0.9.*" }, "autoload": { - "psr-0": { - "Pingpong\\Trusty": "src/" + "psr-4": { + "Pingpong\\Trusty": "" } }, "minimum-stability": "stable" diff --git a/src/Pingpong/Trusty/tests/.gitkeep b/tests/Trusty/.gitkeep similarity index 100% rename from src/Pingpong/Trusty/tests/.gitkeep rename to tests/Trusty/.gitkeep diff --git a/src/Pingpong/Trusty/tests/TrustyTest.php b/tests/Trusty/TrustyTest.php similarity index 100% rename from src/Pingpong/Trusty/tests/TrustyTest.php rename to tests/Trusty/TrustyTest.php From 4f6a8458c5c8ac7bc2b00467faa307e1c25d86ac Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:56:10 +0700 Subject: [PATCH 014/357] Update some dependencies version --- src/Pingpong/Trusty/composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Pingpong/Trusty/composer.json b/src/Pingpong/Trusty/composer.json index d2383f4e..31c73119 100644 --- a/src/Pingpong/Trusty/composer.json +++ b/src/Pingpong/Trusty/composer.json @@ -11,14 +11,14 @@ ], "require": { "php": ">=5.4.0", - "illuminate/auth": ">=4.0.0", - "illuminate/support": ">=4.0.0", - "illuminate/routing": ">=4.0.0", - "illuminate/database": ">=4.0.0" + "illuminate/auth": "~4", + "illuminate/support": "~4", + "illuminate/routing": "~4", + "illuminate/database": "~4" }, "require-dev": { - "phpunit/phpunit": "4.1.*", - "mockery/mockery": "0.9.*" + "phpunit/phpunit": "~4", + "mockery/mockery": "~0.9" }, "autoload": { "psr-4": { From 463a24bdcc674e3bcb4cda954eda5237250c458a Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:56:46 +0700 Subject: [PATCH 015/357] Fix package path --- src/Pingpong/Trusty/TrustyServiceProvider.php | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/Pingpong/Trusty/TrustyServiceProvider.php b/src/Pingpong/Trusty/TrustyServiceProvider.php index aaa6f372..74a2eec9 100644 --- a/src/Pingpong/Trusty/TrustyServiceProvider.php +++ b/src/Pingpong/Trusty/TrustyServiceProvider.php @@ -4,46 +4,46 @@ class TrustyServiceProvider extends ServiceProvider { - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; - - /** - * Boot the package. - * - * @return void - */ - public function boot() - { - $this->package('pingpong/trusty'); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app['pingpong.trusty'] = $this->app->share(function($app) - { - $auth = $app['auth']->driver(); - - return new Trusty($auth, $app['router']); - }); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array('pingpong.trusty'); - } + /** + * Indicates if loading of the provider is deferred. + * + * @var bool + */ + protected $defer = false; + + /** + * Boot the package. + * + * @return void + */ + public function boot() + { + $this->package('pingpong/trusty', 'trusty', __DIR__ . '/src'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $this->app['pingpong.trusty'] = $this->app->share(function ($app) + { + $auth = $app['auth']->driver(); + + return new Trusty($auth, $app['router']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('pingpong.trusty'); + } } From 5c6c9f3c9a7e5e8162a4c64a322d4f7f9cac0194 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:57:36 +0700 Subject: [PATCH 016/357] Update ioc binding name --- src/Pingpong/Trusty/Facades/Trusty.php | 7 +++++-- src/Pingpong/Trusty/TrustyServiceProvider.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Pingpong/Trusty/Facades/Trusty.php b/src/Pingpong/Trusty/Facades/Trusty.php index c39d00b0..2565084b 100644 --- a/src/Pingpong/Trusty/Facades/Trusty.php +++ b/src/Pingpong/Trusty/Facades/Trusty.php @@ -4,9 +4,12 @@ class Trusty extends Facade { + /** + * @return string + */ protected static function getFacadeAccessor() { - return 'pingpong.trusty'; + return 'trusty'; } - + } \ No newline at end of file diff --git a/src/Pingpong/Trusty/TrustyServiceProvider.php b/src/Pingpong/Trusty/TrustyServiceProvider.php index 74a2eec9..9a65491b 100644 --- a/src/Pingpong/Trusty/TrustyServiceProvider.php +++ b/src/Pingpong/Trusty/TrustyServiceProvider.php @@ -28,7 +28,7 @@ public function boot() */ public function register() { - $this->app['pingpong.trusty'] = $this->app->share(function ($app) + $this->app['trusty'] = $this->app->share(function ($app) { $auth = $app['auth']->driver(); @@ -43,7 +43,7 @@ public function register() */ public function provides() { - return array('pingpong.trusty'); + return array('trusty'); } } From 786db4b1e2e770505ce46167611c801e60ca4879 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 10:58:40 +0700 Subject: [PATCH 017/357] Add doc block --- src/Pingpong/Trusty/Facades/Trusty.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Trusty/Facades/Trusty.php b/src/Pingpong/Trusty/Facades/Trusty.php index 2565084b..0a878f56 100644 --- a/src/Pingpong/Trusty/Facades/Trusty.php +++ b/src/Pingpong/Trusty/Facades/Trusty.php @@ -5,8 +5,10 @@ class Trusty extends Facade { /** + * Get the registered name of the component. + * * @return string - */ + */ protected static function getFacadeAccessor() { return 'trusty'; From 34f419878e8835bba72174ff49dc3c0719f8535c Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 11:00:04 +0700 Subject: [PATCH 018/357] Reformat code --- src/Pingpong/Trusty/Entities/Permission.php | 36 +-- src/Pingpong/Trusty/Entities/Role.php | 112 +++---- .../Trusty/Exceptions/ForbiddenException.php | 4 +- src/Pingpong/Trusty/Facades/Trusty.php | 18 +- src/Pingpong/Trusty/Traits/SlugableTrait.php | 20 +- src/Pingpong/Trusty/Traits/TrustyTrait.php | 290 +++++++++--------- src/Pingpong/Trusty/Trusty.php | 118 +++---- src/Pingpong/Trusty/composer.json | 59 ++-- src/Pingpong/Trusty/phpunit.xml | 2 +- .../2014_05_02_051938_create_roles_table.php | 49 +-- ..._05_02_052125_create_permissions_table.php | 49 +-- ...14_05_02_052410_create_role_user_table.php | 53 ++-- ...02_092851_create_permission_role_table.php | 51 +-- 13 files changed, 436 insertions(+), 425 deletions(-) diff --git a/src/Pingpong/Trusty/Entities/Permission.php b/src/Pingpong/Trusty/Entities/Permission.php index e4d3526d..190fde7a 100644 --- a/src/Pingpong/Trusty/Entities/Permission.php +++ b/src/Pingpong/Trusty/Entities/Permission.php @@ -4,24 +4,24 @@ use Pingpong\Trusty\Traits\SlugableTrait; class Permission extends Model { - - use SlugableTrait; - /** - * Fillable property. - * - * @var array - */ - protected $fillable = ['name', 'slug', 'description']; + use SlugableTrait; + + /** + * Fillable property. + * + * @var array + */ + protected $fillable = ['name', 'slug', 'description']; + + /** + * Relation to "Role". + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function roles() + { + return $this->belongsToMany(__NAMESPACE__ . '\\Role')->withTimestamps(); + } - /** - * Relation to "Role". - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function roles() - { - return $this->belongsToMany(__NAMESPACE__ . '\\Role')->withTimestamps(); - } - } \ No newline at end of file diff --git a/src/Pingpong/Trusty/Entities/Role.php b/src/Pingpong/Trusty/Entities/Role.php index a18e3a7f..24e35ca2 100644 --- a/src/Pingpong/Trusty/Entities/Role.php +++ b/src/Pingpong/Trusty/Entities/Role.php @@ -1,69 +1,69 @@ belongsToMany(__NAMESPACE__ . '\\Permission')->withTimestamps(); - } + /** + * Relation to "Permission". + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function permissions() + { + return $this->belongsToMany(__NAMESPACE__ . '\\Permission')->withTimestamps(); + } - /** - * Relation to "User". - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function users() - { - return $this->belongsToMany(Config::get('auth.model'))->withTimestamps(); - } + /** + * Relation to "User". + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function users() + { + return $this->belongsToMany(Config::get('auth.model'))->withTimestamps(); + } - /** - * Check whether the user role can perform the given permission. - * - * @param string $permission - * @return boolean - */ - public function can($permission) - { - return in_array($permission, array_fetch($this->permissions->toArray(), 'slug')); - } + /** + * Check whether the user role can perform the given permission. + * + * @param string $permission + * @return boolean + */ + public function can($permission) + { + return in_array($permission, array_fetch($this->permissions->toArray(), 'slug')); + } - /** - * Handle dynamic method. - * - * @param string $method - * @param array $parameters - * @return boolean - */ - public function __call($method, $parameters = array()) - { - if(starts_with($method, 'can') and $method != 'can') - { - return $this->can(snake_case(substr($method, 3))); - } - else - { - $query = $this->newQuery(); + /** + * Handle dynamic method. + * + * @param string $method + * @param array $parameters + * @return boolean + */ + public function __call($method, $parameters = array()) + { + if (starts_with($method, 'can') and $method != 'can') + { + return $this->can(snake_case(substr($method, 3))); + } + else + { + $query = $this->newQuery(); - return call_user_func_array(array($query, $method), $parameters); - } - } + return call_user_func_array(array($query, $method), $parameters); + } + } } \ No newline at end of file diff --git a/src/Pingpong/Trusty/Exceptions/ForbiddenException.php b/src/Pingpong/Trusty/Exceptions/ForbiddenException.php index 9ae063b6..b3c156c0 100644 --- a/src/Pingpong/Trusty/Exceptions/ForbiddenException.php +++ b/src/Pingpong/Trusty/Exceptions/ForbiddenException.php @@ -1,3 +1,5 @@ attributes['slug'] = Str::slug($value, '_'); - } - + /** + * Set slug property. + * + * @param string $value + */ + public function setSlugAttribute($value) + { + $this->attributes['slug'] = Str::slug($value, '_'); + } + } \ No newline at end of file diff --git a/src/Pingpong/Trusty/Traits/TrustyTrait.php b/src/Pingpong/Trusty/Traits/TrustyTrait.php index e82a101f..95063595 100644 --- a/src/Pingpong/Trusty/Traits/TrustyTrait.php +++ b/src/Pingpong/Trusty/Traits/TrustyTrait.php @@ -1,154 +1,154 @@ belongsToMany('Pingpong\Trusty\Entities\Role')->withTimestamps(); - } - - /** - * Get all roles from current user. - * - * @return array|null - */ - public function getRoles() - { - return ! is_null($this->roles) ? $this->roles->lists('slug') : null; - } - - /** - * Get all roles from current user. - * - * @return \Illuminate\Database\Eloquent\Collection|null - */ - public function getPermissions() - { - return ! is_null($this->getRole()) ? $this->getRole()->permissions : null; - } - - /** - * Get user role from the current user. - * - * @return \Role - */ - public function getRole() - { - return $this->roles->first(); - } - + + /** + * Relation to "Role". + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany|null + */ + public function roles() + { + return $this->belongsToMany('Pingpong\Trusty\Entities\Role')->withTimestamps(); + } + + /** + * Get all roles from current user. + * + * @return array|null + */ + public function getRoles() + { + return ! is_null($this->roles) ? $this->roles->lists('slug') : null; + } + + /** + * Get all roles from current user. + * + * @return \Illuminate\Database\Eloquent\Collection|null + */ + public function getPermissions() + { + return ! is_null($this->getRole()) ? $this->getRole()->permissions : null; + } + + /** + * Get user role from the current user. + * + * @return \Role + */ + public function getRole() + { + return $this->roles->first(); + } + /** * Get role id * * @return mixed */ - public function getRoleId() - { - return $this->getRole() ? $this->getRole()->id : null; - } - - /** - * Get all permissions from the current user. - * - * @return array|null - */ - public function permissions() - { - return ! is_null($this->getPermissions()) ? $this->getPermissions()->lists('slug') : []; - } - - /** - * Check whether the user has a given role. - * - * @param string $role - * @return boolean - */ - public function is($role) - { - return in_array($role, $this->getRoles()); - } - - /** - * Check whether the user has a given permission. - * - * @param string $permission - * @return boolean - */ - public function can($permission) - { - return in_array($permission, $this->permissions()); - } - - /** - * Has role scope. - * - * @param Builder $query - * @param string $type - * @return Builder - */ - public function scopeHasRole($query, $type) - { - return $query->whereHas('roles', function($query) use ($type) - { - $query->where('slug', $type); - }); - } - - /** - * Add role to this user. - * - * @param int $id - */ - public function addRole($id) - { - $this->roles()->attach($id); - } - - /** - * Update roles. - * - * @param int $id - * @return void - */ - public function updateRole($id) - { - $this->roles()->detach($this->getRoleId()); - - $this->addRole($id); - } - - /** - * Handle dynamic method. - * - * @param string $method - * @param array $parameters - * @return boolean - */ - public function __call($method, $parameters = array()) - { - if(starts_with($method, 'is') and $method != 'is') - { - return $this->is(snake_case(substr($method, 2))); - } - elseif(starts_with($method, 'can') and $method != 'can') - { - return $this->can(snake_case(substr($method, 3))); - } - elseif (in_array($method, ['increment', 'decrement'])) - { - return call_user_func_array([$this, $method], $parameters); - } - else - { - $query = $this->newQuery(); - - return call_user_func_array([$query, $method], $parameters); - } - } - + public function getRoleId() + { + return $this->getRole() ? $this->getRole()->id : null; + } + + /** + * Get all permissions from the current user. + * + * @return array|null + */ + public function permissions() + { + return ! is_null($this->getPermissions()) ? $this->getPermissions()->lists('slug') : []; + } + + /** + * Check whether the user has a given role. + * + * @param string $role + * @return boolean + */ + public function is($role) + { + return in_array($role, $this->getRoles()); + } + + /** + * Check whether the user has a given permission. + * + * @param string $permission + * @return boolean + */ + public function can($permission) + { + return in_array($permission, $this->permissions()); + } + + /** + * Has role scope. + * + * @param Builder $query + * @param string $type + * @return Builder + */ + public function scopeHasRole($query, $type) + { + return $query->whereHas('roles', function ($query) use ($type) + { + $query->where('slug', $type); + }); + } + + /** + * Add role to this user. + * + * @param int $id + */ + public function addRole($id) + { + $this->roles()->attach($id); + } + + /** + * Update roles. + * + * @param int $id + * @return void + */ + public function updateRole($id) + { + $this->roles()->detach($this->getRoleId()); + + $this->addRole($id); + } + + /** + * Handle dynamic method. + * + * @param string $method + * @param array $parameters + * @return boolean + */ + public function __call($method, $parameters = array()) + { + if (starts_with($method, 'is') and $method != 'is') + { + return $this->is(snake_case(substr($method, 2))); + } + elseif (starts_with($method, 'can') and $method != 'can') + { + return $this->can(snake_case(substr($method, 3))); + } + elseif (in_array($method, ['increment', 'decrement'])) + { + return call_user_func_array([$this, $method], $parameters); + } + else + { + $query = $this->newQuery(); + + return call_user_func_array([$query, $method], $parameters); + } + } + } diff --git a/src/Pingpong/Trusty/Trusty.php b/src/Pingpong/Trusty/Trusty.php index e6368465..b269d866 100644 --- a/src/Pingpong/Trusty/Trusty.php +++ b/src/Pingpong/Trusty/Trusty.php @@ -6,69 +6,69 @@ class Trusty { - const VERSION = '1.x-dev'; - - /** - * The avaliable HTTP Verbs. - * - * @var array - */ - protected $httpVerbs = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']; + const VERSION = '1.x-dev'; - /** - * The constructor. - * - * @param Guard $auth - * @param Router $router - */ - public function __construct(Guard $auth, Router $router) - { - $this->auth = $auth; - $this->router = $router; - } + /** + * The avaliable HTTP Verbs. + * + * @var array + */ + protected $httpVerbs = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']; - /** - * Register new filter for the specified request. - * - * @param string|array $request - * @param string $permission - * @return self - */ - public function when($request, $permission) - { - foreach ((array) $request as $uri) - { - $this->router->when($uri, $permission, $this->httpVerbs); - } - } + /** + * The constructor. + * + * @param Guard $auth + * @param Router $router + */ + public function __construct(Guard $auth, Router $router) + { + $this->auth = $auth; + $this->router = $router; + } - /** - * Register the permissions. - * - * @param array|null $permissions - * @return void - */ - public function registerPermissions(array $permissions = null) - { - $permissions = $permissions ?: Permission::lists('slug'); + /** + * Register new filter for the specified request. + * + * @param string|array $request + * @param string $permission + * @return self + */ + public function when($request, $permission) + { + foreach ((array)$request as $uri) + { + $this->router->when($uri, $permission, $this->httpVerbs); + } + } - foreach($permissions as $permission) - { - $this->router->filter($permission, function() use ($permission) - { - if( ! $this->auth->user()->can($permission)) $this->forbidden(); - }); - } - } + /** + * Register the permissions. + * + * @param array|null $permissions + * @return void + */ + public function registerPermissions(array $permissions = null) + { + $permissions = $permissions ?: Permission::lists('slug'); - /** - * Show forbidden page. - * - * @return mixed - */ - public function forbidden() - { - throw new Exceptions\ForbiddenException("Sorry, you don't have permission to access this page."); - } + foreach ($permissions as $permission) + { + $this->router->filter($permission, function () use ($permission) + { + if ( ! $this->auth->user()->can($permission)) $this->forbidden(); + }); + } + } + + /** + * Show forbidden page. + * + * @return mixed + */ + public function forbidden() + { + throw new Exceptions\ForbiddenException("Sorry, you don't have permission to access this page."); + } } \ No newline at end of file diff --git a/src/Pingpong/Trusty/composer.json b/src/Pingpong/Trusty/composer.json index 31c73119..94df542e 100644 --- a/src/Pingpong/Trusty/composer.json +++ b/src/Pingpong/Trusty/composer.json @@ -1,29 +1,34 @@ { - "name": "pingpong/trusty", - "description": "Roles and Permissions for Laravel 4", - "keywords": ["roles", "permissions", "laravel", "pingpong"], - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Pingpong Labs", - "email": "pingpong.labs@gmail.com" - } - ], - "require": { - "php": ">=5.4.0", - "illuminate/auth": "~4", - "illuminate/support": "~4", - "illuminate/routing": "~4", - "illuminate/database": "~4" - }, - "require-dev": { - "phpunit/phpunit": "~4", - "mockery/mockery": "~0.9" - }, - "autoload": { - "psr-4": { - "Pingpong\\Trusty": "" - } - }, - "minimum-stability": "stable" + "name": "pingpong/trusty", + "description": "Roles and Permissions for Laravel 4", + "keywords": [ + "roles", + "permissions", + "laravel", + "pingpong" + ], + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Pingpong Labs", + "email": "pingpong.labs@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "illuminate/auth": "~4", + "illuminate/support": "~4", + "illuminate/routing": "~4", + "illuminate/database": "~4" + }, + "require-dev": { + "phpunit/phpunit": "~4", + "mockery/mockery": "~0.9" + }, + "autoload": { + "psr-4": { + "Pingpong\\Trusty": "" + } + }, + "minimum-stability": "stable" } diff --git a/src/Pingpong/Trusty/phpunit.xml b/src/Pingpong/Trusty/phpunit.xml index 3347b75b..37d4d710 100644 --- a/src/Pingpong/Trusty/phpunit.xml +++ b/src/Pingpong/Trusty/phpunit.xml @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" -> + > ./tests/ diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_051938_create_roles_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_051938_create_roles_table.php index affe9ba3..3c0ad6e3 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_051938_create_roles_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_051938_create_roles_table.php @@ -5,31 +5,32 @@ class CreateRolesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('roles', function(Blueprint $table) { - $table->increments('id'); - $table->string('name'); - $table->string('slug')->unique(); - $table->text('description')->nullable(); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('roles', function (Blueprint $table) + { + $table->increments('id'); + $table->string('name'); + $table->string('slug')->unique(); + $table->text('description')->nullable(); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('roles'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('roles'); + } } diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052125_create_permissions_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_052125_create_permissions_table.php index 93646a4b..fe09e1bf 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_052125_create_permissions_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_052125_create_permissions_table.php @@ -5,31 +5,32 @@ class CreatePermissionsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('permissions', function(Blueprint $table) { - $table->increments('id'); - $table->string('name'); - $table->string('slug')->unique(); - $table->text('description')->nullable(); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('permissions', function (Blueprint $table) + { + $table->increments('id'); + $table->string('name'); + $table->string('slug')->unique(); + $table->text('description')->nullable(); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('permissions'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('permissions'); + } } diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php index 60ac0846..cf204181 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php @@ -1,37 +1,38 @@ increments('id'); - $table->integer('role_id')->unsigned()->index(); - $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); - $table->integer('user_id')->unsigned()->index(); - $table->foreign('user_id')->references('id')->on(Config::get('auth.table'))->onDelete('cascade'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('role_user', function (Blueprint $table) + { + $table->increments('id'); + $table->integer('role_id')->unsigned()->index(); + $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); + $table->integer('user_id')->unsigned()->index(); + $table->foreign('user_id')->references('id')->on(Config::get('auth.table'))->onDelete('cascade'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('role_user'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('role_user'); + } } diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_092851_create_permission_role_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_092851_create_permission_role_table.php index d57263af..4b3acf51 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_092851_create_permission_role_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_092851_create_permission_role_table.php @@ -5,32 +5,33 @@ class CreatePermissionRoleTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('permission_role', function(Blueprint $table) { - $table->increments('id'); - $table->integer('permission_id')->unsigned()->index(); - $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade'); - $table->integer('role_id')->unsigned()->index(); - $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); - $table->timestamps(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('permission_role', function (Blueprint $table) + { + $table->increments('id'); + $table->integer('permission_id')->unsigned()->index(); + $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade'); + $table->integer('role_id')->unsigned()->index(); + $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); + $table->timestamps(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('permission_role'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('permission_role'); + } } From e9496083b12d127e7b6634a09e388472b941db6c Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 11:05:58 +0700 Subject: [PATCH 019/357] Add pingpong/trusty --- build/pull.sh | 3 ++- build/push.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/pull.sh b/build/pull.sh index 200f809d..dd6957c8 100755 --- a/build/pull.sh +++ b/build/pull.sh @@ -9,4 +9,5 @@ git subtree pull --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modu git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git master git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master -git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master \ No newline at end of file +git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master +git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master \ No newline at end of file diff --git a/build/push.sh b/build/push.sh index 6375caea..0ce75b99 100755 --- a/build/push.sh +++ b/build/push.sh @@ -9,4 +9,5 @@ git subtree push --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modu git subtree push --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git master git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master -git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master \ No newline at end of file +git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master +git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master \ No newline at end of file From 22b5da86383bb2f887bc8515fb4c439e48d10d22 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 11:14:08 +0700 Subject: [PATCH 020/357] Fix tests --- tests/Oembed/OembedTest.php | 8 ++++++-- tests/Testing/TestingTest.php | 5 +++++ tests/Trusty/TrustyTest.php | 6 +++++- tests/Widget/WidgetTest.php | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/Oembed/OembedTest.php b/tests/Oembed/OembedTest.php index 50888603..79d3956c 100644 --- a/tests/Oembed/OembedTest.php +++ b/tests/Oembed/OembedTest.php @@ -18,6 +18,11 @@ public function setUp() $this->oembed = new Oembed($this->embed, $this->cache); } + public function tearDown() + { + m::close(); + } + public function test_initialize() { $this->assertInstanceOf('Pingpong\Oembed\Oembed', $this->oembed); @@ -48,10 +53,9 @@ public function test_get_info_from_a_specify_url_but_false_returned() public function test_get_info_from_a_specify_url_and_also_use_laravel_cache_manager() { - $url = 'https://www.youtube.com/watch?v=PP1xn5wHtxE'; - $this->embed->shouldReceive('get')->once()->with($url, '')->andReturn(array('url' => $url)); +// $this->embed->shouldReceive('get')->once()->with($url, '')->andReturn(array('url' => $url)); $this->cache->shouldReceive('remember')->once()->andReturn(array('url' => $url)); $info = $this->oembed->cache($url); diff --git a/tests/Testing/TestingTest.php b/tests/Testing/TestingTest.php index 71a6607d..7e0f043b 100644 --- a/tests/Testing/TestingTest.php +++ b/tests/Testing/TestingTest.php @@ -7,6 +7,11 @@ protected function registerBootedCallback($app) include $app['path'] . '/routes.php'; } + public function tearDown() + { + Mockery::close(); + } + public function testOk() { $this->assertInstanceOf('Illuminate\Foundation\Application', $this->app); diff --git a/tests/Trusty/TrustyTest.php b/tests/Trusty/TrustyTest.php index bdb5c273..36b57961 100644 --- a/tests/Trusty/TrustyTest.php +++ b/tests/Trusty/TrustyTest.php @@ -25,6 +25,11 @@ public function setUp() $this->provider = new TrustyServiceProvider($this->app); } + public function tearDown() + { + m::close(); + } + public function test_initialize() { $this->assertInstanceOf('Pingpong\Trusty\Trusty', $this->trusty); @@ -45,7 +50,6 @@ public function test_trusty_when_with_multiple_request() public function test_registers_all_permissions() { $permissions = ['manage_posts', 'manage_users']; - $this->auth->shouldReceive('check')->once()->andReturn(true); $this->router->shouldReceive('filter')->times(2); $this->trusty->registerPermissions($permissions); } diff --git a/tests/Widget/WidgetTest.php b/tests/Widget/WidgetTest.php index 37e15e3a..03bc42d2 100644 --- a/tests/Widget/WidgetTest.php +++ b/tests/Widget/WidgetTest.php @@ -24,7 +24,7 @@ public function setUp() $this->container = new Container; $this->widget = new Widget($this->blade, $this->container); } - + public function testInitialize() { $this->assertInstanceOf('Pingpong\Widget\Widget', $this->widget); From 583089d768cf8ed9ed4a46ba540c4888c5fb4fec Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 11:25:42 +0700 Subject: [PATCH 021/357] Sync pingpong/themes --- build/pull.sh | 3 +- build/push.sh | 3 +- .../themes/default/config/theme.php | 0 .../themes/default/lang/en/theme.php | 0 .../themes/default/views/index.php | 0 .../{src/Pingpong/Themes => }/Finder.php | 0 .../{src/Pingpong/Themes => }/Theme.php | 0 .../Facades/Theme.php => ThemeFacade.php} | 10 +-- src/Pingpong/Themes/ThemesServiceProvider.php | 59 +++++++++++++ src/Pingpong/Themes/composer.json | 4 +- .../Pingpong/Themes/ThemesServiceProvider.php | 59 ------------- src/Pingpong/Themes/tests/.gitkeep | 0 src/Pingpong/Themes/tests/FinderTest.php | 83 ------------------- .../Themes/public => tests/Themes}/.gitkeep | 0 .../tests => tests/Themes}/ThemeTest.php | 6 +- 15 files changed, 73 insertions(+), 154 deletions(-) rename {src/Pingpong/Themes/public => fixture}/themes/default/config/theme.php (100%) rename {src/Pingpong/Themes/public => fixture}/themes/default/lang/en/theme.php (100%) rename {src/Pingpong/Themes/public => fixture}/themes/default/views/index.php (100%) rename src/Pingpong/Themes/{src/Pingpong/Themes => }/Finder.php (100%) rename src/Pingpong/Themes/{src/Pingpong/Themes => }/Theme.php (100%) rename src/Pingpong/Themes/{src/Pingpong/Themes/Facades/Theme.php => ThemeFacade.php} (61%) create mode 100644 src/Pingpong/Themes/ThemesServiceProvider.php delete mode 100644 src/Pingpong/Themes/src/Pingpong/Themes/ThemesServiceProvider.php delete mode 100644 src/Pingpong/Themes/tests/.gitkeep delete mode 100644 src/Pingpong/Themes/tests/FinderTest.php rename {src/Pingpong/Themes/public => tests/Themes}/.gitkeep (100%) rename {src/Pingpong/Themes/tests => tests/Themes}/ThemeTest.php (97%) diff --git a/build/pull.sh b/build/pull.sh index dd6957c8..efda23e0 100755 --- a/build/pull.sh +++ b/build/pull.sh @@ -10,4 +10,5 @@ git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/test git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master -git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master \ No newline at end of file +git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master +git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git master \ No newline at end of file diff --git a/build/push.sh b/build/push.sh index 0ce75b99..7026ebd0 100755 --- a/build/push.sh +++ b/build/push.sh @@ -10,4 +10,5 @@ git subtree push --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/test git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master -git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master \ No newline at end of file +git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master +git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git master \ No newline at end of file diff --git a/src/Pingpong/Themes/public/themes/default/config/theme.php b/fixture/themes/default/config/theme.php similarity index 100% rename from src/Pingpong/Themes/public/themes/default/config/theme.php rename to fixture/themes/default/config/theme.php diff --git a/src/Pingpong/Themes/public/themes/default/lang/en/theme.php b/fixture/themes/default/lang/en/theme.php similarity index 100% rename from src/Pingpong/Themes/public/themes/default/lang/en/theme.php rename to fixture/themes/default/lang/en/theme.php diff --git a/src/Pingpong/Themes/public/themes/default/views/index.php b/fixture/themes/default/views/index.php similarity index 100% rename from src/Pingpong/Themes/public/themes/default/views/index.php rename to fixture/themes/default/views/index.php diff --git a/src/Pingpong/Themes/src/Pingpong/Themes/Finder.php b/src/Pingpong/Themes/Finder.php similarity index 100% rename from src/Pingpong/Themes/src/Pingpong/Themes/Finder.php rename to src/Pingpong/Themes/Finder.php diff --git a/src/Pingpong/Themes/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php similarity index 100% rename from src/Pingpong/Themes/src/Pingpong/Themes/Theme.php rename to src/Pingpong/Themes/Theme.php diff --git a/src/Pingpong/Themes/src/Pingpong/Themes/Facades/Theme.php b/src/Pingpong/Themes/ThemeFacade.php similarity index 61% rename from src/Pingpong/Themes/src/Pingpong/Themes/Facades/Theme.php rename to src/Pingpong/Themes/ThemeFacade.php index 6c7ae1ab..bf4d0997 100644 --- a/src/Pingpong/Themes/src/Pingpong/Themes/Facades/Theme.php +++ b/src/Pingpong/Themes/ThemeFacade.php @@ -1,8 +1,8 @@ -package('pingpong/themes', 'themes', __DIR__ . '/src'); + + $this->registerNamespaces(); + } + + /** + * Register the themes namespaces. + */ + protected function registerNamespaces() + { + $this->app['themes']->registerNamespaces(); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $this->app['themes'] = $this->app->share(function ($app) + { + $finder = new Finder($app['files'], $app['config']); + + return new Theme($finder, $app['config'], $app['view'], $app['translator']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('themes'); + } + +} diff --git a/src/Pingpong/Themes/composer.json b/src/Pingpong/Themes/composer.json index 75f22b84..aeaf15c3 100644 --- a/src/Pingpong/Themes/composer.json +++ b/src/Pingpong/Themes/composer.json @@ -22,8 +22,8 @@ "mockery/mockery": "0.9.*" }, "autoload": { - "psr-0": { - "Pingpong\\Themes\\": "src/" + "psr-4": { + "Pingpong\\Themes\\": "" } }, "minimum-stability": "stable" diff --git a/src/Pingpong/Themes/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/src/Pingpong/Themes/ThemesServiceProvider.php deleted file mode 100644 index 6424751f..00000000 --- a/src/Pingpong/Themes/src/Pingpong/Themes/ThemesServiceProvider.php +++ /dev/null @@ -1,59 +0,0 @@ -package('pingpong/themes'); - - $this->registerNamespaces(); - } - - /** - * Register the themes namespaces. - */ - protected function registerNamespaces() - { - $this->app['themes']->registerNamespaces(); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app['themes'] = $this->app->share(function($app) - { - $finder = new Finder($app['files'], $app['config']); - - return new Theme($finder, $app['config'], $app['view'], $app['translator']); - }); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array('themes'); - } - -} diff --git a/src/Pingpong/Themes/tests/.gitkeep b/src/Pingpong/Themes/tests/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Pingpong/Themes/tests/FinderTest.php b/src/Pingpong/Themes/tests/FinderTest.php deleted file mode 100644 index 81e56963..00000000 --- a/src/Pingpong/Themes/tests/FinderTest.php +++ /dev/null @@ -1,83 +0,0 @@ -shouldReceive('get')->once()->andReturn($this->getPath()); - - $files->shouldReceive('isDirectory')->once()->andReturn(true); - $files->shouldReceive('directories')->once()->andReturn(['themes']); - - $all = $finder->all(); - - $this->assertTrue(is_array($all)); - $this->assertArrayHasKey(0, $all); - $this->assertArrayNotHasKey(1, $all); - } - - function testHasATheme() - { - $config = m::mock('Illuminate\Config\Repository'); - $files = m::mock('Illuminate\Filesystem\Filesystem'); - - $finder = new Finder($files, $config); - $finder->setPath($this->getPath()); - - $files->shouldReceive('isDirectory')->times(2)->andReturn(true); - $files->shouldReceive('directories')->times(2)->andReturn(['default']); - - $this->assertTrue($finder->has('default')); - $this->assertNotTrue($finder->has('white')); - } - - function testSetThemePath() - { - $config = m::mock('Illuminate\Config\Repository'); - $files = m::mock('Illuminate\Filesystem\Filesystem'); - - $finder = new Finder($files, $config); - - $theFinder = $finder->setPath($this->getPath()); - - $this->assertInstanceOf('Pingpong\Themes\Finder', $theFinder); - $this->assertInstanceOf('Pingpong\Themes\Finder', $finder); - } - - function testGetThemePath() - { - $config = m::mock('Illuminate\Config\Repository'); - $files = m::mock('Illuminate\Filesystem\Filesystem'); - - $finder = new Finder($files, $config); - - $config->shouldReceive('get')->times(3)->andReturn($this->getPath()); - - $files->shouldReceive('isDirectory')->times(2)->andReturn(true); - $files->shouldReceive('directories')->times(2)->andReturn(['default']); - - $themePath1 = $finder->getThemePath('default'); - $themePath2 = $finder->getThemePath('white'); - - $this->assertEquals($themePath1, $this->getPath() . "/default"); - $this->assertNull($themePath2); - } -} \ No newline at end of file diff --git a/src/Pingpong/Themes/public/.gitkeep b/tests/Themes/.gitkeep similarity index 100% rename from src/Pingpong/Themes/public/.gitkeep rename to tests/Themes/.gitkeep diff --git a/src/Pingpong/Themes/tests/ThemeTest.php b/tests/Themes/ThemeTest.php similarity index 97% rename from src/Pingpong/Themes/tests/ThemeTest.php rename to tests/Themes/ThemeTest.php index e75a6ffd..57afc07d 100644 --- a/src/Pingpong/Themes/tests/ThemeTest.php +++ b/tests/Themes/ThemeTest.php @@ -3,8 +3,8 @@ use Mockery as m; use Pingpong\Themes\Theme; -class ThemeTest extends PHPUnit_Framework_TestCase -{ +class ThemeTest extends PHPUnit_Framework_TestCase { + function tearDown() { m::close(); @@ -12,7 +12,7 @@ function tearDown() protected function getPath() { - return __DIR__ . '/../public/themes/'; + return __DIR__ . '/../../fixture/themes/'; } function testInitialize() From f779e032a7b02b0a644caf63da8fd4f331108bb3 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 11:30:15 +0700 Subject: [PATCH 022/357] Validate composer --- src/Pingpong/Oembed/composer.json | 2 +- src/Pingpong/Trusty/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Oembed/composer.json b/src/Pingpong/Oembed/composer.json index aa23c815..6e783cc3 100644 --- a/src/Pingpong/Oembed/composer.json +++ b/src/Pingpong/Oembed/composer.json @@ -26,7 +26,7 @@ }, "autoload": { "psr-4": { - "Pingpong\\Oembed": "" + "Pingpong\\Oembed\\": "" } }, "minimum-stability": "stable" diff --git a/src/Pingpong/Trusty/composer.json b/src/Pingpong/Trusty/composer.json index 94df542e..144b7ed4 100644 --- a/src/Pingpong/Trusty/composer.json +++ b/src/Pingpong/Trusty/composer.json @@ -27,7 +27,7 @@ }, "autoload": { "psr-4": { - "Pingpong\\Trusty": "" + "Pingpong\\Trusty\\": "" } }, "minimum-stability": "stable" From e8c244c8cb081720d1737fa61567b9120d58b738 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 12:27:55 +0700 Subject: [PATCH 023/357] Remove publish:config command --- Providers/ConsoleServiceProvider.php | 1 - .../Modules/Commands/PublishConfigCommand.php | 44 ------------------- 2 files changed, 45 deletions(-) delete mode 100644 src/Pingpong/Modules/Commands/PublishConfigCommand.php diff --git a/Providers/ConsoleServiceProvider.php b/Providers/ConsoleServiceProvider.php index 85feff7f..05c98e8f 100644 --- a/Providers/ConsoleServiceProvider.php +++ b/Providers/ConsoleServiceProvider.php @@ -48,7 +48,6 @@ class ConsoleServiceProvider extends ServiceProvider { 'Update', 'Use', 'Dump', - 'PublishConfig', ]; /** diff --git a/src/Pingpong/Modules/Commands/PublishConfigCommand.php b/src/Pingpong/Modules/Commands/PublishConfigCommand.php deleted file mode 100644 index ccfe5070..00000000 --- a/src/Pingpong/Modules/Commands/PublishConfigCommand.php +++ /dev/null @@ -1,44 +0,0 @@ -laravel['files']->copy($path, $destinationPath); - - $this->info("Config file published successfully."); - } - else - { - $this->error("File : {$destinationPath} already exist!"); - } - } - -} From 78f34f3332a136b82481e171f526715b5288932f Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 12:33:37 +0700 Subject: [PATCH 024/357] Fix some config stuff --- Commands/SetupCommand.php | 4 ++-- Generators/ModuleGenerator.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Commands/SetupCommand.php b/Commands/SetupCommand.php index 0603de09..d14727ae 100644 --- a/Commands/SetupCommand.php +++ b/Commands/SetupCommand.php @@ -35,7 +35,7 @@ public function fire() */ public function generateModulesFolder() { - $this->generateDirectory($this->laravel['config']->get('modules::paths.modules'), + $this->generateDirectory($this->laravel['modules']->config('paths.modules'), 'Modules directory created successfully', 'Modules directory already exist' ); @@ -46,7 +46,7 @@ public function generateModulesFolder() */ public function generateAssetsFolder() { - $this->generateDirectory($this->laravel['config']->get('modules::paths.assets'), + $this->generateDirectory($this->laravel['modules']->config('paths.assets'), 'Assets directory created successfully', 'Assets directory already exist' ); diff --git a/Generators/ModuleGenerator.php b/Generators/ModuleGenerator.php index e56d75ba..580755ff 100644 --- a/Generators/ModuleGenerator.php +++ b/Generators/ModuleGenerator.php @@ -291,7 +291,7 @@ protected function getStubContents($stub) */ public function getReplacements() { - return $this->config->get('modules::stubs.replacements'); + return $this->module->config('stubs.replacements'); } /** @@ -302,7 +302,7 @@ public function getReplacements() */ protected function getReplacement($stub) { - $replacements = $this->config->get('modules::stubs.replacements'); + $replacements = $this->module->config('stubs.replacements'); if ( ! isset($replacements[$stub])) return []; From 6744a5c1d33789919c14b4e6e21e8040c026d85c Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 14:11:05 +0700 Subject: [PATCH 025/357] Fix config path --- ModulesServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModulesServiceProvider.php b/ModulesServiceProvider.php index bfbb3a62..4df5729d 100644 --- a/ModulesServiceProvider.php +++ b/ModulesServiceProvider.php @@ -50,7 +50,7 @@ public function register() */ protected function registerNamespaces() { - $configPath = __DIR__.'/../../../src/config/config.php'; + $configPath = __DIR__.'/src/config/config.php'; $this->mergeConfigFrom($configPath, 'modules'); $this->publishes([$configPath => config_path('modules.php')]); } From fb7476ecb17d16ac95fce0d72668d4d1b724d30a Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 14:34:07 +0700 Subject: [PATCH 026/357] Ignore some stuff --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e25d85bf..0c920b07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .idea /vendor/ composer.phar -composer.lock \ No newline at end of file +composer.lock +/fixture/storage +/fixture/.env \ No newline at end of file From 42ccf0eb19c96270b4531b9e652e373c48bd30a8 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 14:35:06 +0700 Subject: [PATCH 027/357] Update branch --- build/pull.sh | 24 ++++++++++++------------ build/push.sh | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/pull.sh b/build/pull.sh index efda23e0..637e159b 100755 --- a/build/pull.sh +++ b/build/pull.sh @@ -1,14 +1,14 @@ #!/bin/sh -git pull origin master -git subtree pull --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git master -git subtree pull --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git master -git subtree pull --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git master -git subtree pull --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git master -git subtree pull --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git master -git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git master -git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master -git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master -git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master -git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master -git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git master \ No newline at end of file +git pull origin 1.0 +git subtree pull --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git 1.0 +git subtree pull --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git 1.0 +git subtree pull --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git 1.0 +git subtree pull --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git 1.0 +git subtree pull --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git 1.0 +git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git 1.0 +git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git 1.0 +git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 1.0 +git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 1.0 +git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 1.0 +git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 1.0 \ No newline at end of file diff --git a/build/push.sh b/build/push.sh index 7026ebd0..48bac68d 100755 --- a/build/push.sh +++ b/build/push.sh @@ -1,14 +1,14 @@ #!/bin/sh -git push origin master -git subtree push --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git master -git subtree push --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git master -git subtree push --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git master -git subtree push --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git master -git subtree push --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git master -git subtree push --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git master -git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git master -git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git master -git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git master -git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git master -git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git master \ No newline at end of file +git push origin 1.0 +git subtree push --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git 1.0 +git subtree push --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git 1.0 +git subtree push --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git 1.0 +git subtree push --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git 1.0 +git subtree push --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git 1.0 +git subtree push --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git 1.0 +git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git 1.0 +git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 1.0 +git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 1.0 +git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 1.0 +git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 1.0 \ No newline at end of file From 3eb6e10f55d0336ae8bfa67d46164d744b9d3d69 Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 5 Feb 2015 14:51:00 +0700 Subject: [PATCH 028/357] Fix autoload path --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf51f65c..ae149aec 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "autoload": { "psr-4": { - "Pingpong\\Modules\\": "src/Pingpong/Modules" + "Pingpong\\Modules\\": "" } }, "autoload-dev": { From 459f011abf3e6f5aef18572a9fa3b4e9becfc53b Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 6 Feb 2015 23:08:40 +0700 Subject: [PATCH 029/357] Add custom namespace script --- Commands/stubs/start.stub | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Commands/stubs/start.stub b/Commands/stubs/start.stub index 8ce075d0..d937406a 100644 --- a/Commands/stubs/start.stub +++ b/Commands/stubs/start.stub @@ -9,4 +9,8 @@ | */ +Lang::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/views'); + +View::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/views'); + require __DIR__ . '/Http/routes.php'; \ No newline at end of file From 5b7fab7a1a3760b3970904e9848479c4e833c566 Mon Sep 17 00:00:00 2001 From: memeq1 Date: Sat, 7 Feb 2015 11:05:40 +0100 Subject: [PATCH 030/357] Correct path lang --- Commands/stubs/start.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commands/stubs/start.stub b/Commands/stubs/start.stub index d937406a..a7b10bc6 100644 --- a/Commands/stubs/start.stub +++ b/Commands/stubs/start.stub @@ -9,8 +9,8 @@ | */ -Lang::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/views'); +Lang::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/lang'); View::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/views'); -require __DIR__ . '/Http/routes.php'; \ No newline at end of file +require __DIR__ . '/Http/routes.php'; From 42839b3acf1103457f515d057d86a00d96b91e1f Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 10:37:54 +0700 Subject: [PATCH 031/357] Fix generator path for service provider --- Commands/GenerateProviderCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/GenerateProviderCommand.php b/Commands/GenerateProviderCommand.php index 35906c37..6da048f5 100644 --- a/Commands/GenerateProviderCommand.php +++ b/Commands/GenerateProviderCommand.php @@ -54,7 +54,7 @@ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $generatorPath = $this->laravel['modules']->get('paths.generator.provider'); + $generatorPath = $this->laravel['modules']->config('paths.generator.provider'); return $path . $generatorPath . '/' . $this->getFileName() . '.php'; } From 933d95964746fcc442652c40cf839e7bd257ed42 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 10:43:36 +0700 Subject: [PATCH 032/357] get a studly case name --- Traits/ModuleCommandTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Traits/ModuleCommandTrait.php b/Traits/ModuleCommandTrait.php index 638d285f..408bf98a 100644 --- a/Traits/ModuleCommandTrait.php +++ b/Traits/ModuleCommandTrait.php @@ -15,7 +15,7 @@ public function getModuleName() $module = $this->laravel['modules']->findOrFail($module); - return $module->getName(); + return $module->getStudlyName(); } } \ No newline at end of file From 0187a8f1a8e6e9ff3686468c7c6b76945b5c8bc2 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 10:48:21 +0700 Subject: [PATCH 033/357] Update comment --- Commands/stubs/start.stub | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Commands/stubs/start.stub b/Commands/stubs/start.stub index a7b10bc6..46cf7258 100644 --- a/Commands/stubs/start.stub +++ b/Commands/stubs/start.stub @@ -2,10 +2,13 @@ /* |-------------------------------------------------------------------------- -| Register The Routes File +| Register Namespaces And Routes |-------------------------------------------------------------------------- | -| This file will loaded automatically. +| When a module starting, this file will executed automatically. This helps +| to register some namespaces like translator or view. Also this file +| will load the routes file for each module. You may also modify +| this file as you want. | */ From 3c28fa0ffa262f9db253211d4a7c5ad75b18e8a8 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:17:21 +0700 Subject: [PATCH 034/357] Remove docs license --- docs/LICENSE | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 docs/LICENSE diff --git a/docs/LICENSE b/docs/LICENSE deleted file mode 100644 index ae2ab01a..00000000 --- a/docs/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2015, Pingpong Labs -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of docs nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - From 155ee7be07a3acef7ee953b50861e65126f4ee58 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:17:28 +0700 Subject: [PATCH 035/357] Update doc readme --- docs/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 38f9be78..de2e2029 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,2 +1,3 @@ -# docs +# Pingpong Labs Documentation + All Packages Documentation From c511d8ec1cd2e21cb199c1348a47ed12f6f64af9 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:19:19 +0700 Subject: [PATCH 036/357] Add generators.md --- docs/generators.md | 112 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 docs/generators.md diff --git a/docs/generators.md b/docs/generators.md new file mode 100644 index 00000000..6f8924c5 --- /dev/null +++ b/docs/generators.md @@ -0,0 +1,112 @@ +Laravel Generators by Pingpong Labs +========== + +[![Build Status](https://travis-ci.org/pingpong-labs/generators.svg)](https://travis-ci.org/pingpong-labs/generators) +[![Latest Stable Version](https://poser.pugx.org/pingpong/generators/v/stable.svg)](https://packagist.org/packages/pingpong/generators) +[![Total Downloads](https://poser.pugx.org/pingpong/generators/downloads.svg)](https://packagist.org/packages/pingpong/generators) +[![Latest Unstable Version](https://poser.pugx.org/pingpong/generators/v/unstable.svg)](https://packagist.org/packages/pingpong/generators) +[![License](https://poser.pugx.org/pingpong/generators/license.svg)](https://packagist.org/packages/pingpong/generators) + +### Quick Installation Via Composer + +``` +composer require "pingpong/generators:1.*" +``` + +Next, register new service provider to `providers` array in `app/config/app.php`. + +```php +'Pingpong\Generators\GeneratorsServiceProvider' +``` + +Done. + +### Documentation + +**Generate a new controller** + +```php +$path = app_path('controllers'); + +$generator = new Pingpong\Generators\ControllerGenerator($path, 'HomeController'); + +$generator->generate(); +``` + +You may also set the namespace for the class by specify the `namespace` key in the `options` array. The `options` array is the third argument in the generator class. For example : + +```php +$options = ['namespace' => 'App\\Controllers']; + +$generator = new Pingpong\Generators\ControllerGenerator($path, 'HomeController', $options); + +$generator->generate(); +``` + +**Generate a new model** + +```php +$generator = new Pingpong\Generators\ModelGenerator($path, 'User'); + +$generator->generate(); +``` + +**Generate a new seed** + +```php +$generator = new Pingpong\Generators\SeedGenerator($path, 'UsersTableSeeder'); + +$generator->generate(); +``` + +**Generate a new filter** + +```php +$generator = new Pingpong\Generators\FilterGenerator($path, 'AdminFilter'); + +$generator->generate(); +``` + +**Generate a new form request** + +```php +$generator = new Pingpong\Generators\FormRequestGenerator($path, 'LoginRequest'); + +$generator->generate(); +``` + +**Generate a new command** + +```php +$generator = new Pingpong\Generators\CommandGenerator($path, 'FooCommand'); + +$generator->generate(); +``` + +**Generate a new service provider** + +```php +$generator = new Pingpong\Generators\ProviderGenerator($path, 'BarServiceProvider'); + +$generator->generate(); +``` + +**Generate a new migration** + +```php +use Pingpong\Generate\MigrationGenerator; + +$generator = new MigrationGenerator($path, 'create_users_table'); + +$generator = new MigrationGenerator($path, 'create_users_table', 'name:string, username:string'); + +$generator = new MigrationGenerator($path, 'add_remember_token_to_users_table', 'remember_token:string:nullable'); + +$generator = new MigrationGenerator($path, 'remove_username_from_users_table', 'username:string'); + +$generator = new MigrationGenerator($path, 'drop_users_table', 'name:string, username:string'); +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file From 1c072dac1647722bb97f0ec90f2600e496086eb1 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:21:57 +0700 Subject: [PATCH 037/357] Add nav links --- docs/generators.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/generators.md b/docs/generators.md index 6f8924c5..9a0f9298 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -7,6 +7,10 @@ Laravel Generators by Pingpong Labs [![Latest Unstable Version](https://poser.pugx.org/pingpong/generators/v/unstable.svg)](https://packagist.org/packages/pingpong/generators) [![License](https://poser.pugx.org/pingpong/generators/license.svg)](https://packagist.org/packages/pingpong/generators) +- [Installation](#quick-installation-via-composer) +- [Documentation](#documentation) +- [License](#license) + ### Quick Installation Via Composer ``` From ac522ce7afe75bcfcffe0fdb1ac273aec4c2808b Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:25:04 +0700 Subject: [PATCH 038/357] Add testing.md --- docs/testing.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs/testing.md diff --git a/docs/testing.md b/docs/testing.md new file mode 100644 index 00000000..bfa051c9 --- /dev/null +++ b/docs/testing.md @@ -0,0 +1,87 @@ +Unit Testing Helper for Laravel's Package +========= + +[![Build Status](https://travis-ci.org/pingpong-labs/testing.svg)](https://travis-ci.org/pingpong-labs/testing) + +- [Installation](#quick-installation-via-composer) +- [Example Usage](#example-usage) +- [License](#license) + +### Quick Installation Via Composer + +``` +composer require "pingpong/testing:1.*" +``` + +### Example Usage + +Your First Test. + +```php +use Pingpong\Testing\TestCase; + +class LoginControllerTest extends TestCase { + + public function testGetLogin() + { + $this->call('GET', '/login'); + $this->assertResponseOk(); + } +} +``` + +Register The Package's Providers And Aliases. + +```php +use Pingpong\Testing\TestCase; + +class MasterTestCase extends TestCase { + + public function getPackageAliases() + { + return [ + 'Sample' => 'Vendor\Sample\Facades\Sample' + ]; + } + + public function getPackageProviders() + { + return [ + 'Vendor\Sample\SampleServiceProvider' + ]; + } +} +``` + +Register custom booted callback. + +```php +use Pingpong\Testing\TestCase; + +class MasterTestCase extends TestCase { + + protected function registerBootedCallback($app) + { + include __DIR__ . '/../routes.php'; + } +} +``` + +Setup Your Application Timezone. + +```php + +use Pingpong\Testing\TestCase; + +class MasterTestCase extends TestCase { + + protected function getApplicationTimezone() + { + return 'Asia/Jakarta'; + } +} +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) From ef0903fb3bbc8a8304ac58503571f03835a084df Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:30:16 +0700 Subject: [PATCH 039/357] Add shortcode doc --- docs/shortcode.md | 144 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 docs/shortcode.md diff --git a/docs/shortcode.md b/docs/shortcode.md new file mode 100644 index 00000000..04ac7940 --- /dev/null +++ b/docs/shortcode.md @@ -0,0 +1,144 @@ +Laravel Shortcode +========= + +[![Build Status](https://travis-ci.org/pingpong-labs/shortcode.svg?branch=master)](https://travis-ci.org/pingpong-labs/shortcode) +[![Latest Stable Version](https://poser.pugx.org/pingpong/shortcode/v/stable.png)](https://packagist.org/packages/pingpong/shortcode) [![Total Downloads](https://poser.pugx.org/pingpong/shortcode/downloads.png)](https://packagist.org/packages/pingpong/shortcode) [![Latest Unstable Version](https://poser.pugx.org/pingpong/shortcode/v/unstable.png)](https://packagist.org/packages/pingpong/shortcode) [![License](https://poser.pugx.org/pingpong/shortcode/license.png)](https://packagist.org/packages/pingpong/shortcode) +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pingpong-labs/shortcode/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + +- [Server Requirements](#server-requirements) +- [Installation](#installation) +- [Registering Shorcode](#registering-shorcode) +- [License](#license) + +### Server Requirements + +- PHP 5.4.0 or higher. + +### Installation +Open your composer.json file, and add the new required package. + +``` + "pingpong/shortcode": "1.0.*" +``` + +Next, open a terminal and run. + +``` + composer update +``` + +After the composer updated. Add new service provider in app/config/app.php. + +``` + 'Pingpong\Shortcode\ShortcodeServiceProvider' +``` + +Add new Facade alias. +```php +'Shortcode' => 'Pingpong\Shortcode\Facades\Shortcode', +``` + +Done. + +### Registering Shorcode + +Using closure: +```php +Shortcode::register('a', function($attr, $content = null, $name = null) +{ + $text = Shortcode::compile($content); + return ''. $text .''; +}); +``` + +Using class name. +```php + +class DivShortcode +{ + public function register($attr, $content = null, $name = null) + { + $text = Shortcode::compile($content); + return ''. $text .''; + } +} + +Shortcode::register('div', 'DivShortcode'); +``` + +Using class name with the specified method. +```php + +class HTMLShortcode +{ + public function img($attr, $content = null, $name = null) + { + $src = array_get($attr, 'src'); + $text = Shortcode::compile($content); + return ''; + } +} + + +Shortcode::register('img', 'HTMLShortcode@img'); +``` + +Using callback array. +```php + +class SpanShortcode +{ + + public function div($attr, $content = null, $name = null) + { + $text = Shortcode::compile($content); + return ''. $text .''; + } +} + +Shortcode::register('span', array('SpanShortcode', 'span')); +``` + +Using function name. +```php +function smallTag($attr, $content = null, $name = null) +{ + $text = Shortcode::compile($content); + return ''. $text .''; +} + +Shortcode::register('small', 'smallTag'); +``` + +### Compile + +```php +$text = '[a href="#"]Click here[/a]'; +echo Shortcode::compile($text); + +$text = ' +[a href="#"] + [img src="http://placehold.it/140x140"] + [small]This is small text[/small] +[/a] +'; +echo Shortcode::compile($text); +``` + +### Unregister The Specified Shortcode + +```php +Shortcode::unregister('img'); +``` + +### Destroy All Shortcodes + +```php +Shortcode::destroy(); +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) + +This package also adopted a system of wordpress shortcodes. Please see or read [the license](http://wordpress.org/about/license/) of wordpress also [here](http://codex.wordpress.org/License). \ No newline at end of file From c0cc01b701932e2b1bae3fb824982f73cb13eeeb Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:30:55 +0700 Subject: [PATCH 040/357] Add trusty doc --- docs/trusty.md | 252 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 docs/trusty.md diff --git a/docs/trusty.md b/docs/trusty.md new file mode 100644 index 00000000..ee8fed0a --- /dev/null +++ b/docs/trusty.md @@ -0,0 +1,252 @@ +## Trusty - Roles and Permissions for Laravel 4 + +[![Build Status](https://travis-ci.org/pingpong-labs/trusty.svg?branch=master)](https://travis-ci.org/pingpong-labs/trusty) + +### Server Requirements + +- PHP 5.4 or higher + +### Installation + +Open your composer.json file, and add the new required package. +``` +"pingpong/trusty": "1.0.*" +``` +Next, open a terminal and run. +``` +composer update +``` + +Next, Add new service provider in `app/config/app.php`. + +```php + 'Pingpong\Trusty\TrustyServiceProvider', +``` + +Next, Add new aliases in `app/config/app.php`. + +```php +'Trusty' => 'Pingpong\Trusty\Facades\Trusty', +'Role' => 'Pingpong\Trusty\Entities\Role', +'Permission' => 'Pingpong\Trusty\Entities\Permission', +``` + +Next, migrate the database. +``` +php artisan migrate --package=pingpong/trusty +``` + +**NOTE:** If you want to modify the `roles` and `permissions` table, you can publish the migration. + +Done. + +### Usage + +Open your `app/models/User.php` file and use the `Pingpong\Trusty\Traits\TrustyTrait` trait. Look like this. + +```php + +``` + +Creating new Role. +```php +Role::create([ + 'name' => 'Administrator', + 'slug' => Str::slug('Administrator', '_'), + 'description' => 'The Super Administrator' +]); + +// without description +Role::create([ + 'name' => 'Editor', + 'slug' => Str::slug('Editor', '_'), +]); +``` + +Creating new Permission. + +```php +Permission::create([ + 'name' => 'Manage Users', + 'slug' => Str::slug('Manage Users', '_'), // manage_users + 'description' => 'Create, Read, Update and Delete Users' +]); + +// without description +Permission::create([ + 'name' => 'Manage Posts', + 'slug' => Str::slug('Manage Posts', '_'), // manage_posts +]); +``` + +Set permission for the specified role. + +```php +$permission_id = 1; +$role = Role::findOrFail(1); +$role->permissions()->attach($permission_id); +``` + +Set role for current user. +```php +$role_id = 1; +$user = Auth::user(); +$user->roles()->attach($role_id); +``` + +Adding role to the user. +```php +Auth::user()->addRole(1); +``` + +Updating role user. +```php +$role_id = 1; +Auth::user()->updateRole($role_id); +``` + +Check role for current user. +```php +if(Auth::user()->is('administrator')) +{ + // your code here +} +``` + +Or using magic method. +```php +if(Auth::user()->isAdministrator()) +{ + // your code +} +``` + +Check permission for current user. +```php +if(Auth::user()->can('manage_users')) +{ + // your code here +} +``` + +Or using magic method. +```php +if(Auth::user()->canManageUsers()) +{ + // your code here +} +``` + +Check permissions against a role. +```php +$role = Role::findOrFail(1); + +if ($role->can('manage_users')) +{ + // your code here +} +``` + +Or using magic method. +```php +$role = Role::findOrFail(1); + +if($role->canManageUsers()) +{ + // your code here +} +``` + +Get all permission from current users. +```php +$myPermissions = Auth::user()->getPermissions(); +dd($myPermissions); + +// or + +$permissions = Auth::user()->permissions(); +dd($permissions); +``` + +Get role for current user. +```php +$myRole = Auth::user()->getRole(); +``` + +Simple filtering route based on permission. +```php + +// register all permission as filter +Trusty::registerPermissions(); + +// filter request +Trusty::when('admin/*', 'filter_name'); + +// mutiple request +Trusty::when(['admin/users', 'admin/users/*'], 'manage_users'); +``` + +Abort the user if that user have not a specify permission. +```php +Trusty::forbidden(); +``` + +Maybe you can do something like this. +```php +if( ! Auth::user()->canManageUsers()) +{ + Trusty::forbidden(); +} +``` + +When you run `forbidden` method, that's will throw an exception. You can handle this exception using Laravel error handler feature. You can do something like this. + +```php +App::error(function(Pingpong\Trusty\Exceptions\ForbiddenException $e) +{ + return Response::make($e->getMessage(), 403); +}); +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) + + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pingpong-labs/trusty/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + From 0d205600755f5cbe2ab49c58241e53ad664e994e Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:31:16 +0700 Subject: [PATCH 041/357] Add widget doc --- docs/widget.md | 225 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 docs/widget.md diff --git a/docs/widget.md b/docs/widget.md new file mode 100644 index 00000000..cee81d3c --- /dev/null +++ b/docs/widget.md @@ -0,0 +1,225 @@ +Simple Widget System for Laravel Framework +================================== + +[![Build Status](https://travis-ci.org/pingpong-labs/widget.svg?branch=master)](https://travis-ci.org/pingpong-labs/widget) +[![Latest Stable Version](https://poser.pugx.org/pingpong/widget/v/stable.svg)](https://packagist.org/packages/pingpong/widget) [![Total Downloads](https://poser.pugx.org/pingpong/widget/downloads.svg)](https://packagist.org/packages/pingpong/widget) [![Latest Unstable Version](https://poser.pugx.org/pingpong/widget/v/unstable.svg)](https://packagist.org/packages/pingpong/widget) [![License](https://poser.pugx.org/pingpong/widget/license.svg)](https://packagist.org/packages/pingpong/widget) + +### Version Compability + + Laravel | Pingpong Widget | PHP +:---------|:-----------------|:---- + 4.x | 1.* |>= 5.3 + 5.0.x | 2.0.*@dev |>= 5.3 + +### Installation + +Open your composer.json file and add the new required package. + +``` + "pingpong/widget" : "1.*" +``` + +Next, open your terminal and run `composer update`. + +After composer updated, add new service provider in `app/config/app.php` : + +```php + 'Pingpong\Widget\WidgetServiceProvider', +``` + +And add facade in the same file + +```php + 'Widget' => 'Pingpong\Widget\Facades\Widget' +``` + +Done. + +### What's New! + +Subscribe widget: It's a new way to register widget using a specified class. For example: + +```php +Widget::subscribe('WidgetSubscriber'); + +class WidgetSubscriber { + + public function subscribe($widget) + { + $widget->register('image', __CLASS__ .'@image'); + } + + public function image() + { + return 'Your handler here'; + } +} +``` + +You can also specified which method to handle subscriber of widget. + +```php +Widget::subscribe('WidgetSubscriber@handle'); + +class WidgetSubscriber { + + public function handle($widget) + { + $widget->register('image', __CLASS__ .'@image'); + } + + public function image() + { + return 'Your handler here'; + } +} +``` + +### Registering A Widget + +By default you can register a widget in `app/widgets.php`, that file will autoload automatically. + +Via Closure. + +```php +// app/widgets.php + +Widget::register('small', function($contents) +{ + return "{$contents}"; +}); + +Widget::register('view', function($view, $data = array(), $mergeData = array() +{ + return View::make($view, $data, $mergeData)->render(); +}); + +``` + +Via Class Name. + +By default will call `register` method. + +```php +class MyWidget { + + public function register($contents, $attributes = array()) + { + $attributes = HTML::attributes($attributes); + + return "{$contents}"; + } + +} + +Widget::register('h1', 'MyWidget'); +``` + +Via Class Name with the specified method. + +```php + +class TagCreator { + + public function create($tag, $contents, $attributes = array()) + { + $attributes = HTML::attributes($attributes); + + return "<{$tag}{$attributes}>{$contents}"; + } + +} + +class HTMLWidget { + + protected $tag; + + public function __construct(TagCreator $tag) + { + $this->tag = $tag; + } + + public function p($contents, $attributes = array()) + { + return $this->tag->create('p', $contents, $attributes); + } + + public function div($contents, $attributes = array()) + { + return $this->tag->create('div', $contents, $attributes); + } +} +Widget::register('p', 'HTMLWidget@p'); + +Widget::register('div', 'HTMLWidget@div'); + +``` + +### Calling A Widget + +```php +Widget::get('small', array('My Content')); + +Widget::call('small', array('My Content')); + +Widget::small('My Content'); + +Widget::p('My Content'); + +Widget::div('My Content'); + +Widget::h1('My Content'); +``` + +On view you can call like this. + +``` +@small('My Content') + +@view('users.show', $data, $mergeData) + +@h1('Welcome!') + +@p('Hello World', array('class' => 'page-header')); + +@div('Lorem ipsum', array('class' => 'alert alert-warning')); +``` + +### Grouping A Widget + +It is very easy to group widget. you only need to specify the group name and specify an array of the names of the widgets that will be grouped. + +```php +Widget::register('calendar', 'SidebarWidget@calendar') + +Widget::register('archive', 'SidebarWidget@archive') + +Widget::group('sidebar', array('calendar', 'archive')); +``` + +To call a group of widgets is the same as calling the widget. + +```php +Widget::sidebar(); +``` + +If you want to send parameters to the widget that is in the group, you can call it like this. + +```php +Widget::sidebar( + array('your-first-param', 'your-second-param'), + array('first-param-for-second-widget', 'the-second') +); +``` + +On view you can call a group of widgets is same as calling the widget. + +``` +@sidebar() + +@sidebar(array('first-param'), array('first-param-for-second-widget')) +``` + +### License + +This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) From 16d2703968ae854151f9c4d2e1f40e703e96ecbf Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:31:50 +0700 Subject: [PATCH 042/357] Add validator doc --- docs/validator.md | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 docs/validator.md diff --git a/docs/validator.md b/docs/validator.md new file mode 100644 index 00000000..373df9f1 --- /dev/null +++ b/docs/validator.md @@ -0,0 +1,124 @@ +Simple Validator Class for Laravel +========= + +[![Build Status](https://travis-ci.org/pingpong-labs/validator.svg)](https://travis-ci.org/pingpong-labs/validator) + +### Quick Installation Via Composer + +``` +composer require "pingpong/validator:1.*" +``` + +### Example + +Your validator class must extends to `Pingpong\Validator\Validator` class. + +```php +use Pingpong\Validator\Validator; + +class RegisterValidator extends Validator { + + public function rules() + { + return [ + 'name' => 'required', + 'username' => 'required|unique:users,username', + 'email' => 'required|unique:users,email', + 'password' => 'required|min:6|max:20', + ]; + } + +} +``` + +Now, inject the validator class to your controller. + +```php + +class RegisterController extends BaseController { + + protected $validator; + + public function __construct(RegisterValidator $validator) + { + $this->validator = $validator; + } + + public function store() + { + $this->validator->validate(); + + $user = User::create($this->validator->getInput()); + + return Redirect::to('login'); + } + +} + +``` + +### Custom Validation Messages + +You can also specify the custom validation messages as you want. For example : + +```php +use Pingpong\Validator\Validator; + +class RegisterValidator extends Validator { + + public function rules() + { + return [ + 'name' => 'required' + ]; + } + + public function messages() + { + return [ + 'name.required' => 'Please enter your name', + ]; + } + +} +``` + +### Handling Failed Validation + +Handle one-by-one via validator class. +```php + +use Pingpong\Validator\Validator; + +class RegisterValidator extends Validator { + + public function rules() + { + return [ + 'name' => 'required', + 'username' => 'required|unique:users,username', + 'email' => 'required|unique:users,email', + 'password' => 'required|min:6|max:20', + ]; + } + + public function failed() + { + return Redirect::back()->withInput()->withErrors($this->getErrors()); + } + +} +``` + +Global handler. + +```php +App::error(function(Pingpong\Validator\Exceptions\ValidationException $e) +{ + return Redirect::back()->withInput()->withErrors($e->getErrors()); +}); +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file From 5495beb6fad34dad7622a33a61e68d534e3a646a Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:32:23 +0700 Subject: [PATCH 043/357] Add themes doc --- docs/themes.md | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 docs/themes.md diff --git a/docs/themes.md b/docs/themes.md new file mode 100644 index 00000000..fbc5c344 --- /dev/null +++ b/docs/themes.md @@ -0,0 +1,98 @@ +## Laravel Themes + +[![Build Status](https://travis-ci.org/pingpong-labs/themes.svg?branch=master)](https://travis-ci.org/pingpong-labs/themes) +[![Latest Stable Version](https://poser.pugx.org/pingpong/themes/v/stable.svg)](https://packagist.org/packages/pingpong/themes) [![Total Downloads](https://poser.pugx.org/pingpong/themes/downloads.svg)](https://packagist.org/packages/pingpong/themes) [![Latest Unstable Version](https://poser.pugx.org/pingpong/themes/v/unstable.svg)](https://packagist.org/packages/pingpong/themes) [![License](https://poser.pugx.org/pingpong/themes/license.svg)](https://packagist.org/packages/pingpong/themes) + +### Installation + +Open your composer.json file, and add the new required package. +``` + "pingpong/themes": "1.0.*" +``` +Next, open a terminal and run. +``` +composer update +``` + +Next, Add new service provider in `app/config/app.php`. + +```php + 'Pingpong\Themes\ThemesServiceProvider', +``` + +Next, Add new aliases in `app/config/app.php`. + +```php + 'Theme' => 'Pingpong\Themes\Facades\Theme', +``` + +Next, publish the asset. The asset is an example theme. +``` +php artisan asset:publish pingpong/themes +``` + +Done. + +### Usage + +Get all themes. +```php +Theme::all(); +``` + +Set theme active. +```php +Theme::set('default'); + +Theme::setCurrent('default'); +``` + +Get current theme active. +```php +Theme::getCurrent(); +``` + +Check theme. +```php +Theme::has('simple') + +Theme::exists('other-theme'); +``` + +Set theme path. +```php +$path = public_path('themes'); + +Theme::setPath($path); +``` + +Get theme path. +```php +Theme::getThemePath('default'); +``` + +Get themes path. +```php +Theme::getPath(); +``` + +Get view from current active theme. +```php +Theme::view('index'); + +Theme::view('folders.view'); +``` + +Get config from current active theme. +```php +Theme::config('group.name'); +``` + +Get lang from current active theme. +```php +Theme::lang('group.name'); +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) From 1ba23536d69348e7f88cb883d7b5527672953edc Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:32:55 +0700 Subject: [PATCH 044/357] Add presenters doc --- docs/presenters.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docs/presenters.md diff --git a/docs/presenters.md b/docs/presenters.md new file mode 100644 index 00000000..ae614a8c --- /dev/null +++ b/docs/presenters.md @@ -0,0 +1,65 @@ +View Presenter For Laravel +============================= + +[![Build Status](https://travis-ci.org/pingpong-labs/presenters.svg?branch=1.0.4)](https://travis-ci.org/pingpong-labs/presenters) + +### Installation + +Open your composer.json file, and add the new required package. + + "pingpong/presenters": "1.0.*" + +Next, open a terminal and run. + + composer update + +Done. + +### Example Usage + +First, create your own presenter and make sure that class is extends to `Pingpong\Presenters\Presenter` class. Like this. + +```php +resource->email, $this->resource->email, $attributes); + } +} +?> +``` + +Make sure your model/eloquent to extends `Pingpong\Presenters\Model` and set the presenter property to that model/eloquent. + +```php + +``` + +That's it! You're done. Now, within your view, you can do: + +```php +

Your email is {{ $user->present()->email }}

+``` + +Or, call the presenter as method. + +```php +

Your email is {{ $user->present()->email(['width' => 140]) }}

+``` + +### License + +This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) \ No newline at end of file From e976ac482fdac60082069e9a10fd3552a72ec289 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:33:19 +0700 Subject: [PATCH 045/357] Add oembed doc --- docs/oembed.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 docs/oembed.md diff --git a/docs/oembed.md b/docs/oembed.md new file mode 100644 index 00000000..512271ab --- /dev/null +++ b/docs/oembed.md @@ -0,0 +1,81 @@ +Oembed +====== + +Laravel 4 - Retrieve page info using oembed, opengraph, etc. + +[![Build Status](https://travis-ci.org/pingpong-labs/oembed.svg?branch=master)](https://travis-ci.org/pingpong-labs/oembed) + +### Server Requirements + + Require PHP 5.4+ or higher. + +### Installation + +Open your composer.json file, and add the new required package. + + "pingpong/oembed": "1.0.*" + +Next, open a terminal and run. + + composer update + +After the composer updated. Add new service provider in app/config/app.php. + +```php + 'Pingpong\Oembed\OembedServiceProvider' +``` + +Next, Add new alias. + +```php + 'Oembed' => 'Pingpong\Oembed\Facades\Oembed', +``` + +Done. + +### Usage + +Basic Usage + +```php +$info = Oembed::get('https://www.youtube.com/watch?v=PP1xn5wHtxE'); + +//Get content info + +$info->title; //The page title +$info->description; //The page description +$info->url; //The canonical url +$info->type; //The page type (link, video, image, rich) + +$info->images; //List of all images found in the page +$info->image; //The image choosen as main image +$info->imageWidth; //The with of the main image +$info->imageHeight; //The height of the main image + +$info->code; //The code to embed the image, video, etc +$info->width; //The with of the embed code +$info->height; //The height of the embed code +$info->aspectRatio; //The aspect ratio (width/height) + +$info->authorName; //The (video/article/image/whatever) author +$info->authorUrl; //The author url + +$info->providerName; //The provider name of the page (youtube, twitter, instagram, etc) +$info->providerUrl; //The provider url +$info->providerIcons; //All provider icons found in the page +$info->providerIcon; //The icon choosen as main icon +``` + +Caching the results. + +```php +$info = Oembed::cache($url, $options); +``` + +### Documentation + +Because this package using the library [oscarotero/Embed](https://github.com/oscarotero/Embed), please refer to its documentation for more info. + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) From 4d17d8e4e01dee621b025c4222abf988c5fd0624 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 12:33:51 +0700 Subject: [PATCH 046/357] Add menus doc --- docs/menus.md | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 docs/menus.md diff --git a/docs/menus.md b/docs/menus.md new file mode 100644 index 00000000..df7d6c28 --- /dev/null +++ b/docs/menus.md @@ -0,0 +1,390 @@ +Laravel Menus +======================== + +[![Build Status](https://travis-ci.org/pingpong-labs/menus.svg)](https://travis-ci.org/pingpong-labs/menus) +[![Latest Stable Version](https://poser.pugx.org/pingpong/menus/v/stable.svg)](https://packagist.org/packages/pingpong/menus) [![Total Downloads](https://poser.pugx.org/pingpong/menus/downloads.svg)](https://packagist.org/packages/pingpong/menus) [![Latest Unstable Version](https://poser.pugx.org/pingpong/menus/v/unstable.svg)](https://packagist.org/packages/pingpong/menus) [![License](https://poser.pugx.org/pingpong/menus/license.svg)](https://packagist.org/packages/pingpong/menus) + +### Version Compability + + Laravel | Pingpong Menus | PHP +:---------|:---------------|:---- + 4.x | 1.x |>= 5.3 + 5.0.x | 2.*@dev |>= 5.4 + +### Installation + +First, open your `composer.json` file and add new package. +``` + "require": { + "pingpong/menus": "1.0.*" + }, +``` +Then open a terminal and run: +``` +composer update +``` +After that, open the file `app/config/app.php` and add a new service provider in `providers` array. +```php + + 'providers' => array( + + 'Illuminate\Foundation\Providers\ArtisanServiceProvider', + 'Illuminate\Auth\AuthServiceProvider', + ... + 'Illuminate\View\ViewServiceProvider', + 'Illuminate\Workbench\WorkbenchServiceProvider', + + // here + 'Pingpong\Menus\MenusServiceProvider' + + ), +``` +Then add the class alias in `aliases`. +```php + + 'aliases' => array( + + 'App' => 'Illuminate\Support\Facades\App', + 'Artisan' => 'Illuminate\Support\Facades\Artisan', + ... + 'Validator' => 'Illuminate\Support\Facades\Validator', + 'View' => 'Illuminate\Support\Facades\View', + + // here + 'Menu' => 'Pingpong\Menus\Facades\Menu', + ) +``` +Then, publish configuration for package `pingpong/menus`: +``` +php artisan config:publish pingpong/menus +``` +Done. + +### Screenshot + +![View Screenshot](https://raw.githubusercontent.com/pingpong-labs/menus/master/shots/multilevel-menu-pingpong.png) + +### Example Usage + +**NEW!** + +On `app/menus.php` : +```php + +// app/menus.php + +use Pingpong\Menus\Builder; +use Pingpong\Menus\MenuItem; + +Menu::create('top', function(Builder $menu) +{ + // simple using route + $menu->route('home', 'Home'); + // simple using route with parameters and attributes + $menu->route('profile.user', 'View Profile', ['username' => 'gravitano'], ['class' => 'btn btn-default']); + // using array + $menu->add([ + 'url' => 'messages', + 'title' => 'Messages', + 'icon' => 'fa fa-envelope' + ]); + // using url + $menu->url('products', 'Products'); + // using url with attributes + $menu->url('products/1', 'View Products', ['class' => 'btn btn-link']); + // new! support dropdown with multi level nested menu + $menu->dropdown('Settings', function(MenuItem $sub) + { + $sub->url('profile/edit', 'Edit Profile'); + $sub->dropdown('Account', function(MenuItem $sub) + { + $sub->url('settings/payment', 'Payment'); + // nested menu + $sub->dropdown('Social Network', function(MenuItem $sub) + { + $sub->url('https://github.com/gravitano', 'Github', ['target' => '_blank']); + $sub->url('https://facebook.com/warsono.m.faisyal', 'Facebook', ['target' => '_blank']); + $sub->url('https://twitter.com/gravitano', 'Twitter', ['target' => '_blank']); + }); + }); + $sub->url('logout', 'Logout'); + }); +}); +``` + +On view, for example `hello.blade.php`. +```html + + + + + Laravel PHP Framework + {{ HTML::style('css/bootstrap.css') }} + {{-- Add new style for allowing multi level menu --}} + {{ Menu::style() }} + + + +
+ {{ Menu::get('top') }} +
+ + {{ HTML::script('js/jquery.min.js') }} + {{ HTML::script('js/bootstrap.min.js') }} + + +``` + +First, create a file called `menus.php` in your `app/` folder, alongside with `routes.php` and `filters.php`. The file will be automatically include if the file exists. And you can define your menus in that file. + +**Creating a menu.** +```php +Menu::create('navbar', function($menu) +{ + // using array + $menu->add([ + 'route' => 'home', + 'title' => 'Home', + 'icon' => 'fa fa-dashboard' + ]); + + // menu with target to url + $menu->url('/', 'Home'); + + // with additional attributes + $menu->url('/', 'Home', ['class' => 'nav-link']); + + // menu with target to registered route + $menu->route('home', 'Home'); + + // with additional route parameters and attributes + $menu->route('home', 'Home', null, ['class' => 'nav-link']); + + $menu->route('users.show', Auth::user()->name, Auth::id(), ['class' => 'nav-link']); + + $menu->route('users.show', 'My Profile', ['username' => 'gravitano'], ['class' => 'nav-link']); + + $menu->route('products.show', 'View Product', 1, ['class' => 'nav-link']); + + // dropdown menu + $menu->dropdown('Settings', function($sub) + { + $sub->url('settings/account', 'Account'); + $sub->route('settings.profile', 'Profile'); + $sub->route('logout', 'Logout'); + }); + + // multi level menu (nested) + $menu->dropdown('Category', function($sub) + { + $sub->url('category/programming', 'Programming'); + + $sub->url('category/screencasts', 'Screencasts'); + + $sub->dropdown('Sport News', function($sub) + { + $sub->url('category/football', 'Football'); + $sub->url('category/basket-ball', 'Basket Ball'); + }); + + $sub->dropdown('Title', function($sub) + { + $sub->url('link', 'Link'); + $sub->dropdown('Title', function($sub) + { + $sub->dropdown('Title N', function($sub) + { + // more nested menu here + }); + }); + }); + }); +}); +```` + +**Make Lots of menu** + +This package allows you to create a menu with a lot of different styles. Here's an example. + +```php +Menu::create('menu1', function($menu) +{ + + $menu->route('home', 'Home'); + + $menu->url('profile', 'Profile'); +}); + +Menu::create('menu2', function($menu) +{ + $menu->route('home', 'Home'); + + $menu->url('profile', 'Profile'); +}); +``` + +**Calling a menu.** + +To call up the menu you can use `render` or `get` method. + +```php +Menu::render('navbar'); + +Menu::get('menu1'); + +Menu::get('menu2'); +``` + +**Menu Style.** + +By default the generated menu style is bootstrap navbar. In addition there are also several different menu styles and is already available by default are `navbar`, `navbar-right`, `nav-pills` and `nav-tab`. To set the style menu you can use the method `style`. Examples like this. + +```php +Menu::create('navbar', function($menu) +{ + $menu->style('nav-pills'); + + $menu->route('home', 'Home'); + + $menu->url('profile', 'Profile'); +}); +``` + +**Make A Costum Presenter** + +You can create your own presenter class. Make sure your presenter is extends to `Pingpong\Menus\Presenters\Presenter`, that class is also `implements` to 'Pingpong\Menus\Presenters\PresenterInterface'. For example this is zurb topbar presenter. + +```php + +use Pingpong\Menus\Presenters\Presenter; + +class ZurbTopBarPresenter extends Presenter +{ + /** + * {@inheritdoc } + */ + public function getOpenTagWrapper() + { + return PHP_EOL . '
' . PHP_EOL; + } + + /** + * {@inheritdoc } + */ + public function getCloseTagWrapper() + { + return PHP_EOL . '
' . PHP_EOL; + } + + /** + * {@inheritdoc } + */ + public function getMenuWithoutDropdownWrapper($item) + { + return 'getActiveState($item).'>'.$item->getIcon().' '.$item->title.''; + } + + /** + * {@inheritdoc } + */ + public function getActiveState($item) + { + return \Request::is($item->getRequest()) ? ' class="active"' : null; + } + + /** + * {@inheritdoc } + */ + public function getDividerWrapper() + { + return '
  • '; + } + + /** + * {@inheritdoc } + */ + public function getMenuWithDropDownWrapper($item) + { + return '
  • + + '.$item->getIcon().' '.$item->title.' + + +
  • ' . PHP_EOL; + ; + } +} + +``` +For use costum presenter, you can use the `setPresenter` method, for example like this. +```php +Menu::create('zurb-top-bar', function($menu) +{ + $menu->setPresenter('ZurbTopBarPresenter'); + + $menu->route('home', 'Home'); + + $menu->url('profile', 'Profile'); +}); +``` + +Or you can set it at the time of calling the menu, like this. + +```php +Menu::render('zurb-top-bar', 'ZurbTopBarPresenter'); + +Menu::get('zurb-top-bar', 'ZurbTopBarPresenter'); +``` + +**Register A New Style Menu** + +This Style is like an alias to a presenter. You can register your style from your costum presenter in the configuration file in `app/config/packages/pingpong/menus/config.php`. Like this. + +```php +return array( + 'navbar' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarPresenter', + 'navbar-right' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarRightPresenter', + 'nav-pills' => 'Pingpong\Menus\Presenters\Bootstrap\NavPillsPresenter', + 'nav-tab' => 'Pingpong\Menus\Presenters\Bootstrap\NavTabPresenter', + + 'zurb-top-bar' => 'ZurbTopBarPresenter', +); +``` + +Then you can use a style like this. Same as section **Menu Style** above. + +```php +Menu::create('zurb-top-bar', function($menu) +{ + $menu->style('zurb-top-bar'); + $menu->add([ + 'route' => 'home', + 'title' => 'Home', + ]); + $menu->url('profile', 'Profile'); + + $menu->route('settings', 'Settings'); +}); +``` + +**Get The Menu Instance** + +To get an instance of an existing menu, you can use the `instance` method. Here's an example. + +```php +$menu = Menu::instance('zurb-top-bar'); + +// You can also make additions to the menu again + +$menu->add(['title' => 'Settings', 'route' => 'settings']); + +$menu->url('profile', 'Profile'); + +$menu->route('settings', 'Settings'); +``` + +### License + +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file From 7bc15a986ab75c9b2056a94734ab9b6ddb38beb1 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 10 Feb 2015 14:59:53 +0700 Subject: [PATCH 047/357] Sync docs --- build/pull.sh | 3 ++- build/push.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/pull.sh b/build/pull.sh index 51c6f53e..bfea38a1 100755 --- a/build/pull.sh +++ b/build/pull.sh @@ -11,4 +11,5 @@ git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/g git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 -git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 \ No newline at end of file +git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 +git subtree pull --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 \ No newline at end of file diff --git a/build/push.sh b/build/push.sh index 7a76d75e..3efba986 100755 --- a/build/push.sh +++ b/build/push.sh @@ -11,4 +11,5 @@ git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/g git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 -git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 \ No newline at end of file +git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 +git subtree push --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 \ No newline at end of file From 69a310e462167cbf79a4483c2347775f3ca4664b Mon Sep 17 00:00:00 2001 From: gravitano Date: Thu, 12 Feb 2015 13:57:32 +0700 Subject: [PATCH 048/357] Update version & status --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fc95a24..cea4775d 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Laravel | Pingpong Sky | PHP | Status :---------|:-----------------|:-------|:-------- - 4.x | dev-master |>= 5.4 | Ready - 5.0.x | 2.0.*@dev |>= 5.4 | Planned + 4.x | 1.*@dev |>= 5.4 | Ready + 5.0.x | 2.0.*@dev |>= 5.4 | Ready ### Documentation From e00927f51798d86d7d649b153b313ef30514032a Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 07:21:28 +0700 Subject: [PATCH 049/357] Fix namespace --- src/Pingpong/Shortcode/ShortcodeFacade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Shortcode/ShortcodeFacade.php b/src/Pingpong/Shortcode/ShortcodeFacade.php index 3caf87b4..10629288 100644 --- a/src/Pingpong/Shortcode/ShortcodeFacade.php +++ b/src/Pingpong/Shortcode/ShortcodeFacade.php @@ -1,4 +1,4 @@ - Date: Fri, 13 Feb 2015 07:21:49 +0700 Subject: [PATCH 050/357] Add facade test for shortcode --- tests/Shortcode/FacadeTest.php | 29 +++++++++++++++++++++++++++++ tests/Shortcode/ShortcodeTest.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/Shortcode/FacadeTest.php diff --git a/tests/Shortcode/FacadeTest.php b/tests/Shortcode/FacadeTest.php new file mode 100644 index 00000000..a0c1b1c3 --- /dev/null +++ b/tests/Shortcode/FacadeTest.php @@ -0,0 +1,29 @@ + 'Pingpong\Shortcode\ShortcodeFacade']; + } + + protected function getPackageProviders() + { + return ['Pingpong\Shortcode\ShortcodeServiceProvider']; + } + +} + +class FacadeTest extends ShortcodeTestCase { + + public function testUsingFacade() + { + Shortcode::register('foo', function () + { + return 'bar'; + }); + + $this->assertEquals('foo', Shortcode::compile('foo')); + } + +} \ No newline at end of file diff --git a/tests/Shortcode/ShortcodeTest.php b/tests/Shortcode/ShortcodeTest.php index 89ce2ef1..785f63a6 100644 --- a/tests/Shortcode/ShortcodeTest.php +++ b/tests/Shortcode/ShortcodeTest.php @@ -118,4 +118,4 @@ function testRegisterShortcodeUsingClasses() $this->assertEquals($exceptedImg, $shortcode->compile('[img src="#"]')); } -} +} \ No newline at end of file From c709ce570e3ab140dbd2dd20155b0a3376888b0c Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 07:36:27 +0700 Subject: [PATCH 051/357] Ignore some file & folder --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e25d85bf..f4ffdcf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -.idea +/.idea /vendor/ +/fixture/storage +.env composer.phar composer.lock \ No newline at end of file From 0122ab5528a63f81b6cc3c5d202dc266dd43870f Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 07:45:42 +0700 Subject: [PATCH 052/357] Fix conflict & update heading level --- docs/oembed.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/oembed.md b/docs/oembed.md index 6457b04b..5939d9fe 100644 --- a/docs/oembed.md +++ b/docs/oembed.md @@ -1,11 +1,10 @@ # Laravel Oembed Retrieve page info using oembed, opengraph, etc. ->>>>>>> 01c197cd4fba96d40ce84fc6ff630cf97662ca3b [![Build Status](https://travis-ci.org/pingpong-labs/oembed.svg?branch=master)](https://travis-ci.org/pingpong-labs/oembed) -### Installation +## Installation Open your composer.json file, and add the new required package. @@ -29,7 +28,7 @@ Next, Add new alias. Done. -### Usage +## Usage Basic Usage @@ -68,10 +67,10 @@ Caching the results. $info = Oembed::cache($url, $options); ``` -### Documentation +## Documentation Because this package using the library [oscarotero/Embed](https://github.com/oscarotero/Embed), please refer to its documentation for more info. -### License +## License This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) From b6458b2df3624806df925841cad123b731d93d6f Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 07:45:56 +0700 Subject: [PATCH 053/357] Fix facade class --- docs/oembed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/oembed.md b/docs/oembed.md index 5939d9fe..4fd97d10 100644 --- a/docs/oembed.md +++ b/docs/oembed.md @@ -23,7 +23,7 @@ After the composer updated. Add new service provider in app/config/app.php. Next, Add new alias. ```php - 'Oembed' => 'Pingpong\Oembed\Facades\Oembed', + 'Oembed' => 'Pingpong\Oembed\OembedFacade', ``` Done. From 17a85a29a8c23a9ff73483f5f380a3645bd972ab Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 07:46:31 +0700 Subject: [PATCH 054/357] Update heading level --- docs/presenters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/presenters.md b/docs/presenters.md index fc89b91a..40e52234 100644 --- a/docs/presenters.md +++ b/docs/presenters.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/pingpong-labs/presenters.svg?branch=1.0.4)](https://travis-ci.org/pingpong-labs/presenters) -### Installation +## Installation Open your composer.json file, and add the new required package. @@ -14,7 +14,7 @@ Next, open a terminal and run. Done. -### Example Usage +## Example Usage First, create your own presenter and make sure that class is extends to `Pingpong\Presenters\Presenter` class. Like this. From de160921c736bfc92b1011ae798d44c772f81743 Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 08:14:53 +0700 Subject: [PATCH 055/357] Add doc info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cea4775d..48313024 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ### Documentation -Coming soon +Documentation is located [here](http://sky.pingpong-labs.com). ### License From 77feca83cde09cff217218f55866f52f0f2d3b8e Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 08:15:46 +0700 Subject: [PATCH 056/357] Remove travis file --- src/Pingpong/Widget/.travis.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/Pingpong/Widget/.travis.yml diff --git a/src/Pingpong/Widget/.travis.yml b/src/Pingpong/Widget/.travis.yml deleted file mode 100644 index 9fc1e4c0..00000000 --- a/src/Pingpong/Widget/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer install --prefer-source --no-interaction --dev - -script: phpunit From 65c6465d13de79a9744099010bde0c561cb28297 Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 08:15:56 +0700 Subject: [PATCH 057/357] Fix namespace --- src/Pingpong/Widget/WidgetFacade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Widget/WidgetFacade.php b/src/Pingpong/Widget/WidgetFacade.php index 298d960b..aae49997 100644 --- a/src/Pingpong/Widget/WidgetFacade.php +++ b/src/Pingpong/Widget/WidgetFacade.php @@ -1,4 +1,4 @@ - Date: Fri, 13 Feb 2015 08:18:20 +0700 Subject: [PATCH 058/357] documentation moved to official website --- src/Pingpong/Widget/README.md | 227 +--------------------------------- 1 file changed, 3 insertions(+), 224 deletions(-) diff --git a/src/Pingpong/Widget/README.md b/src/Pingpong/Widget/README.md index cee81d3c..f2d12ff1 100644 --- a/src/Pingpong/Widget/README.md +++ b/src/Pingpong/Widget/README.md @@ -1,225 +1,4 @@ -Simple Widget System for Laravel Framework -================================== +Laravel Widget +============== -[![Build Status](https://travis-ci.org/pingpong-labs/widget.svg?branch=master)](https://travis-ci.org/pingpong-labs/widget) -[![Latest Stable Version](https://poser.pugx.org/pingpong/widget/v/stable.svg)](https://packagist.org/packages/pingpong/widget) [![Total Downloads](https://poser.pugx.org/pingpong/widget/downloads.svg)](https://packagist.org/packages/pingpong/widget) [![Latest Unstable Version](https://poser.pugx.org/pingpong/widget/v/unstable.svg)](https://packagist.org/packages/pingpong/widget) [![License](https://poser.pugx.org/pingpong/widget/license.svg)](https://packagist.org/packages/pingpong/widget) - -### Version Compability - - Laravel | Pingpong Widget | PHP -:---------|:-----------------|:---- - 4.x | 1.* |>= 5.3 - 5.0.x | 2.0.*@dev |>= 5.3 - -### Installation - -Open your composer.json file and add the new required package. - -``` - "pingpong/widget" : "1.*" -``` - -Next, open your terminal and run `composer update`. - -After composer updated, add new service provider in `app/config/app.php` : - -```php - 'Pingpong\Widget\WidgetServiceProvider', -``` - -And add facade in the same file - -```php - 'Widget' => 'Pingpong\Widget\Facades\Widget' -``` - -Done. - -### What's New! - -Subscribe widget: It's a new way to register widget using a specified class. For example: - -```php -Widget::subscribe('WidgetSubscriber'); - -class WidgetSubscriber { - - public function subscribe($widget) - { - $widget->register('image', __CLASS__ .'@image'); - } - - public function image() - { - return 'Your handler here'; - } -} -``` - -You can also specified which method to handle subscriber of widget. - -```php -Widget::subscribe('WidgetSubscriber@handle'); - -class WidgetSubscriber { - - public function handle($widget) - { - $widget->register('image', __CLASS__ .'@image'); - } - - public function image() - { - return 'Your handler here'; - } -} -``` - -### Registering A Widget - -By default you can register a widget in `app/widgets.php`, that file will autoload automatically. - -Via Closure. - -```php -// app/widgets.php - -Widget::register('small', function($contents) -{ - return "{$contents}"; -}); - -Widget::register('view', function($view, $data = array(), $mergeData = array() -{ - return View::make($view, $data, $mergeData)->render(); -}); - -``` - -Via Class Name. - -By default will call `register` method. - -```php -class MyWidget { - - public function register($contents, $attributes = array()) - { - $attributes = HTML::attributes($attributes); - - return "{$contents}"; - } - -} - -Widget::register('h1', 'MyWidget'); -``` - -Via Class Name with the specified method. - -```php - -class TagCreator { - - public function create($tag, $contents, $attributes = array()) - { - $attributes = HTML::attributes($attributes); - - return "<{$tag}{$attributes}>{$contents}"; - } - -} - -class HTMLWidget { - - protected $tag; - - public function __construct(TagCreator $tag) - { - $this->tag = $tag; - } - - public function p($contents, $attributes = array()) - { - return $this->tag->create('p', $contents, $attributes); - } - - public function div($contents, $attributes = array()) - { - return $this->tag->create('div', $contents, $attributes); - } -} -Widget::register('p', 'HTMLWidget@p'); - -Widget::register('div', 'HTMLWidget@div'); - -``` - -### Calling A Widget - -```php -Widget::get('small', array('My Content')); - -Widget::call('small', array('My Content')); - -Widget::small('My Content'); - -Widget::p('My Content'); - -Widget::div('My Content'); - -Widget::h1('My Content'); -``` - -On view you can call like this. - -``` -@small('My Content') - -@view('users.show', $data, $mergeData) - -@h1('Welcome!') - -@p('Hello World', array('class' => 'page-header')); - -@div('Lorem ipsum', array('class' => 'alert alert-warning')); -``` - -### Grouping A Widget - -It is very easy to group widget. you only need to specify the group name and specify an array of the names of the widgets that will be grouped. - -```php -Widget::register('calendar', 'SidebarWidget@calendar') - -Widget::register('archive', 'SidebarWidget@archive') - -Widget::group('sidebar', array('calendar', 'archive')); -``` - -To call a group of widgets is the same as calling the widget. - -```php -Widget::sidebar(); -``` - -If you want to send parameters to the widget that is in the group, you can call it like this. - -```php -Widget::sidebar( - array('your-first-param', 'your-second-param'), - array('first-param-for-second-widget', 'the-second') -); -``` - -On view you can call a group of widgets is same as calling the widget. - -``` -@sidebar() - -@sidebar(array('first-param'), array('first-param-for-second-widget')) -``` - -### License - -This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/widget) \ No newline at end of file From 4a5143b5a633eb5a0414c63cce66f6fc938353c8 Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 08:20:01 +0700 Subject: [PATCH 059/357] documentation moved to official website --- src/Pingpong/Trusty/README.md | 254 +--------------------------------- 1 file changed, 3 insertions(+), 251 deletions(-) diff --git a/src/Pingpong/Trusty/README.md b/src/Pingpong/Trusty/README.md index ee8fed0a..96483d39 100644 --- a/src/Pingpong/Trusty/README.md +++ b/src/Pingpong/Trusty/README.md @@ -1,252 +1,4 @@ -## Trusty - Roles and Permissions for Laravel 4 - -[![Build Status](https://travis-ci.org/pingpong-labs/trusty.svg?branch=master)](https://travis-ci.org/pingpong-labs/trusty) - -### Server Requirements - -- PHP 5.4 or higher - -### Installation - -Open your composer.json file, and add the new required package. -``` -"pingpong/trusty": "1.0.*" -``` -Next, open a terminal and run. -``` -composer update -``` - -Next, Add new service provider in `app/config/app.php`. - -```php - 'Pingpong\Trusty\TrustyServiceProvider', -``` - -Next, Add new aliases in `app/config/app.php`. - -```php -'Trusty' => 'Pingpong\Trusty\Facades\Trusty', -'Role' => 'Pingpong\Trusty\Entities\Role', -'Permission' => 'Pingpong\Trusty\Entities\Permission', -``` - -Next, migrate the database. -``` -php artisan migrate --package=pingpong/trusty -``` - -**NOTE:** If you want to modify the `roles` and `permissions` table, you can publish the migration. - -Done. - -### Usage - -Open your `app/models/User.php` file and use the `Pingpong\Trusty\Traits\TrustyTrait` trait. Look like this. - -```php - -``` - -Creating new Role. -```php -Role::create([ - 'name' => 'Administrator', - 'slug' => Str::slug('Administrator', '_'), - 'description' => 'The Super Administrator' -]); - -// without description -Role::create([ - 'name' => 'Editor', - 'slug' => Str::slug('Editor', '_'), -]); -``` - -Creating new Permission. - -```php -Permission::create([ - 'name' => 'Manage Users', - 'slug' => Str::slug('Manage Users', '_'), // manage_users - 'description' => 'Create, Read, Update and Delete Users' -]); - -// without description -Permission::create([ - 'name' => 'Manage Posts', - 'slug' => Str::slug('Manage Posts', '_'), // manage_posts -]); -``` - -Set permission for the specified role. - -```php -$permission_id = 1; -$role = Role::findOrFail(1); -$role->permissions()->attach($permission_id); -``` - -Set role for current user. -```php -$role_id = 1; -$user = Auth::user(); -$user->roles()->attach($role_id); -``` - -Adding role to the user. -```php -Auth::user()->addRole(1); -``` - -Updating role user. -```php -$role_id = 1; -Auth::user()->updateRole($role_id); -``` - -Check role for current user. -```php -if(Auth::user()->is('administrator')) -{ - // your code here -} -``` - -Or using magic method. -```php -if(Auth::user()->isAdministrator()) -{ - // your code -} -``` - -Check permission for current user. -```php -if(Auth::user()->can('manage_users')) -{ - // your code here -} -``` - -Or using magic method. -```php -if(Auth::user()->canManageUsers()) -{ - // your code here -} -``` - -Check permissions against a role. -```php -$role = Role::findOrFail(1); - -if ($role->can('manage_users')) -{ - // your code here -} -``` - -Or using magic method. -```php -$role = Role::findOrFail(1); - -if($role->canManageUsers()) -{ - // your code here -} -``` - -Get all permission from current users. -```php -$myPermissions = Auth::user()->getPermissions(); -dd($myPermissions); - -// or - -$permissions = Auth::user()->permissions(); -dd($permissions); -``` - -Get role for current user. -```php -$myRole = Auth::user()->getRole(); -``` - -Simple filtering route based on permission. -```php - -// register all permission as filter -Trusty::registerPermissions(); - -// filter request -Trusty::when('admin/*', 'filter_name'); - -// mutiple request -Trusty::when(['admin/users', 'admin/users/*'], 'manage_users'); -``` - -Abort the user if that user have not a specify permission. -```php -Trusty::forbidden(); -``` - -Maybe you can do something like this. -```php -if( ! Auth::user()->canManageUsers()) -{ - Trusty::forbidden(); -} -``` - -When you run `forbidden` method, that's will throw an exception. You can handle this exception using Laravel error handler feature. You can do something like this. - -```php -App::error(function(Pingpong\Trusty\Exceptions\ForbiddenException $e) -{ - return Response::make($e->getMessage(), 403); -}); -``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) - - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pingpong-labs/trusty/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +Trusty +============== +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/trusty) \ No newline at end of file From f5a6152f373b13e45096acc2371b50ea57b555fb Mon Sep 17 00:00:00 2001 From: gravitano Date: Fri, 13 Feb 2015 08:23:50 +0700 Subject: [PATCH 060/357] documentation moved to official website --- src/Pingpong/Generators/README.md | 112 +-------- src/Pingpong/Menus/README.md | 390 +----------------------------- src/Pingpong/Modules/README.md | 25 +- src/Pingpong/Presenters/README.md | 67 +---- src/Pingpong/Shortcode/README.md | 139 +---------- src/Pingpong/Testing/README.md | 87 +------ src/Pingpong/Themes/README.md | 100 +------- 7 files changed, 17 insertions(+), 903 deletions(-) diff --git a/src/Pingpong/Generators/README.md b/src/Pingpong/Generators/README.md index 3448c8cc..1fcdb40e 100644 --- a/src/Pingpong/Generators/README.md +++ b/src/Pingpong/Generators/README.md @@ -1,112 +1,4 @@ Laravel Generators -========== +============== -[![Build Status](https://travis-ci.org/pingpong-labs/generators.svg)](https://travis-ci.org/pingpong-labs/generators) -[![Latest Stable Version](https://poser.pugx.org/pingpong/generators/v/stable.svg)](https://packagist.org/packages/pingpong/generators) -[![Total Downloads](https://poser.pugx.org/pingpong/generators/downloads.svg)](https://packagist.org/packages/pingpong/generators) -[![Latest Unstable Version](https://poser.pugx.org/pingpong/generators/v/unstable.svg)](https://packagist.org/packages/pingpong/generators) -[![License](https://poser.pugx.org/pingpong/generators/license.svg)](https://packagist.org/packages/pingpong/generators) - -### Quick Installation Via Composer - -``` -composer require "pingpong/generators:1.*" -``` - -Next, register new service provider to `providers` array in `app/config/app.php`. - -```php -'Pingpong\Generators\GeneratorsServiceProvider' -``` - -Done. - -### Documentation - -**Generate a new controller** - -```php -$path = app_path('controllers'); - -$generator = new Pingpong\Generators\ControllerGenerator($path, 'HomeController'); - -$generator->generate(); -``` - -You may also set the namespace for the class by specify the `namespace` key in the `options` array. The `options` array is the third argument in the generator class. For example : - -```php -$options = ['namespace' => 'App\\Controllers']; - -$generator = new Pingpong\Generators\ControllerGenerator($path, 'HomeController', $options); - -$generator->generate(); -``` - -**Generate a new model** - -```php -$generator = new Pingpong\Generators\ModelGenerator($path, 'User'); - -$generator->generate(); -``` - -**Generate a new seed** - -```php -$generator = new Pingpong\Generators\SeedGenerator($path, 'UsersTableSeeder'); - -$generator->generate(); -``` - -**Generate a new filter** - -```php -$generator = new Pingpong\Generators\FilterGenerator($path, 'AdminFilter'); - -$generator->generate(); -``` - -**Generate a new form request** - -```php -$generator = new Pingpong\Generators\FormRequestGenerator($path, 'LoginRequest'); - -$generator->generate(); -``` - -**Generate a new command** - -```php -$generator = new Pingpong\Generators\CommandGenerator($path, 'FooCommand'); - -$generator->generate(); -``` - -**Generate a new service provider** - -```php -$generator = new Pingpong\Generators\ProviderGenerator($path, 'BarServiceProvider'); - -$generator->generate(); -``` - -**Generate a new migration** - -```php -use Pingpong\Generate\MigrationGenerator; - -$generator = new MigrationGenerator($path, 'create_users_table'); - -$generator = new MigrationGenerator($path, 'create_users_table', 'name:string, username:string'); - -$generator = new MigrationGenerator($path, 'add_remember_token_to_users_table', 'remember_token:string:nullable'); - -$generator = new MigrationGenerator($path, 'remove_username_from_users_table', 'username:string'); - -$generator = new MigrationGenerator($path, 'drop_users_table', 'name:string, username:string'); -``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/generators) \ No newline at end of file diff --git a/src/Pingpong/Menus/README.md b/src/Pingpong/Menus/README.md index df7d6c28..0010c60b 100644 --- a/src/Pingpong/Menus/README.md +++ b/src/Pingpong/Menus/README.md @@ -1,390 +1,4 @@ Laravel Menus -======================== +============== -[![Build Status](https://travis-ci.org/pingpong-labs/menus.svg)](https://travis-ci.org/pingpong-labs/menus) -[![Latest Stable Version](https://poser.pugx.org/pingpong/menus/v/stable.svg)](https://packagist.org/packages/pingpong/menus) [![Total Downloads](https://poser.pugx.org/pingpong/menus/downloads.svg)](https://packagist.org/packages/pingpong/menus) [![Latest Unstable Version](https://poser.pugx.org/pingpong/menus/v/unstable.svg)](https://packagist.org/packages/pingpong/menus) [![License](https://poser.pugx.org/pingpong/menus/license.svg)](https://packagist.org/packages/pingpong/menus) - -### Version Compability - - Laravel | Pingpong Menus | PHP -:---------|:---------------|:---- - 4.x | 1.x |>= 5.3 - 5.0.x | 2.*@dev |>= 5.4 - -### Installation - -First, open your `composer.json` file and add new package. -``` - "require": { - "pingpong/menus": "1.0.*" - }, -``` -Then open a terminal and run: -``` -composer update -``` -After that, open the file `app/config/app.php` and add a new service provider in `providers` array. -```php - - 'providers' => array( - - 'Illuminate\Foundation\Providers\ArtisanServiceProvider', - 'Illuminate\Auth\AuthServiceProvider', - ... - 'Illuminate\View\ViewServiceProvider', - 'Illuminate\Workbench\WorkbenchServiceProvider', - - // here - 'Pingpong\Menus\MenusServiceProvider' - - ), -``` -Then add the class alias in `aliases`. -```php - - 'aliases' => array( - - 'App' => 'Illuminate\Support\Facades\App', - 'Artisan' => 'Illuminate\Support\Facades\Artisan', - ... - 'Validator' => 'Illuminate\Support\Facades\Validator', - 'View' => 'Illuminate\Support\Facades\View', - - // here - 'Menu' => 'Pingpong\Menus\Facades\Menu', - ) -``` -Then, publish configuration for package `pingpong/menus`: -``` -php artisan config:publish pingpong/menus -``` -Done. - -### Screenshot - -![View Screenshot](https://raw.githubusercontent.com/pingpong-labs/menus/master/shots/multilevel-menu-pingpong.png) - -### Example Usage - -**NEW!** - -On `app/menus.php` : -```php - -// app/menus.php - -use Pingpong\Menus\Builder; -use Pingpong\Menus\MenuItem; - -Menu::create('top', function(Builder $menu) -{ - // simple using route - $menu->route('home', 'Home'); - // simple using route with parameters and attributes - $menu->route('profile.user', 'View Profile', ['username' => 'gravitano'], ['class' => 'btn btn-default']); - // using array - $menu->add([ - 'url' => 'messages', - 'title' => 'Messages', - 'icon' => 'fa fa-envelope' - ]); - // using url - $menu->url('products', 'Products'); - // using url with attributes - $menu->url('products/1', 'View Products', ['class' => 'btn btn-link']); - // new! support dropdown with multi level nested menu - $menu->dropdown('Settings', function(MenuItem $sub) - { - $sub->url('profile/edit', 'Edit Profile'); - $sub->dropdown('Account', function(MenuItem $sub) - { - $sub->url('settings/payment', 'Payment'); - // nested menu - $sub->dropdown('Social Network', function(MenuItem $sub) - { - $sub->url('https://github.com/gravitano', 'Github', ['target' => '_blank']); - $sub->url('https://facebook.com/warsono.m.faisyal', 'Facebook', ['target' => '_blank']); - $sub->url('https://twitter.com/gravitano', 'Twitter', ['target' => '_blank']); - }); - }); - $sub->url('logout', 'Logout'); - }); -}); -``` - -On view, for example `hello.blade.php`. -```html - - - - - Laravel PHP Framework - {{ HTML::style('css/bootstrap.css') }} - {{-- Add new style for allowing multi level menu --}} - {{ Menu::style() }} - - - -
    - {{ Menu::get('top') }} -
    - - {{ HTML::script('js/jquery.min.js') }} - {{ HTML::script('js/bootstrap.min.js') }} - - -``` - -First, create a file called `menus.php` in your `app/` folder, alongside with `routes.php` and `filters.php`. The file will be automatically include if the file exists. And you can define your menus in that file. - -**Creating a menu.** -```php -Menu::create('navbar', function($menu) -{ - // using array - $menu->add([ - 'route' => 'home', - 'title' => 'Home', - 'icon' => 'fa fa-dashboard' - ]); - - // menu with target to url - $menu->url('/', 'Home'); - - // with additional attributes - $menu->url('/', 'Home', ['class' => 'nav-link']); - - // menu with target to registered route - $menu->route('home', 'Home'); - - // with additional route parameters and attributes - $menu->route('home', 'Home', null, ['class' => 'nav-link']); - - $menu->route('users.show', Auth::user()->name, Auth::id(), ['class' => 'nav-link']); - - $menu->route('users.show', 'My Profile', ['username' => 'gravitano'], ['class' => 'nav-link']); - - $menu->route('products.show', 'View Product', 1, ['class' => 'nav-link']); - - // dropdown menu - $menu->dropdown('Settings', function($sub) - { - $sub->url('settings/account', 'Account'); - $sub->route('settings.profile', 'Profile'); - $sub->route('logout', 'Logout'); - }); - - // multi level menu (nested) - $menu->dropdown('Category', function($sub) - { - $sub->url('category/programming', 'Programming'); - - $sub->url('category/screencasts', 'Screencasts'); - - $sub->dropdown('Sport News', function($sub) - { - $sub->url('category/football', 'Football'); - $sub->url('category/basket-ball', 'Basket Ball'); - }); - - $sub->dropdown('Title', function($sub) - { - $sub->url('link', 'Link'); - $sub->dropdown('Title', function($sub) - { - $sub->dropdown('Title N', function($sub) - { - // more nested menu here - }); - }); - }); - }); -}); -```` - -**Make Lots of menu** - -This package allows you to create a menu with a lot of different styles. Here's an example. - -```php -Menu::create('menu1', function($menu) -{ - - $menu->route('home', 'Home'); - - $menu->url('profile', 'Profile'); -}); - -Menu::create('menu2', function($menu) -{ - $menu->route('home', 'Home'); - - $menu->url('profile', 'Profile'); -}); -``` - -**Calling a menu.** - -To call up the menu you can use `render` or `get` method. - -```php -Menu::render('navbar'); - -Menu::get('menu1'); - -Menu::get('menu2'); -``` - -**Menu Style.** - -By default the generated menu style is bootstrap navbar. In addition there are also several different menu styles and is already available by default are `navbar`, `navbar-right`, `nav-pills` and `nav-tab`. To set the style menu you can use the method `style`. Examples like this. - -```php -Menu::create('navbar', function($menu) -{ - $menu->style('nav-pills'); - - $menu->route('home', 'Home'); - - $menu->url('profile', 'Profile'); -}); -``` - -**Make A Costum Presenter** - -You can create your own presenter class. Make sure your presenter is extends to `Pingpong\Menus\Presenters\Presenter`, that class is also `implements` to 'Pingpong\Menus\Presenters\PresenterInterface'. For example this is zurb topbar presenter. - -```php - -use Pingpong\Menus\Presenters\Presenter; - -class ZurbTopBarPresenter extends Presenter -{ - /** - * {@inheritdoc } - */ - public function getOpenTagWrapper() - { - return PHP_EOL . '
    ' . PHP_EOL; - } - - /** - * {@inheritdoc } - */ - public function getCloseTagWrapper() - { - return PHP_EOL . '
    ' . PHP_EOL; - } - - /** - * {@inheritdoc } - */ - public function getMenuWithoutDropdownWrapper($item) - { - return 'getActiveState($item).'>'.$item->getIcon().' '.$item->title.''; - } - - /** - * {@inheritdoc } - */ - public function getActiveState($item) - { - return \Request::is($item->getRequest()) ? ' class="active"' : null; - } - - /** - * {@inheritdoc } - */ - public function getDividerWrapper() - { - return '
  • '; - } - - /** - * {@inheritdoc } - */ - public function getMenuWithDropDownWrapper($item) - { - return '
  • - - '.$item->getIcon().' '.$item->title.' - - -
  • ' . PHP_EOL; - ; - } -} - -``` -For use costum presenter, you can use the `setPresenter` method, for example like this. -```php -Menu::create('zurb-top-bar', function($menu) -{ - $menu->setPresenter('ZurbTopBarPresenter'); - - $menu->route('home', 'Home'); - - $menu->url('profile', 'Profile'); -}); -``` - -Or you can set it at the time of calling the menu, like this. - -```php -Menu::render('zurb-top-bar', 'ZurbTopBarPresenter'); - -Menu::get('zurb-top-bar', 'ZurbTopBarPresenter'); -``` - -**Register A New Style Menu** - -This Style is like an alias to a presenter. You can register your style from your costum presenter in the configuration file in `app/config/packages/pingpong/menus/config.php`. Like this. - -```php -return array( - 'navbar' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarPresenter', - 'navbar-right' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarRightPresenter', - 'nav-pills' => 'Pingpong\Menus\Presenters\Bootstrap\NavPillsPresenter', - 'nav-tab' => 'Pingpong\Menus\Presenters\Bootstrap\NavTabPresenter', - - 'zurb-top-bar' => 'ZurbTopBarPresenter', -); -``` - -Then you can use a style like this. Same as section **Menu Style** above. - -```php -Menu::create('zurb-top-bar', function($menu) -{ - $menu->style('zurb-top-bar'); - $menu->add([ - 'route' => 'home', - 'title' => 'Home', - ]); - $menu->url('profile', 'Profile'); - - $menu->route('settings', 'Settings'); -}); -``` - -**Get The Menu Instance** - -To get an instance of an existing menu, you can use the `instance` method. Here's an example. - -```php -$menu = Menu::instance('zurb-top-bar'); - -// You can also make additions to the menu again - -$menu->add(['title' => 'Settings', 'route' => 'settings']); - -$menu->url('profile', 'Profile'); - -$menu->route('settings', 'Settings'); -``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/menus) \ No newline at end of file diff --git a/src/Pingpong/Modules/README.md b/src/Pingpong/Modules/README.md index 5ec46fc4..4fd49ea6 100644 --- a/src/Pingpong/Modules/README.md +++ b/src/Pingpong/Modules/README.md @@ -1,25 +1,4 @@ Laravel Modules -========================= - -[![Build Status](https://travis-ci.org/pingpong-labs/modules.svg?branch=master)](https://travis-ci.org/pingpong-labs/modules) -[![HHVM Status](http://hhvm.h4cc.de/badge/pingpong/modules.svg)](http://hhvm.h4cc.de/package/pingpong/modules) -[![Latest Stable Version](https://poser.pugx.org/pingpong/modules/v/stable.svg)](https://packagist.org/packages/pingpong/modules) -[![Total Downloads](https://poser.pugx.org/pingpong/modules/downloads.svg)](https://packagist.org/packages/pingpong/modules) -[![License](https://poser.pugx.org/pingpong/modules/license.svg)](https://packagist.org/packages/pingpong/modules) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pingpong-labs/modules/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - -### Version Compability - - Laravel | Pingpong Modules | PHP -:---------|:-----------------|:---- - 4.x | 1.x |>= 5.4 - 5.0.x | 2.0.*@dev |>= 5.4 - -### Documentation - -For more documentation please see [wiki](https://github.com/pingpong-labs/modules/wiki) part of this repo. - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) +============== +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/modules) \ No newline at end of file diff --git a/src/Pingpong/Presenters/README.md b/src/Pingpong/Presenters/README.md index ae614a8c..fc088bec 100644 --- a/src/Pingpong/Presenters/README.md +++ b/src/Pingpong/Presenters/README.md @@ -1,65 +1,4 @@ -View Presenter For Laravel -============================= +Laravel View Presenter +============== -[![Build Status](https://travis-ci.org/pingpong-labs/presenters.svg?branch=1.0.4)](https://travis-ci.org/pingpong-labs/presenters) - -### Installation - -Open your composer.json file, and add the new required package. - - "pingpong/presenters": "1.0.*" - -Next, open a terminal and run. - - composer update - -Done. - -### Example Usage - -First, create your own presenter and make sure that class is extends to `Pingpong\Presenters\Presenter` class. Like this. - -```php -resource->email, $this->resource->email, $attributes); - } -} -?> -``` - -Make sure your model/eloquent to extends `Pingpong\Presenters\Model` and set the presenter property to that model/eloquent. - -```php - -``` - -That's it! You're done. Now, within your view, you can do: - -```php -

    Your email is {{ $user->present()->email }}

    -``` - -Or, call the presenter as method. - -```php -

    Your email is {{ $user->present()->email(['width' => 140]) }}

    -``` - -### License - -This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) \ No newline at end of file +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/presenters) \ No newline at end of file diff --git a/src/Pingpong/Shortcode/README.md b/src/Pingpong/Shortcode/README.md index defac3a7..a8e124e9 100644 --- a/src/Pingpong/Shortcode/README.md +++ b/src/Pingpong/Shortcode/README.md @@ -1,139 +1,4 @@ Laravel Shortcode -========= +============== -[![Build Status](https://travis-ci.org/pingpong-labs/shortcode.svg?branch=master)](https://travis-ci.org/pingpong-labs/shortcode) -[![Latest Stable Version](https://poser.pugx.org/pingpong/shortcode/v/stable.png)](https://packagist.org/packages/pingpong/shortcode) [![Total Downloads](https://poser.pugx.org/pingpong/shortcode/downloads.png)](https://packagist.org/packages/pingpong/shortcode) [![Latest Unstable Version](https://poser.pugx.org/pingpong/shortcode/v/unstable.png)](https://packagist.org/packages/pingpong/shortcode) [![License](https://poser.pugx.org/pingpong/shortcode/license.png)](https://packagist.org/packages/pingpong/shortcode) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pingpong-labs/shortcode/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - -### Server Requirements - -- PHP 5.4.0 or higher. - -### Installation -Open your composer.json file, and add the new required package. - -``` - "pingpong/shortcode": "1.0.*" -``` - -Next, open a terminal and run. - -``` - composer update -``` - -After the composer updated. Add new service provider in app/config/app.php. - -``` - 'Pingpong\Shortcode\ShortcodeServiceProvider' -``` - -Add new Facade alias. -```php -'Shortcode' => 'Pingpong\Shortcode\Facades\Shortcode', -``` - -Done. - -### Registering Shorcode - -Using closure: -```php -Shortcode::register('a', function($attr, $content = null, $name = null) -{ - $text = Shortcode::compile($content); - return ''. $text .''; -}); -``` - -Using class name. -```php - -class DivShortcode -{ - public function register($attr, $content = null, $name = null) - { - $text = Shortcode::compile($content); - return ''. $text .''; - } -} - -Shortcode::register('div', 'DivShortcode'); -``` - -Using class name with the specified method. -```php - -class HTMLShortcode -{ - public function img($attr, $content = null, $name = null) - { - $src = array_get($attr, 'src'); - $text = Shortcode::compile($content); - return ''; - } -} - - -Shortcode::register('img', 'HTMLShortcode@img'); -``` - -Using callback array. -```php - -class SpanShortcode -{ - - public function div($attr, $content = null, $name = null) - { - $text = Shortcode::compile($content); - return ''. $text .''; - } -} - -Shortcode::register('span', array('SpanShortcode', 'span')); -``` - -Using function name. -```php -function smallTag($attr, $content = null, $name = null) -{ - $text = Shortcode::compile($content); - return ''. $text .''; -} - -Shortcode::register('small', 'smallTag'); -``` - -### Compile - -```php -$text = '[a href="#"]Click here[/a]'; -echo Shortcode::compile($text); - -$text = ' -[a href="#"] - [img src="http://placehold.it/140x140"] - [small]This is small text[/small] -[/a] -'; -echo Shortcode::compile($text); -``` - -### Unregister The Specified Shortcode - -```php -Shortcode::unregister('img'); -``` - -### Destroy All Shortcodes - -```php -Shortcode::destroy(); -``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) - -This package also adopted a system of wordpress shortcodes. Please see or read [the license](http://wordpress.org/about/license/) of wordpress also [here](http://codex.wordpress.org/License). \ No newline at end of file +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/shortcode) \ No newline at end of file diff --git a/src/Pingpong/Testing/README.md b/src/Pingpong/Testing/README.md index 31811b46..d539537f 100644 --- a/src/Pingpong/Testing/README.md +++ b/src/Pingpong/Testing/README.md @@ -1,85 +1,4 @@ -Unit Testing Helper for Laravel's Package -========= +Unit Testing Helper for Your Laravel Package +============== -This package is inspired from orchestra/testbench package - -[![Build Status](https://travis-ci.org/pingpong-labs/testing.svg)](https://travis-ci.org/pingpong-labs/testing) - -### Quick Installation Via Composer - -``` -composer require "pingpong/testing:1.*" -``` - -### Example Usage - -Your First Test. - -```php -use Pingpong\Testing\TestCase; - -class LoginControllerTest extends TestCase { - - public function testGetLogin() - { - $this->call('GET', '/login'); - $this->assertResponseOk(); - } -} -``` - -Register The Package's Providers And Aliases. - -```php -use Pingpong\Testing\TestCase; - -class MasterTestCase extends TestCase { - - public function getPackageAliases() - { - return [ - 'Sample' => 'Vendor\Sample\Facades\Sample' - ]; - } - - public function getPackageProviders() - { - return [ - 'Vendor\Sample\SampleServiceProvider' - ]; - } -} -``` - -Register custom booted callback. - -```php -use Pingpong\Testing\TestCase; - -class MasterTestCase extends TestCase { - - protected function registerBootedCallback($app) - { - include __DIR__ . '/../routes.php'; - } -} -``` - -Setup Your Application Timezone. - -```php - -use Pingpong\Testing\TestCase; - -class MasterTestCase extends TestCase { - - protected function getApplicationTimezone() - { - return 'Asia/Jakarta'; - } -} -``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/testing) \ No newline at end of file diff --git a/src/Pingpong/Themes/README.md b/src/Pingpong/Themes/README.md index fbc5c344..6e9a02b4 100644 --- a/src/Pingpong/Themes/README.md +++ b/src/Pingpong/Themes/README.md @@ -1,98 +1,4 @@ -## Laravel Themes +Laravel Themes +============== -[![Build Status](https://travis-ci.org/pingpong-labs/themes.svg?branch=master)](https://travis-ci.org/pingpong-labs/themes) -[![Latest Stable Version](https://poser.pugx.org/pingpong/themes/v/stable.svg)](https://packagist.org/packages/pingpong/themes) [![Total Downloads](https://poser.pugx.org/pingpong/themes/downloads.svg)](https://packagist.org/packages/pingpong/themes) [![Latest Unstable Version](https://poser.pugx.org/pingpong/themes/v/unstable.svg)](https://packagist.org/packages/pingpong/themes) [![License](https://poser.pugx.org/pingpong/themes/license.svg)](https://packagist.org/packages/pingpong/themes) - -### Installation - -Open your composer.json file, and add the new required package. -``` - "pingpong/themes": "1.0.*" -``` -Next, open a terminal and run. -``` -composer update -``` - -Next, Add new service provider in `app/config/app.php`. - -```php - 'Pingpong\Themes\ThemesServiceProvider', -``` - -Next, Add new aliases in `app/config/app.php`. - -```php - 'Theme' => 'Pingpong\Themes\Facades\Theme', -``` - -Next, publish the asset. The asset is an example theme. -``` -php artisan asset:publish pingpong/themes -``` - -Done. - -### Usage - -Get all themes. -```php -Theme::all(); -``` - -Set theme active. -```php -Theme::set('default'); - -Theme::setCurrent('default'); -``` - -Get current theme active. -```php -Theme::getCurrent(); -``` - -Check theme. -```php -Theme::has('simple') - -Theme::exists('other-theme'); -``` - -Set theme path. -```php -$path = public_path('themes'); - -Theme::setPath($path); -``` - -Get theme path. -```php -Theme::getThemePath('default'); -``` - -Get themes path. -```php -Theme::getPath(); -``` - -Get view from current active theme. -```php -Theme::view('index'); - -Theme::view('folders.view'); -``` - -Get config from current active theme. -```php -Theme::config('group.name'); -``` - -Get lang from current active theme. -```php -Theme::lang('group.name'); -``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) +Official documentation is located [here](http://sky.pingpong-labs.com/docs/2.0/themes) \ No newline at end of file From 6c842a1fb785dacd50db45c3b29a14b24d7d8ef4 Mon Sep 17 00:00:00 2001 From: gravitano Date: Sat, 14 Feb 2015 22:36:50 +0700 Subject: [PATCH 061/357] Update facade --- docs/widget.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/widget.md b/docs/widget.md index 99417f0d..b7adbb11 100644 --- a/docs/widget.md +++ b/docs/widget.md @@ -27,7 +27,7 @@ After composer updated, add new service provider in `config/app.php` : And add facade in the same file ```php - 'Widget' => 'Pingpong\Widget\Facades\Widget' + 'Widget' => 'Pingpong\Widget\WidgetFacade' ``` Done. From ec355af13df4175f1e405913543901b5142186ca Mon Sep 17 00:00:00 2001 From: gravitano Date: Sat, 14 Feb 2015 22:37:53 +0700 Subject: [PATCH 062/357] Update facade --- docs/shortcode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/shortcode.md b/docs/shortcode.md index 9c815012..1fd63b9c 100644 --- a/docs/shortcode.md +++ b/docs/shortcode.md @@ -29,7 +29,7 @@ After the composer updated. Add new service provider in app/config/app.php. Add new Facade alias. ```php -'Shortcode' => 'Pingpong\Shortcode\Facades\Shortcode', +'Shortcode' => 'Pingpong\Shortcode\ShortcodeFacade', ``` Done. From 5064a1ebf4d26b575ff1955dfdc4bbf6de67082a Mon Sep 17 00:00:00 2001 From: gravitano Date: Sat, 14 Feb 2015 22:39:29 +0700 Subject: [PATCH 063/357] Update facade --- docs/menus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/menus.md b/docs/menus.md index 907cecfd..5470873b 100644 --- a/docs/menus.md +++ b/docs/menus.md @@ -47,7 +47,7 @@ Then add the class alias in `aliases`. 'View' => 'Illuminate\Support\Facades\View', // here - 'Menu' => 'Pingpong\Menus\Facades\Menu', + 'Menu' => 'Pingpong\Menus\MenuFacade', ) ``` Then, publish configuration for package `pingpong/menus`: From 54f9e8ef6963e29681f4831ce6e99085ff9e294f Mon Sep 17 00:00:00 2001 From: gravitano Date: Sun, 15 Feb 2015 00:21:22 +0700 Subject: [PATCH 064/357] Remove boot method --- src/Pingpong/Shortcode/ShortcodeServiceProvider.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Pingpong/Shortcode/ShortcodeServiceProvider.php b/src/Pingpong/Shortcode/ShortcodeServiceProvider.php index 5b15c3ad..909482f6 100644 --- a/src/Pingpong/Shortcode/ShortcodeServiceProvider.php +++ b/src/Pingpong/Shortcode/ShortcodeServiceProvider.php @@ -11,16 +11,6 @@ class ShortcodeServiceProvider extends ServiceProvider { */ protected $defer = false; - /** - * Bootstrap the application events. - * - * @return void - */ - public function boot() - { - $this->package('pingpong/shortcode'); - } - /** * Register the service provider. * From 8cd83cd8031f03178bc0b5ae106305a5cab1b968 Mon Sep 17 00:00:00 2001 From: gravitano Date: Sun, 15 Feb 2015 01:48:06 +0700 Subject: [PATCH 065/357] Add --squash option --- build/pull.sh | 24 ++++++++++++------------ build/push.sh | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/pull.sh b/build/pull.sh index bfea38a1..979068bb 100755 --- a/build/pull.sh +++ b/build/pull.sh @@ -1,15 +1,15 @@ #!/bin/sh git pull origin 2.0 -git subtree pull --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git 2.0 -git subtree pull --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git 2.0 -git subtree pull --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git 2.0 -git subtree pull --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git 2.0 -git subtree pull --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git 2.0 -git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git 2.0 -git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git 2.0 -git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 -git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 -git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 -git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 -git subtree pull --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 \ No newline at end of file +git subtree pull --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 --squash +git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2. --squash +git subtree pull --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 --squash \ No newline at end of file diff --git a/build/push.sh b/build/push.sh index 3efba986..aa9d5bbd 100755 --- a/build/push.sh +++ b/build/push.sh @@ -1,15 +1,15 @@ #!/bin/sh git push origin 2.0 -git subtree push --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git 2.0 -git subtree push --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git 2.0 -git subtree push --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git 2.0 -git subtree push --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git 2.0 -git subtree push --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git 2.0 -git subtree push --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git 2.0 -git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git 2.0 -git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 -git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 -git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 -git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 -git subtree push --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 \ No newline at end of file +git subtree push --prefix=src/Pingpong/Widget git@github.com:pingpong-labs/widget.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Shortcode git@github.com:pingpong-labs/shortcode.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Menus git@github.com:pingpong-labs/menus.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Presenters git@github.com:pingpong-labs/presenters.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Modules git@github.com:pingpong-labs/modules.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Testing git@github.com:pingpong-labs/testing.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/generators.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 --squash +git subtree push --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 --squash +git subtree push --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 --squash \ No newline at end of file From 26a54a2f52070879ebf03f09bddc1a481f029598 Mon Sep 17 00:00:00 2001 From: gravitano Date: Sun, 15 Feb 2015 02:02:44 +0700 Subject: [PATCH 066/357] Fix test --- tests/Menus/BuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Menus/BuilderTest.php b/tests/Menus/BuilderTest.php index ab2a2d23..f7ed87bb 100644 --- a/tests/Menus/BuilderTest.php +++ b/tests/Menus/BuilderTest.php @@ -42,7 +42,7 @@ public function testGetAliasFromConfigFile() $this->builder->setStyles(array()); $this->config->shouldReceive('get') ->times(2) - ->with('menus::styles') + ->with('menus.styles') ->andReturn(array('navbar' => $this->styles['navbar'])); $actual = $this->builder->hasStyle('navbar'); From 3e66aeee8adb46f53fc6c58a342c7ea068c28b5d Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 11:53:39 +0700 Subject: [PATCH 067/357] Fix 'class InvalidMigrationName not found' --- src/Pingpong/Modules/Commands/MigrationCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pingpong/Modules/Commands/MigrationCommand.php b/src/Pingpong/Modules/Commands/MigrationCommand.php index 871626f4..341638c2 100644 --- a/src/Pingpong/Modules/Commands/MigrationCommand.php +++ b/src/Pingpong/Modules/Commands/MigrationCommand.php @@ -1,13 +1,13 @@ Date: Mon, 16 Feb 2015 17:41:55 +0700 Subject: [PATCH 068/357] remove useless import class --- .../src/migrations/2014_05_02_052410_create_role_user_table.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php index cf204181..7a0b921f 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php @@ -1,6 +1,5 @@ Date: Mon, 16 Feb 2015 17:42:15 +0700 Subject: [PATCH 069/357] Remove duplicate service provider --- .../Pingpong/Menus/MenusServiceProvider.php | 86 ------------------- 1 file changed, 86 deletions(-) delete mode 100644 src/Pingpong/Menus/src/Pingpong/Menus/MenusServiceProvider.php diff --git a/src/Pingpong/Menus/src/Pingpong/Menus/MenusServiceProvider.php b/src/Pingpong/Menus/src/Pingpong/Menus/MenusServiceProvider.php deleted file mode 100644 index c27d1148..00000000 --- a/src/Pingpong/Menus/src/Pingpong/Menus/MenusServiceProvider.php +++ /dev/null @@ -1,86 +0,0 @@ -requireMenusFile(); - } - - /** - * Require the menus file if that file is exists. - * - * @return void - */ - public function requireMenusFile() - { - if(file_exists($file = app_path('menus.php'))) - { - require $file; - } - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->registerServices(); - $this->registerNamespaces(); - } - - /** - * Register package service. - * - * @return void - */ - protected function registerServices() - { - $this->app['menus'] = $this->app->share(function($app) - { - return new Menu($app['view'], $app['config']); - }); - } - - /** - * Register package's namespaces. - * - * @return void - */ - protected function registerNamespaces() - { - // config - $configPath = __DIR__.'/../../../src/config/menus.styles.php'; - $this->mergeConfigFrom($configPath, 'menus.styles'); - $this->publishes([$configPath => config_path('menus.styles.php')]); - // views - $this->loadViewsFrom(__DIR__.'/../../../src/views', 'menus'); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array('menus'); - } - -} From 6794aa72143940795d5987cb7f5115d037b565bb Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 17:52:54 +0700 Subject: [PATCH 070/357] remove VERSION constant --- src/Pingpong/Trusty/Trusty.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Pingpong/Trusty/Trusty.php b/src/Pingpong/Trusty/Trusty.php index b269d866..32d825ac 100644 --- a/src/Pingpong/Trusty/Trusty.php +++ b/src/Pingpong/Trusty/Trusty.php @@ -6,8 +6,6 @@ class Trusty { - const VERSION = '1.x-dev'; - /** * The avaliable HTTP Verbs. * From 4e0d13803289a617e7b398bce617271e2f5523a7 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 17:53:23 +0700 Subject: [PATCH 071/357] publish migrations for l5 --- src/Pingpong/Trusty/TrustyServiceProvider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Trusty/TrustyServiceProvider.php b/src/Pingpong/Trusty/TrustyServiceProvider.php index 9a65491b..559995b8 100644 --- a/src/Pingpong/Trusty/TrustyServiceProvider.php +++ b/src/Pingpong/Trusty/TrustyServiceProvider.php @@ -18,7 +18,9 @@ class TrustyServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('pingpong/trusty', 'trusty', __DIR__ . '/src'); + $this->publishes([ + __DIR__ . '/src/migrations/' => base_path('/database/migrations') + ]); } /** From 5e298a25a36f4d5d7698028825773c0117b49c59 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 18:01:44 +0700 Subject: [PATCH 072/357] Make the relationship configurable --- src/Pingpong/Trusty/Entities/Permission.php | 2 +- src/Pingpong/Trusty/Entities/Role.php | 2 +- src/Pingpong/Trusty/Traits/TrustyTrait.php | 2 +- src/Pingpong/Trusty/src/config/config.php | 11 +++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/Pingpong/Trusty/src/config/config.php diff --git a/src/Pingpong/Trusty/Entities/Permission.php b/src/Pingpong/Trusty/Entities/Permission.php index 190fde7a..c13ae1f6 100644 --- a/src/Pingpong/Trusty/Entities/Permission.php +++ b/src/Pingpong/Trusty/Entities/Permission.php @@ -21,7 +21,7 @@ class Permission extends Model { */ public function roles() { - return $this->belongsToMany(__NAMESPACE__ . '\\Role')->withTimestamps(); + return $this->belongsToMany(config('trusty.model.permission'))->withTimestamps(); } } \ No newline at end of file diff --git a/src/Pingpong/Trusty/Entities/Role.php b/src/Pingpong/Trusty/Entities/Role.php index 24e35ca2..d079cc35 100644 --- a/src/Pingpong/Trusty/Entities/Role.php +++ b/src/Pingpong/Trusty/Entities/Role.php @@ -22,7 +22,7 @@ class Role extends Model { */ public function permissions() { - return $this->belongsToMany(__NAMESPACE__ . '\\Permission')->withTimestamps(); + return $this->belongsToMany(config('trusty.model.permission'))->withTimestamps(); } /** diff --git a/src/Pingpong/Trusty/Traits/TrustyTrait.php b/src/Pingpong/Trusty/Traits/TrustyTrait.php index 95063595..a0d2d24c 100644 --- a/src/Pingpong/Trusty/Traits/TrustyTrait.php +++ b/src/Pingpong/Trusty/Traits/TrustyTrait.php @@ -9,7 +9,7 @@ trait TrustyTrait { */ public function roles() { - return $this->belongsToMany('Pingpong\Trusty\Entities\Role')->withTimestamps(); + return $this->belongsToMany(config('trusty.model.role'))->withTimestamps(); } /** diff --git a/src/Pingpong/Trusty/src/config/config.php b/src/Pingpong/Trusty/src/config/config.php new file mode 100644 index 00000000..df7192c0 --- /dev/null +++ b/src/Pingpong/Trusty/src/config/config.php @@ -0,0 +1,11 @@ + [ + 'user' => 'App\User', + 'role' => 'Pingpong\Trusty\Entities\Role', + 'permission' => 'Pingpong\Trusty\Entities\Permission', + ], + +]; \ No newline at end of file From 4b8de5146496e54916bb38fc825b03132e6d22de Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 18:03:35 +0700 Subject: [PATCH 073/357] Add PermissionTrait feature --- .../Exceptions/PermissionDeniedException.php | 3 ++ .../Trusty/Traits/PermissionTrait.php | 38 ++++++++++++++++++ src/Pingpong/Trusty/Trusty.php | 39 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 src/Pingpong/Trusty/Exceptions/PermissionDeniedException.php create mode 100644 src/Pingpong/Trusty/Traits/PermissionTrait.php diff --git a/src/Pingpong/Trusty/Exceptions/PermissionDeniedException.php b/src/Pingpong/Trusty/Exceptions/PermissionDeniedException.php new file mode 100644 index 00000000..96a29682 --- /dev/null +++ b/src/Pingpong/Trusty/Exceptions/PermissionDeniedException.php @@ -0,0 +1,3 @@ +beforeFilter(function () use ($permissions) + { + Trusty::filterByPermission($permissions); + }); + } + + /** + * Filter the specified request by the given roles. + * + * @param string|array $roles + * @return void + */ + public function beforeRole($roles) + { + $roles = is_array($roles) ? $roles : func_get_args(); + + $this->beforeFilter(function () use ($roles) + { + Trusty::filterByRole($roles); + }); + } +} \ No newline at end of file diff --git a/src/Pingpong/Trusty/Trusty.php b/src/Pingpong/Trusty/Trusty.php index 32d825ac..495c903e 100644 --- a/src/Pingpong/Trusty/Trusty.php +++ b/src/Pingpong/Trusty/Trusty.php @@ -3,6 +3,7 @@ use Illuminate\Auth\Guard; use Illuminate\Routing\Router; use Pingpong\Trusty\Entities\Permission; +use Pingpong\Trusty\Exceptions\PermissionDeniedException; class Trusty { @@ -69,4 +70,42 @@ public function forbidden() throw new Exceptions\ForbiddenException("Sorry, you don't have permission to access this page."); } + /** + * Filter the specified request by the given permissions. + * + * @param string|array $permissions + * @return void + */ + public function filterByPermission($permissions) + { + $permissions = is_array($permissions) ? $permissions : func_get_args(); + + foreach ($permissions as $permission) + { + if ( ! Auth::user()->can($permission)) + { + throw new PermissionDeniedException("You don't have permission to \"{$permission}\"."); + } + } + } + + /** + * Filter the specified request by the given roles. + * + * @param string|array $roles + * @return void + */ + public function filterByRole($roles) + { + $roles = is_array($roles) ? $roles : func_get_args(); + + foreach ($roles as $role) + { + if ( ! Auth::user()->is($role)) + { + throw new PermissionDeniedException("You aren't a \"{$role}\"."); + } + } + } + } \ No newline at end of file From 6e371216d02ba4c654cece24b90495a2193132ae Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 18:09:53 +0700 Subject: [PATCH 074/357] remove useless stuffs --- src/Pingpong/Trusty/.travis.yml | 13 ------------- .../2014_05_02_052410_create_role_user_table.php | 1 - 2 files changed, 14 deletions(-) delete mode 100644 src/Pingpong/Trusty/.travis.yml diff --git a/src/Pingpong/Trusty/.travis.yml b/src/Pingpong/Trusty/.travis.yml deleted file mode 100644 index 2774819b..00000000 --- a/src/Pingpong/Trusty/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php index cf204181..7a0b921f 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php @@ -1,6 +1,5 @@ Date: Mon, 16 Feb 2015 21:03:22 +0700 Subject: [PATCH 075/357] Use config helper & update config key --- .../migrations/2014_05_02_052410_create_role_user_table.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php index 7a0b921f..8fe897ff 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php @@ -1,5 +1,6 @@ integer('role_id')->unsigned()->index(); $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); $table->integer('user_id')->unsigned()->index(); - $table->foreign('user_id')->references('id')->on(Config::get('auth.table'))->onDelete('cascade'); + $table->foreign('user_id')->references('id')->on(config('trusty.model.user'))->onDelete('cascade'); $table->timestamps(); }); } From f712befbdf841d5a6e386b387fb4ac121a044f37 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 21:25:15 +0700 Subject: [PATCH 076/357] publish & merge config --- src/Pingpong/Trusty/TrustyServiceProvider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Trusty/TrustyServiceProvider.php b/src/Pingpong/Trusty/TrustyServiceProvider.php index 559995b8..d869d3d2 100644 --- a/src/Pingpong/Trusty/TrustyServiceProvider.php +++ b/src/Pingpong/Trusty/TrustyServiceProvider.php @@ -19,8 +19,10 @@ class TrustyServiceProvider extends ServiceProvider { public function boot() { $this->publishes([ - __DIR__ . '/src/migrations/' => base_path('/database/migrations') + __DIR__ . '/src/migrations/' => base_path('/database/migrations'), + __DIR__.'/src/config/config.php' => config_path('trusty.php') ]); + $this->mergeConfigFrom(__DIR__.'/src/config/config.php', 'trusty'); } /** From c0eaa81486f3cb24688c8c158441db913a2392b4 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 21:25:46 +0700 Subject: [PATCH 077/357] added new feature --- src/Pingpong/Trusty/Entities/Role.php | 56 +++++++-- src/Pingpong/Trusty/Traits/TrustyTrait.php | 130 +++++++++------------ 2 files changed, 103 insertions(+), 83 deletions(-) diff --git a/src/Pingpong/Trusty/Entities/Role.php b/src/Pingpong/Trusty/Entities/Role.php index d079cc35..d140b7cf 100644 --- a/src/Pingpong/Trusty/Entities/Role.php +++ b/src/Pingpong/Trusty/Entities/Role.php @@ -25,6 +25,45 @@ public function permissions() return $this->belongsToMany(config('trusty.model.permission'))->withTimestamps(); } + /** + * @param $query + * @param $search + * @return mixed + */ + public function scopeSearch($query, $search) + { + return $query->whereName($search) + ->orWhere('id', intval($search)) + ->orWhere('slug', intval($search)); + } + + /** + * @param $id + */ + public function addPermission($id) + { + $this->permissions()->attach($id); + } + + /** + * @param $ids + */ + public function removePermission($ids) + { + $ids = is_array($ids) ? $ids : func_get_args(); + + $this->permissions()->detach($ids); + } + + /** + * + */ + public function clearPermissions() + { + $this->removePermission($this->permissions->lists('id')); + } + + /** * Relation to "User". * @@ -32,18 +71,21 @@ public function permissions() */ public function users() { - return $this->belongsToMany(Config::get('auth.model'))->withTimestamps(); + return $this->belongsToMany(config('trusty.model.user'))->withTimestamps(); } /** - * Check whether the user role can perform the given permission. - * - * @param string $permission - * @return boolean + * @param $name + * @return bool */ - public function can($permission) + public function can($name) { - return in_array($permission, array_fetch($this->permissions->toArray(), 'slug')); + foreach ($this->permissions as $permission) + { + if ($permission->name == $name) return true; + } + + return false; } /** diff --git a/src/Pingpong/Trusty/Traits/TrustyTrait.php b/src/Pingpong/Trusty/Traits/TrustyTrait.php index a0d2d24c..3f4b570f 100644 --- a/src/Pingpong/Trusty/Traits/TrustyTrait.php +++ b/src/Pingpong/Trusty/Traits/TrustyTrait.php @@ -1,11 +1,12 @@ roles) ? $this->roles->lists('slug') : null; - } + $ids = is_array($idOrName) ? $idOrName : func_get_args(); - /** - * Get all roles from current user. - * - * @return \Illuminate\Database\Eloquent\Collection|null - */ - public function getPermissions() - { - return ! is_null($this->getRole()) ? $this->getRole()->permissions : null; - } + foreach ($ids as $search) + { + $role = Role::search($idOrName)->firstOrFail(); - /** - * Get user role from the current user. - * - * @return \Role - */ - public function getRole() - { - return $this->roles->first(); + $this->roles()->attach($role->id); + } } /** - * Get role id - * - * @return mixed + * @param $idOrName */ - public function getRoleId() + public function removeRole($idOrName) { - return $this->getRole() ? $this->getRole()->id : null; - } + $ids = is_array($idOrName) ? $idOrName : func_get_args(); - /** - * Get all permissions from the current user. - * - * @return array|null - */ - public function permissions() - { - return ! is_null($this->getPermissions()) ? $this->getPermissions()->lists('slug') : []; - } + foreach ($ids as $search) + { + $role = Role::search($search)->firstOrFail(); - /** - * Check whether the user has a given role. - * - * @param string $role - * @return boolean - */ - public function is($role) - { - return in_array($role, $this->getRoles()); + $this->roles()->detach($role->id); + } } /** - * Check whether the user has a given permission. * - * @param string $permission - * @return boolean */ - public function can($permission) + public function detachRoles() { - return in_array($permission, $this->permissions()); + $this->removeRole($this->roles->lists('id')); } /** - * Has role scope. - * - * @param Builder $query - * @param string $type - * @return Builder + * @param $name + * @return bool */ - public function scopeHasRole($query, $type) + public function is($name) { - return $query->whereHas('roles', function ($query) use ($type) + foreach ($this->roles as $role) { - $query->where('slug', $type); - }); + if ($role->name == $name) return true; + } + + return false; } /** - * Add role to this user. - * - * @param int $id + * @param $name + * @return bool */ - public function addRole($id) + public function can($name) { - $this->roles()->attach($id); + foreach ($this->roles as $role) + { + foreach ($role->permissions as $permission) + { + if ($permission->name == $name) return true; + } + } + + return false; } /** - * Update roles. - * - * @param int $id - * @return void + * @return Collection */ - public function updateRole($id) + public function getPermissionsAttribute() { - $this->roles()->detach($this->getRoleId()); + $permissions = new Collection; + + foreach ($this->roles as $role) + { + foreach ($role->permissions as $permission) + { + $permissions->push($permission); + } + } - $this->addRole($id); + return $permissions; } /** From 6a47e9a7798ddc3e7c0d065eaa7c651a03639909 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 22:06:32 +0700 Subject: [PATCH 078/357] use auth property instead of facade --- src/Pingpong/Trusty/Trusty.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Trusty/Trusty.php b/src/Pingpong/Trusty/Trusty.php index 495c903e..5edea9c5 100644 --- a/src/Pingpong/Trusty/Trusty.php +++ b/src/Pingpong/Trusty/Trusty.php @@ -82,7 +82,7 @@ public function filterByPermission($permissions) foreach ($permissions as $permission) { - if ( ! Auth::user()->can($permission)) + if ( ! $this->auth->user()->can($permission)) { throw new PermissionDeniedException("You don't have permission to \"{$permission}\"."); } @@ -101,7 +101,7 @@ public function filterByRole($roles) foreach ($roles as $role) { - if ( ! Auth::user()->is($role)) + if ( ! $this->auth->user()->is($role)) { throw new PermissionDeniedException("You aren't a \"{$role}\"."); } From 3f6e8586eeaa977f195d8b8b0270d4da9bf4d580 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 22:06:55 +0700 Subject: [PATCH 079/357] Also search for slug --- src/Pingpong/Trusty/Traits/TrustyTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Trusty/Traits/TrustyTrait.php b/src/Pingpong/Trusty/Traits/TrustyTrait.php index 3f4b570f..20fd4db9 100644 --- a/src/Pingpong/Trusty/Traits/TrustyTrait.php +++ b/src/Pingpong/Trusty/Traits/TrustyTrait.php @@ -59,7 +59,7 @@ public function is($name) { foreach ($this->roles as $role) { - if ($role->name == $name) return true; + if ($role->name == $name || $role->slug == $name) return true; } return false; @@ -75,7 +75,7 @@ public function can($name) { foreach ($role->permissions as $permission) { - if ($permission->name == $name) return true; + if ($permission->name == $name || $permission->slug == $name) return true; } } From bba4e3dac15d20742d2dace227069d830a0f9006 Mon Sep 17 00:00:00 2001 From: gravitano Date: Mon, 16 Feb 2015 22:17:16 +0700 Subject: [PATCH 080/357] Update trusty doc --- docs/trusty.md | 63 +++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/docs/trusty.md b/docs/trusty.md index 7e5dd144..e6df5141 100644 --- a/docs/trusty.md +++ b/docs/trusty.md @@ -1,5 +1,9 @@ ## Trusty - Roles and Permissions for Laravel 4 +- [Installation](#installation) +- [Creating A Role](#creating-a-role) +- [Creating A Permission](#creating-a-permission) + ### Server Requirements - PHP 5.4 or higher @@ -29,9 +33,9 @@ Next, Add new aliases in `app/config/app.php`. 'Permission' => 'Pingpong\Trusty\Entities\Permission', ``` -Next, migrate the database. +Next, publish the package's migrations. ``` -php artisan migrate --package=pingpong/trusty +php artisan vendor:publish ``` **NOTE:** If you want to modify the `roles` and `permissions` table, you can publish the migration. @@ -40,7 +44,7 @@ Done. ### Usage -Open your `app/models/User.php` file and use the `Pingpong\Trusty\Traits\TrustyTrait` trait. Look like this. +Add `Pingpong\Trusty\Traits\TrustyTrait` trait to your `User` model. For example. ```php ``` -Creating new Role. + +## Creating A Role. ```php Role::create([ 'name' => 'Administrator', @@ -96,7 +87,8 @@ Role::create([ ]); ``` -Creating new Permission. + +## Creating A Permission ```php Permission::create([ @@ -112,6 +104,7 @@ Permission::create([ ]); ``` + Set permission for the specified role. ```php @@ -127,15 +120,13 @@ $user = Auth::user(); $user->roles()->attach($role_id); ``` -Adding role to the user. + +## Adding role to the user. ```php +// by id Auth::user()->addRole(1); -``` - -Updating role user. -```php -$role_id = 1; -Auth::user()->updateRole($role_id); +// by name +Auth::user()->addRole('admin'); ``` Check role for current user. @@ -192,18 +183,8 @@ if($role->canManageUsers()) Get all permission from current users. ```php -$myPermissions = Auth::user()->getPermissions(); +$myPermissions = Auth::user()->permissions; dd($myPermissions); - -// or - -$permissions = Auth::user()->permissions(); -dd($permissions); -``` - -Get role for current user. -```php -$myRole = Auth::user()->getRole(); ``` Simple filtering route based on permission. @@ -240,11 +221,3 @@ App::error(function(Pingpong\Trusty\Exceptions\ForbiddenException $e) return Response::make($e->getMessage(), 403); }); ``` - -### License - -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) - - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pingpong-labs/trusty/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - From 6dc706ea5688b7fb7da2e4e41fbf5e9713269d21 Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 17 Feb 2015 10:29:53 +0700 Subject: [PATCH 081/357] remove call to method --- src/Pingpong/Themes/ThemesServiceProvider.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/ThemesServiceProvider.php index e14f9e74..4a9202bc 100644 --- a/src/Pingpong/Themes/ThemesServiceProvider.php +++ b/src/Pingpong/Themes/ThemesServiceProvider.php @@ -18,8 +18,6 @@ class ThemesServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('pingpong/themes', 'themes', __DIR__ . '/src'); - $this->registerNamespaces(); } From 985ed23049602c93218fa5fe1216eaf26dfdc9fb Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 17 Feb 2015 10:30:46 +0700 Subject: [PATCH 082/357] Update default theme path --- src/Pingpong/Themes/src/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/src/config/config.php b/src/Pingpong/Themes/src/config/config.php index 844acad4..11835674 100644 --- a/src/Pingpong/Themes/src/config/config.php +++ b/src/Pingpong/Themes/src/config/config.php @@ -4,6 +4,6 @@ 'default' => 'default', - 'path' => public_path('packages/pingpong/themes') + 'path' => base_path('themes') ); \ No newline at end of file From a7d1ba97e2b4858d03b0ef6668f4506611ae119e Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 17 Feb 2015 10:38:05 +0700 Subject: [PATCH 083/357] Register configuration file using new way --- src/Pingpong/Themes/ThemesServiceProvider.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/ThemesServiceProvider.php index 4a9202bc..37e11b0c 100644 --- a/src/Pingpong/Themes/ThemesServiceProvider.php +++ b/src/Pingpong/Themes/ThemesServiceProvider.php @@ -18,9 +18,25 @@ class ThemesServiceProvider extends ServiceProvider { */ public function boot() { + $this->registerConfig(); + $this->registerNamespaces(); } + /** + * Register configuration file. + * + * @return void + */ + protected function registerConfig() + { + $configPath = __DIR__ . '/src/config/config.php'; + + $this->publishes([$configPath => config_path('themes')]); + + $this->mergeConfigFrom($configPath, 'themes'); + } + /** * Register the themes namespaces. */ From c2cf4deca2177dfde99f79632bc13be3e57e6a6a Mon Sep 17 00:00:00 2001 From: gravitano Date: Tue, 17 Feb 2015 10:45:48 +0700 Subject: [PATCH 084/357] improvement in theme finder class --- src/Pingpong/Themes/Finder.php | 119 +++------------------------------ 1 file changed, 11 insertions(+), 108 deletions(-) diff --git a/src/Pingpong/Themes/Finder.php b/src/Pingpong/Themes/Finder.php index 5127e862..c10354eb 100644 --- a/src/Pingpong/Themes/Finder.php +++ b/src/Pingpong/Themes/Finder.php @@ -1,129 +1,32 @@ files = $files; - $this->config = $config; + public function __construct($path, Filesystem $finder = null) + { + $this->path = $path; + + $this->finder = $finder ?: new Filesystem; } - /** - * Get all themes. - * - * @return array - */ - public function all() + public function find() { - $themes = array(); + $found = $this->finder->in($path)->files()->name($this->filename)->depth('<= 3')->followLinks(); - if( ! $this->files->isDirectory($path = $this->getPath())) return $themes; + $themes = []; - $folders = $this->files->directories($path); - - foreach($folders as $theme) + foreach ($found as $file) { - $themes[] = basename($theme); + $themes[] = $file; } return $themes; } - - /** - * Set theme path. - * - * @param $path - * @return self - */ - public function setPath($path) - { - $this->path = $path; - - return $this; - } - - /** - * Get theme path. - * - * @return string - */ - public function getPath() - { - return $this->path ?: $this->config->get('themes::path'); - } - - /** - * Check whether the given theme in all themes. - * - * @param $theme - * @return bool - */ - public function has($theme) - { - return in_array($theme, $this->all()); - } - - /** - * Get theme path by given theme name. - * - * @param $theme - * @return null|string - */ - public function getThemePath($theme) - { - if( ! $this->has($theme)) return null; - - return $this->getPath() . "/{$theme}"; - } - - /** - * Get The Laravel Filesystem. - * - * @return Filesystem - */ - public function getFiles() - { - return $this->files; - } - - /** - * Get The Laravel Config Repository. - * - * @return Repository - */ - public function getConfig() - { - return $this->config; - } } \ No newline at end of file From c380029ef27a0c7a580a5fc8771ab653fbb68b5f Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 06:34:45 +0700 Subject: [PATCH 085/357] remove double brackets --- src/Pingpong/Menus/Presenters/Presenter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Menus/Presenters/Presenter.php b/src/Pingpong/Menus/Presenters/Presenter.php index 14b36403..b12a5f06 100644 --- a/src/Pingpong/Menus/Presenters/Presenter.php +++ b/src/Pingpong/Menus/Presenters/Presenter.php @@ -70,7 +70,7 @@ public function getChildMenuItems(MenuItem $item) { if($child->hasSubMenu()) { - $results.= $this->getMultiLevelDropdownWrapper(($child)); + $results.= $this->getMultiLevelDropdownWrapper($child); } elseif($child->isHeader()) { From 74934f2290fc5595835702e326d99c5357437af2 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 06:36:55 +0700 Subject: [PATCH 086/357] make base presenter class as an abstract class --- src/Pingpong/Menus/Presenters/Presenter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Menus/Presenters/Presenter.php b/src/Pingpong/Menus/Presenters/Presenter.php index b12a5f06..2f754afd 100644 --- a/src/Pingpong/Menus/Presenters/Presenter.php +++ b/src/Pingpong/Menus/Presenters/Presenter.php @@ -2,7 +2,7 @@ use Pingpong\Menus\MenuItem; -class Presenter implements PresenterInterface { +abstract class Presenter implements PresenterInterface { /** * Get open tag wrapper. From 5fc723743e151d72080f4887a7648e77e86094ee Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:22:03 +0700 Subject: [PATCH 087/357] Fix #4 --- src/Pingpong/Themes/Finder.php | 20 +++++++++++-------- src/Pingpong/Themes/Theme.php | 2 +- src/Pingpong/Themes/ThemesServiceProvider.php | 8 +++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Pingpong/Themes/Finder.php b/src/Pingpong/Themes/Finder.php index c10354eb..08940559 100644 --- a/src/Pingpong/Themes/Finder.php +++ b/src/Pingpong/Themes/Finder.php @@ -1,6 +1,7 @@ path = $path; - $this->finder = $finder ?: new Filesystem; + $this->finder = $finder ?: new SymfonyFinder; } public function find() { - $found = $this->finder->in($path)->files()->name($this->filename)->depth('<= 3')->followLinks(); - $themes = []; - - foreach ($found as $file) - { - $themes[] = $file; + + if(is_dir($path = $this->path)) + { + $found = $this->finder->in($this->path)->files()->name($this->filename)->depth('<= 3')->followLinks(); + + foreach ($found as $file) + { + $themes[] = $file; + } } return $themes; diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 70281a85..b46ccc3a 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -136,7 +136,7 @@ public function set($theme) */ public function all() { - return $this->finder->all(); + return $this->finder->find(); } /** diff --git a/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/ThemesServiceProvider.php index 37e11b0c..b3cb7284 100644 --- a/src/Pingpong/Themes/ThemesServiceProvider.php +++ b/src/Pingpong/Themes/ThemesServiceProvider.php @@ -32,9 +32,9 @@ protected function registerConfig() { $configPath = __DIR__ . '/src/config/config.php'; - $this->publishes([$configPath => config_path('themes')]); + $this->publishes([$configPath => config_path('themes.php')]); - $this->mergeConfigFrom($configPath, 'themes'); + $this->mergeConfigFrom($configPath, 'themes.php'); } /** @@ -54,7 +54,9 @@ public function register() { $this->app['themes'] = $this->app->share(function ($app) { - $finder = new Finder($app['files'], $app['config']); + $path = $app['config']->get('themes.path'); + + $finder = new Finder($path); return new Theme($finder, $app['config'], $app['view'], $app['translator']); }); From ca349a550ecf98bd63d0170aab2130a3ced113bc Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:33:04 +0700 Subject: [PATCH 088/357] Tweak some codes --- src/Pingpong/Themes/Finder.php | 40 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/Pingpong/Themes/Finder.php b/src/Pingpong/Themes/Finder.php index 08940559..629a05bc 100644 --- a/src/Pingpong/Themes/Finder.php +++ b/src/Pingpong/Themes/Finder.php @@ -5,29 +5,39 @@ class Finder { - protected $filename = 'theme.json'; - - protected $path; - - public function __construct($path, SymfonyFinderSymfonyFinder $finder = null) - { - $this->path = $path; - + /** + * The symfony finder instance. + * + * @var SymfonyFinder + */ + protected $finder; + + /** + * The constructor. + * + * @param $finder SymfonyFinder + */ + public function __construct(SymfonyFinder $finder = null) + { $this->finder = $finder ?: new SymfonyFinder; } - public function find() + /** + * Find the specified theme by searching a 'theme.json' file as identifier. + * + * @param string $path + * @param string $filename + * @return array + */ + public function find($path, $filename = 'theme.json') { $themes = []; - if(is_dir($path = $this->path)) + if(is_dir($path)) { - $found = $this->finder->in($this->path)->files()->name($this->filename)->depth('<= 3')->followLinks(); + $found = $this->finder->in($path)->files()->name($filename)->depth('<= 3')->followLinks(); - foreach ($found as $file) - { - $themes[] = $file; - } + foreach ($found as $file) $themes[] = $file; } return $themes; From d54ee5c4cd590eca9cdef661b9ec6cff2ad7857b Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:34:22 +0700 Subject: [PATCH 089/357] Fix service provider --- src/Pingpong/Themes/ThemesServiceProvider.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/ThemesServiceProvider.php index b3cb7284..f3e29eb2 100644 --- a/src/Pingpong/Themes/ThemesServiceProvider.php +++ b/src/Pingpong/Themes/ThemesServiceProvider.php @@ -54,11 +54,7 @@ public function register() { $this->app['themes'] = $this->app->share(function ($app) { - $path = $app['config']->get('themes.path'); - - $finder = new Finder($path); - - return new Theme($finder, $app['config'], $app['view'], $app['translator']); + return new Theme(new Finder, $app['config'], $app['view'], $app['translator']); }); } From 2292ead94df515391b0cb4765aea912dd733445a Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:34:32 +0700 Subject: [PATCH 090/357] Fix namespace syntax --- src/Pingpong/Themes/Theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index b46ccc3a..8b4e84cc 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -103,7 +103,7 @@ public function getThemePath($theme) */ public function getCurrent() { - return $this->current ?: $this->config->get('themes::default'); + return $this->current ?: $this->config->get('themes.default'); } /** From 01ba8799702c26a501445d5640083372642ab5b3 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:34:51 +0700 Subject: [PATCH 091/357] remove namespace for config --- src/Pingpong/Themes/Theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 8b4e84cc..70a18f5e 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -66,7 +66,7 @@ public function registerNamespaces() { foreach($this->all() as $theme) { - foreach(array('config', 'views', 'lang') as $hint) + foreach(array('views', 'lang') as $hint) { $this->{$hint}->addNamespace($theme, $this->getNamespacePath($theme, $hint)); } From 599c5cb3d8740f83e6448807fa31ebd13c444e5f Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:36:23 +0700 Subject: [PATCH 092/357] Fix call to find method --- src/Pingpong/Themes/Theme.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 70a18f5e..44d0b74f 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -42,6 +42,10 @@ class Theme { */ protected $current; + protected $path; + + protected $filename = 'theme.json'; + /** * The constructor. * @@ -115,6 +119,7 @@ public function getCurrent() public function setCurrent($current) { $this->current = $current; + return $this; } @@ -136,7 +141,7 @@ public function set($theme) */ public function all() { - return $this->finder->find(); + return $this->finder->find($this->path, $this->filename); } /** From 831f6b1a86b185f9991f7610e0fb0b9236bd1624 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:38:25 +0700 Subject: [PATCH 093/357] Tweak themes code --- src/Pingpong/Themes/Theme.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 44d0b74f..59179788 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -97,7 +97,7 @@ protected function getNamespacePath($theme, $type) */ public function getThemePath($theme) { - return $this->finder->getThemePath($theme); + return $this->path ."/{$theme}"; } /** @@ -152,7 +152,7 @@ public function all() */ public function has($theme) { - return $this->finder->has($theme); + return in_array($theme, $this->all()); } /** @@ -174,7 +174,7 @@ public function exists($theme) */ public function setPath($path) { - return $this->finder->setPath($path); + return $this->path = $path; } /** @@ -184,7 +184,7 @@ public function setPath($path) */ public function getPath() { - return $this->finder->getPath(); + return $this->path; } /** From b61f7321baca0c79086f02dd63382cd3eaed4cf0 Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:40:25 +0700 Subject: [PATCH 094/357] Remove useless files --- src/Pingpong/Themes/.travis.yml | 13 ------------- src/Pingpong/Themes/phpunit.xml | 18 ------------------ 2 files changed, 31 deletions(-) delete mode 100644 src/Pingpong/Themes/.travis.yml delete mode 100644 src/Pingpong/Themes/phpunit.xml diff --git a/src/Pingpong/Themes/.travis.yml b/src/Pingpong/Themes/.travis.yml deleted file mode 100644 index 2774819b..00000000 --- a/src/Pingpong/Themes/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/src/Pingpong/Themes/phpunit.xml b/src/Pingpong/Themes/phpunit.xml deleted file mode 100644 index 3347b75b..00000000 --- a/src/Pingpong/Themes/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - From db33e09a4481e10955e9a15f084d4bc45a8665cf Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:40:57 +0700 Subject: [PATCH 095/357] Support for L5 only --- src/Pingpong/Themes/composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Pingpong/Themes/composer.json b/src/Pingpong/Themes/composer.json index aeaf15c3..afb1cc61 100644 --- a/src/Pingpong/Themes/composer.json +++ b/src/Pingpong/Themes/composer.json @@ -11,11 +11,11 @@ ], "require": { "php": ">=5.4.0", - "illuminate/support": "4.*|~5", - "illuminate/filesystem": "4.*|~5", - "illuminate/translation": "4.*|~5", - "illuminate/view": "4.*|~5", - "illuminate/config": "4.*|~5" + "illuminate/support": "5.0.*", + "illuminate/filesystem": "5.0.*", + "illuminate/translation": "5.0.*", + "illuminate/view": "5.0.*", + "illuminate/config": "5.0.*" }, "require-dev": { "phpunit/phpunit": "4.1.*", From 97e8f05f5d4efa131d206a69986720296286497e Mon Sep 17 00:00:00 2001 From: gravitano Date: Wed, 18 Feb 2015 18:41:16 +0700 Subject: [PATCH 096/357] Upgrade dependencies version --- src/Pingpong/Themes/composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Themes/composer.json b/src/Pingpong/Themes/composer.json index afb1cc61..820527db 100644 --- a/src/Pingpong/Themes/composer.json +++ b/src/Pingpong/Themes/composer.json @@ -18,8 +18,8 @@ "illuminate/config": "5.0.*" }, "require-dev": { - "phpunit/phpunit": "4.1.*", - "mockery/mockery": "0.9.*" + "phpunit/phpunit": "~4", + "mockery/mockery": "~0.9" }, "autoload": { "psr-4": { From 037f164154f2da6820bbce9901fe04f32ed0ae54 Mon Sep 17 00:00:00 2001 From: gravitano Date: Sun, 22 Feb 2015 13:43:59 +0700 Subject: [PATCH 097/357] return generated path --- src/Pingpong/Generators/FileGenerator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/FileGenerator.php b/src/Pingpong/Generators/FileGenerator.php index 7c6c4d5d..0616366d 100644 --- a/src/Pingpong/Generators/FileGenerator.php +++ b/src/Pingpong/Generators/FileGenerator.php @@ -128,7 +128,9 @@ public function generateFile() $this->autoCreateDirectory($path); - return $this->filesystem->put($path, $this->getTemplateContents()); + $this->filesystem->put($path, $this->getTemplateContents()); + + return $path; } /** From 90f90595b9841d5524636b476c75fa36e5e5e5f7 Mon Sep 17 00:00:00 2001 From: gravitano Date: Sun, 22 Feb 2015 13:44:17 +0700 Subject: [PATCH 098/357] Fix throws docblock --- src/Pingpong/Generators/MigrationGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/MigrationGenerator.php b/src/Pingpong/Generators/MigrationGenerator.php index 13550912..9dd0b904 100644 --- a/src/Pingpong/Generators/MigrationGenerator.php +++ b/src/Pingpong/Generators/MigrationGenerator.php @@ -76,7 +76,7 @@ protected function getClassName() /** * @return Stub - * @throws Invalidname + * @throws InvalidMigrationNameException */ public function getTemplateContents() { From 9ba57b327491a3326acca52e06ab564471fbac56 Mon Sep 17 00:00:00 2001 From: gravitano Date: Sun, 22 Feb 2015 13:46:04 +0700 Subject: [PATCH 099/357] fix branch --- build/pull.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pull.sh b/build/pull.sh index 979068bb..bfc3a186 100755 --- a/build/pull.sh +++ b/build/pull.sh @@ -11,5 +11,5 @@ git subtree pull --prefix=src/Pingpong/Generators git@github.com:pingpong-labs/g git subtree pull --prefix=src/Pingpong/Validator git@github.com:pingpong-labs/validator.git 2.0 --squash git subtree pull --prefix=src/Pingpong/Oembed git@github.com:pingpong-labs/oembed.git 2.0 --squash git subtree pull --prefix=src/Pingpong/Trusty git@github.com:pingpong-labs/trusty.git 2.0 --squash -git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2. --squash +git subtree pull --prefix=src/Pingpong/Themes git@github.com:pingpong-labs/themes.git 2.0 --squash git subtree pull --prefix=docs git@github.com:pingpong-labs/docs.git 2.0 --squash \ No newline at end of file From 087c29882bd3e3a58c3d228fa9a26f046274d66f Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 00:46:29 +0700 Subject: [PATCH 100/357] Fix themes tests --- tests/Themes/ThemeTest.php | 146 +++++++++++-------------------------- 1 file changed, 43 insertions(+), 103 deletions(-) diff --git a/tests/Themes/ThemeTest.php b/tests/Themes/ThemeTest.php index 57afc07d..6c54db44 100644 --- a/tests/Themes/ThemeTest.php +++ b/tests/Themes/ThemeTest.php @@ -15,132 +15,72 @@ protected function getPath() return __DIR__ . '/../../fixture/themes/'; } - function testInitialize() + public function setUp() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $this->assertInstanceOf('Pingpong\Themes\Theme', $theme); + $this->finder = m::mock('Pingpong\Themes\Finder'); + $this->config = m::mock('Illuminate\Config\Repository'); + $this->view = m::mock('Illuminate\View\Factory'); + $this->lang = m::mock('Illuminate\Translation\Translator'); + $this->theme = new Theme($this->finder, $this->config, $this->view, $this->lang); + $this->theme->setPath($this->getPath()); } - function testGetAllThemes() + public function testGetAllThemes() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $finder->shouldReceive('all')->once()->andReturn(['default']); - - $themes = $theme->all(); - + $this->finder->shouldReceive('find')->with($this->getPath(), 'theme.json')->once()->andReturn(['default']); + $themes = $this->theme->all(); $this->assertTrue(is_array($themes)); - $this->assertArrayHasKey(0, $themes); - $this->assertArrayNotHasKey(1, $themes); } - function testHasTheme() + public function testSetAndGetThemePath() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $finder->shouldReceive('has')->once()->with('default')->andReturn(true); - - $hasTheme = $theme->has('default'); + $this->theme->setPath('path/to'); + $this->assertEquals('path/to', $this->theme->getPath()); + } - $this->assertTrue($hasTheme); + public function testRegisterNamespaces() + { + $this->finder->shouldReceive('find')->with($this->getPath(), 'theme.json')->once()->andReturn(['default']); + $this->view->shouldReceive('addNamespace')->once(); + $this->lang->shouldReceive('addNamespace')->once(); + $themes = $this->theme->registerNamespaces(); } - function testGetCurrentThemeAndWillReturnFromConfig() + public function testGetThemePathForSpecifiedTheme() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $config->shouldReceive('get')->once()->with('themes::default')->andReturn('default'); - - $currentTheme = $theme->getCurrent(); - - $this->assertEquals($currentTheme, 'default'); + $this->theme->setPath('path/to'); + $themePath = $this->theme->getThemePath('default'); + $this->assertEquals('path/to/default', $themePath); } - function testSetAndGetCurrentTheme() + public function testSetAndGetCurrentTheme() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $theme->setCurrent('white'); - - $currentTheme = $theme->getCurrent(); - - $this->assertEquals($currentTheme, 'white'); + $this->theme->setCurrent('foo'); + $this->assertEquals('foo', $this->theme->getCurrent()); } - function testGetThemesPath() + public function testHasTheme() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $finder->shouldReceive('getPath')->once()->andReturn($this->getPath()); - - $path = $theme->getPath(); - - $this->assertEquals($path, $this->getPath()); + $this->finder->shouldReceive('find')->with($this->getPath(), 'theme.json')->times(3)->andReturn(['foo', 'bar']); + $this->assertTrue($this->theme->has('foo')); + $this->assertTrue($this->theme->exists('bar')); + $this->assertFalse($this->theme->has('baz')); } - function testThemePathForTheSpecifiedTheme() + public function testLoadViewFromCurrentTheme() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $themePath = $this->getPath() . "/default"; - - $finder->shouldReceive('getThemePath')->once()->with('default')->andReturn($themePath); - - $path = $theme->getThemePath('default'); - - $this->assertEquals($path, $themePath); + $this->config->shouldReceive('get')->once()->andreturn('foo'); + $this->view->shouldReceive('make')->once()->andreturn('bar'); + $response = $this->theme->view('index'); + $this->assertEquals('bar', $response); } - function testSetAndGetThemesPath() + public function testLoadLangFromCurrentTheme() { - $finder = m::mock('Pingpong\Themes\Finder'); - $config = m::mock('Illuminate\Config\Repository'); - $view = m::mock('Illuminate\View\Factory'); - $lang = m::mock('Illuminate\Translation\Translator'); - - $theme = new Theme($finder, $config, $view, $lang); - - $finder->shouldReceive('setPath')->once()->with($this->getPath())->andReturn($this->getPath()); - $finder->shouldReceive('getPath')->once()->andReturn($this->getPath()); - - $theme->setPath($this->getPath()); - - $this->assertEquals($theme->getPath(), $this->getPath()); + $this->config->shouldReceive('get')->once()->andreturn('foo'); + $this->lang->shouldReceive('get')->once()->andreturn('bar'); + $result = $this->theme->lang('index'); + $this->assertEquals('bar', $result); } + } \ No newline at end of file From 430d8e7426b5e181d79abe49662f5f3f0b1e8bc6 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 05:32:37 +0700 Subject: [PATCH 101/357] Update forlder name: Filters to Middleware. Fixes #4 --- src/Pingpong/Modules/src/config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Modules/src/config/config.php b/src/Pingpong/Modules/src/config/config.php index baf90822..2bcaf90a 100644 --- a/src/Pingpong/Modules/src/config/config.php +++ b/src/Pingpong/Modules/src/config/config.php @@ -76,7 +76,7 @@ 'repository' => 'Repositories', 'seeder' => 'Database/Seeders', 'controller' => 'Http/Controllers', - 'filter' => 'Http/Filters', + 'filter' => 'Http/Middleware', 'request' => 'Http/Requests', 'provider' => 'Providers', 'lang' => 'Resources/lang', @@ -131,4 +131,4 @@ 'lifetime' => 60 ] -]; \ No newline at end of file +]; From 2c166de651887f347f7f9795a404a6f21852c9f1 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 14:55:54 +0700 Subject: [PATCH 102/357] Add crud generator --- src/Pingpong/Generators/CrudGenerator.php | 299 ++++++++++++++++ .../Scaffold/ControllerGenerator.php | 172 +++++++++ .../Generators/Scaffold/FormGenerator.php | 60 ++++ .../Generators/Stubs/form/checkbox.stub | 7 + src/Pingpong/Generators/Stubs/form/input.stub | 6 + .../Generators/Stubs/form/password.stub | 6 + src/Pingpong/Generators/Stubs/form/radio.stub | 7 + .../Generators/Stubs/form/select.stub | 6 + src/Pingpong/Generators/Stubs/form/text.stub | 6 + .../Generators/Stubs/form/textarea.stub | 6 + .../Generators/Stubs/scaffold/controller.stub | 110 ++++++ .../Stubs/scaffold/views/blank.stub | 0 .../Stubs/scaffold/views/create.stub | 17 + .../Generators/Stubs/scaffold/views/edit.stub | 17 + .../Generators/Stubs/scaffold/views/form.stub | 17 + .../Stubs/scaffold/views/index.stub | 45 +++ .../Generators/Stubs/scaffold/views/show.stub | 24 ++ src/Pingpong/Generators/ViewGenerator.php | 331 ++++++++++++++++++ 18 files changed, 1136 insertions(+) create mode 100644 src/Pingpong/Generators/CrudGenerator.php create mode 100644 src/Pingpong/Generators/Scaffold/ControllerGenerator.php create mode 100644 src/Pingpong/Generators/Scaffold/FormGenerator.php create mode 100644 src/Pingpong/Generators/Stubs/form/checkbox.stub create mode 100644 src/Pingpong/Generators/Stubs/form/input.stub create mode 100644 src/Pingpong/Generators/Stubs/form/password.stub create mode 100644 src/Pingpong/Generators/Stubs/form/radio.stub create mode 100644 src/Pingpong/Generators/Stubs/form/select.stub create mode 100644 src/Pingpong/Generators/Stubs/form/text.stub create mode 100644 src/Pingpong/Generators/Stubs/form/textarea.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/controller.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/views/blank.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/views/create.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/views/edit.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/views/form.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/views/index.stub create mode 100644 src/Pingpong/Generators/Stubs/scaffold/views/show.stub create mode 100644 src/Pingpong/Generators/ViewGenerator.php diff --git a/src/Pingpong/Generators/CrudGenerator.php b/src/Pingpong/Generators/CrudGenerator.php new file mode 100644 index 00000000..1ebd5f05 --- /dev/null +++ b/src/Pingpong/Generators/CrudGenerator.php @@ -0,0 +1,299 @@ +options = $options; + $this->console = $console; + } + + /** + * @param Command $console + * @return $this + */ + public function setConsole(Command $console) + { + $this->console = $console; + + return $this; + } + + /** + * @param $message + * @return bool + */ + public function confirm($message) + { + return $this->console->confirm($message); + } + + /** + * @param $command + * @param array $arguments + */ + public function call($command, array $arguments) + { + $this->console->call($command, $arguments); + } + + /** + * @param $key + * @param null $default + * @return mixed + */ + public function option($key, $default = null) + { + return array_get($this->options, $key, $default); + } + + /** + * + */ + public function generate() + { + $this->generateModel(); + $this->generateMigration(); + $this->generateController(); + $this->generateRequest(); + $this->runMigration(); + $this->generateView(); + $this->dumpAutoload(); + } + + /** + * @return bool + */ + public function hasPrefix() + { + return ! is_null($this->getPrefix()); + } + + /** + * @return mixed|string + */ + public function getPrefix() + { + return Str::studly($this->option('prefix')); + } + + /** + * @return mixed|string + */ + public function getModel() + { + return Str::studly($this->option('entity')); + } + + /** + * @return string + */ + public function getController() + { + $class = Str::studly(Str::plural($this->option('entity'))); + + if ($prefix = $this->getPrefix()) + { + $class = $prefix . '/' . $class; + } + + return $class . 'Controller'; + } + + /** + * @return string + */ + public function getMigration() + { + return 'create_' . $this->getPluralEntityName() . '_table'; + } + + /** + * @return string + */ + public function getPluralEntityName() + { + return Str::lower(Str::plural($this->option('entity'))); + } + + /** + * @return string + */ + public function getSingularEntityName() + { + return Str::lower(Str::singular($this->option('entity'))); + } + + /** + * @return mixed + */ + public function getTable() + { + return $this->option('entity'); + } + + /** + * + */ + public function generateModel() + { + $name = $this->getModel(); + + if ($this->confirm("Do you want me to create a new model: {$name} ? [yes|no]")) + { + $this->call('make:model', compact('name')); + } + } + + /** + * + */ + public function generateMigration() + { + $name = $this->getMigration(); + + if ($this->confirm("Do you want me to create a new migration: {$name} ? [yes|no]")) + { + $path = base_path('database/migrations'); + + $fields = $this->option('fields'); + + $file = (new MigrationGenerator($path, $name, $fields))->generate(); + + $this->console->info("File created : {$file}"); + } + } + + /** + * + */ + public function generateController() + { + try + { + $name = $this->getController(); + + if ($this->confirm("Do you want me to create a new controller: {$name} ? [yes|no]")) + { + $generator = new ControllerGenerator([ + 'name' => $name, + 'entity' => $this->option('entity'), + 'prefix' => $this->getPrefix(), + 'model' => $this->getModel() + ]); + + $generator->generate(); + } + } + catch (FileAlreadyExistException $e) + { + $this->console->error("Controller already exists!"); + } + } + + /** + * + */ + public function generateView() + { + if ($this->confirm('Do you want me to create views?')) + { + foreach (['index', 'create', 'edit', 'show', 'form'] as $view) + { + $generator = new ViewGenerator([ + 'name' => $view, + 'entity' => $this->option('entity'), + 'form' => $this->option('form'), + 'prefix' => $this->getPrefix(), + 'fields' => $this->option('fields'), + 'table-heading' => $this->option('table-heading'), + 'view-layout' => $this->option('view-layout', 'layouts.master'), + 'table' => $this->option('table'), + ]); + + $message = $generator->generate(); + + $this->console->info($message); + } + } + } + + /** + * @param string $type + * @return string + */ + public function getRequestName($type = 'Create') + { + $entityPrefix = Str::studly(Str::plural($this->option('entity'))); + + $class = $entityPrefix . '/' . $type . Str::studly($this->option('entity')); + + if ($this->hasPrefix()) + { + $class = $this->getPrefix() . '/' . $class; + } + + return $class . 'Request'; + } + + /** + * + */ + public function generateRequest() + { + if ($this->confirm("Do you want me to create a new form request class? [yes|no]")) + { + $this->call('make:request', [ + 'name' => $this->getRequestName('Create') + ]); + + $this->call('make:request', [ + 'name' => $this->getRequestName('Update') + ]); + } + } + + /** + * + */ + protected function runMigration() + { + if ($this->confirm("Do you want to all migrations now? [yes|no]")) + { + $this->call('migrate', []); + } + } + + /** + * Dump autoload. + * + * @return void + */ + protected function dumpAutoload() + { + passthru('composer dump -o'); + + $this->call('optimize', []); + } + +} \ No newline at end of file diff --git a/src/Pingpong/Generators/Scaffold/ControllerGenerator.php b/src/Pingpong/Generators/Scaffold/ControllerGenerator.php new file mode 100644 index 00000000..51179a5f --- /dev/null +++ b/src/Pingpong/Generators/Scaffold/ControllerGenerator.php @@ -0,0 +1,172 @@ +options = $options; + } + + public function getClassName() + { + return Str::studly(Str::plural(str_replace('Controller', '', $this->option('name')))) . 'Controller'; + } + + public function getPrefixBackSlash() + { + return $this->prefix ? '\\' . $this->prefix : null; + } + + public function getPrefixDot() + { + return Str::lower($this->prefix ? $this->prefix . '.' : null); + } + + public function getStudlyEntityName() + { + return Str::studly(Str::singular($this->entity)); + } + + public function getStudlyPluralEntityName() + { + return Str::studly(Str::plural($this->entity)); + } + + public function getLowerPluralEntityName() + { + return Str::lower(Str::plural($this->entity)); + } + + public function getLowerSingularEntityName() + { + return Str::lower(Str::singular($this->entity)); + } + + public function getModel() + { + return $this->getAppNamespace() . $this->model; + } + + public function getStubReplacements() + { + return [ + 'MODEL' => $this->getModel(), + 'ENTITY' => $this->entity, + 'PREFIX_BACKSLASH' => $this->getPrefixBackSlash(), + 'PREFIX_DOT' => $this->getPrefixDot(), + 'STUDLY_ENTITY' => $this->getStudlyEntityName(), + 'LOWER_PLURAL_ENTITY' => $this->getLowerPluralEntityName(), + 'LOWER_SINGULAR_ENTITY' => $this->getLowerSingularEntityName(), + 'STUDLY_PLURAL_ENTITY' => $this->getStudlyPluralEntityName() + ]; + } + + /** + * Get template contents. + * + * @return string + */ + public function getTemplateContents() + { + return new Stub($this->stub, array_merge( + $this->getDefaultReplacements(), + $this->getStubReplacements() + ) + ); + } + + /** + * Generate a new file. + * + * @throws FileAlreadyExistException + * @return bool + */ + public function generateFile() + { + $path = $this->getDestinationFilePath(); + + if($this->filesystem->exists($path)) + { + throw new FileAlreadyExistException("File already exist : {$path}"); + } + + $this->autoCreateDirectory($path); + + return $this->filesystem->put($path, $this->getTemplateContents()); + } + + /** + * Auto create directory. + * + * @param string $path + * @return void + */ + protected function autoCreateDirectory($path) + { + if( ! is_dir($dir = dirname($path))) + { + $this->filesystem->makeDirectory($dir); + } + } + + /** + * Get destination filepath. + * + * @return string + */ + public function getDestinationFilePath() + { + return $this->path . '/' . $this->getFilename(); + } + + /** + * Get filename. + * + * @return string + */ + public function getFilename() + { + return $this->getClassName() . '.php'; + } + + /** + * Generate the file. + * + * @return bool + */ + public function generate() + { + return $this->generateFile(); + } + + /** + * Get default replacements. + * + * @return array + */ + public function getDefaultReplacements() + { + return ['CLASS_NAME' => $this->getClassName()]; + } + + public function __get($key) + { + return $this->option($key); + } + +} \ No newline at end of file diff --git a/src/Pingpong/Generators/Scaffold/FormGenerator.php b/src/Pingpong/Generators/Scaffold/FormGenerator.php new file mode 100644 index 00000000..93898014 --- /dev/null +++ b/src/Pingpong/Generators/Scaffold/FormGenerator.php @@ -0,0 +1,60 @@ +fields = $fields; + } + + /** + * Generate the form. + * + * @return string + */ + public function generate() + { + $fields = explode(',', $this->fields); + + $result = ''; + + foreach ($fields as $field) + { + list($name, $type) = explode(':', $field); + + $label = ucfirst($name); + + $result .= PHP_EOL.$this->getStub($type, compact('name', 'label', 'type'))->getContents().PHP_EOL; + } + + return $result; + } + + /** + * Get stub for specified form type. + * + * @param string $type + * @param array $replacements + * @return string + */ + protected function getStub($type, array $replacements) + { + return new Stub('form/' . $type, $replacements); + } + +} \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/checkbox.stub b/src/Pingpong/Generators/Stubs/form/checkbox.stub new file mode 100644 index 00000000..f793aed6 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/checkbox.stub @@ -0,0 +1,7 @@ +
    + {!! Form::label('$NAME$', '', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::checkbox('$NAME$') !!} + $LABEL$ +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/input.stub b/src/Pingpong/Generators/Stubs/form/input.stub new file mode 100644 index 00000000..838367bd --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/input.stub @@ -0,0 +1,6 @@ +
    + {!! Form::label('$NAME$', '$LABEL$:', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::$TYPE$('$NAME$', null, ['class' => 'form-control']) !!} +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/password.stub b/src/Pingpong/Generators/Stubs/form/password.stub new file mode 100644 index 00000000..6a2323d5 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/password.stub @@ -0,0 +1,6 @@ +
    + {!! Form::label('$NAME$', '$LABEL$:', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::password('$NAME$', ['class' => 'form-control']) !!} +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/radio.stub b/src/Pingpong/Generators/Stubs/form/radio.stub new file mode 100644 index 00000000..a7a31773 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/radio.stub @@ -0,0 +1,7 @@ +
    + {!! Form::label('$NAME$', '', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::radio('$NAME$') !!} + $LABEL$ +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/select.stub b/src/Pingpong/Generators/Stubs/form/select.stub new file mode 100644 index 00000000..84b2cfdc --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/select.stub @@ -0,0 +1,6 @@ +
    + {!! Form::label('$NAME$', '$LABEL$:', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::select('$NAME$', [], null, ['class' => 'form-control']) !!} +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/text.stub b/src/Pingpong/Generators/Stubs/form/text.stub new file mode 100644 index 00000000..1d74b7f9 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/text.stub @@ -0,0 +1,6 @@ +
    + {!! Form::label('$NAME$', '$LABEL$:', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::text('$NAME$', null, ['class' => 'form-control']) !!} +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/form/textarea.stub b/src/Pingpong/Generators/Stubs/form/textarea.stub new file mode 100644 index 00000000..7ef5beb3 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/form/textarea.stub @@ -0,0 +1,6 @@ +
    + {!! Form::label('$NAME$', '$LABEL$:', ['class' => 'col-md-2 control-label']) !!} +
    + {!! Form::textarea('$NAME$', null, ['class' => 'form-control']) !!} +
    +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/scaffold/controller.stub b/src/Pingpong/Generators/Stubs/scaffold/controller.stub new file mode 100644 index 00000000..42509bea --- /dev/null +++ b/src/Pingpong/Generators/Stubs/scaffold/controller.stub @@ -0,0 +1,110 @@ +paginate(20); + + $no = $$LOWER_PLURAL_ENTITY$->firstItem(); + + return view('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.index', compact('$LOWER_PLURAL_ENTITY$', 'no')); + } + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function create() + { + return view('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.create'); + } + + /** + * Store a newly created resource in storage. + * + * @return Response + */ + public function store(Create$STUDLY_ENTITY$Request $request) + { + $$LOWER_SINGULAR_ENTITY$ = $STUDLY_ENTITY$::create($request->all()); + + return redirect()->route('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return Response + */ + public function show($id) + { + $$LOWER_SINGULAR_ENTITY$ = $STUDLY_ENTITY$::findOrFail($id); + + return view('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.show', compact('$LOWER_SINGULAR_ENTITY$')); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return Response + */ + public function edit($id) + { + $$LOWER_SINGULAR_ENTITY$ = $STUDLY_ENTITY$::findOrFail($id); + + return view('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.edit', compact('$LOWER_SINGULAR_ENTITY$')); + } + + /** + * Update the specified resource in storage. + * + * @param int $id + * @return Response + */ + public function update(Update$STUDLY_ENTITY$Request $request, $id) + { + $$LOWER_SINGULAR_ENTITY$ = $STUDLY_ENTITY$::findOrFail($id); + + $$LOWER_SINGULAR_ENTITY$->update($request->all()); + + return redirect()->route('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return Response + */ + public function destroy($id) + { + $$LOWER_SINGULAR_ENTITY$ = $STUDLY_ENTITY$::findOrFail($id); + + $$LOWER_SINGULAR_ENTITY$->delete(); + + return redirect()->route('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.index'); + } + +} diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/blank.stub b/src/Pingpong/Generators/Stubs/scaffold/views/blank.stub new file mode 100644 index 00000000..e69de29b diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/create.stub b/src/Pingpong/Generators/Stubs/scaffold/views/create.stub new file mode 100644 index 00000000..54988e27 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/scaffold/views/create.stub @@ -0,0 +1,17 @@ +@extends('$VIEW_LAYOUT$') + +@section('content') + +
    +
    + Add New $STUDLY_SINGULAR_ENTITY$ +
    + Back +
    +
    +
    + @include('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.form') +
    +
    + +@stop \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub b/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub new file mode 100644 index 00000000..1116a357 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub @@ -0,0 +1,17 @@ +@extends('$VIEW_LAYOUT$') + +@section('content') + +
    +
    + Edit $STUDLY_SINGULAR_ENTITY$ +
    + Back +
    +
    +
    + @include('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.form', ['model' => $$LOWER_SINGULAR_ENTITY$) +
    +
    + +@stop \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/form.stub b/src/Pingpong/Generators/Stubs/scaffold/views/form.stub new file mode 100644 index 00000000..fc213267 --- /dev/null +++ b/src/Pingpong/Generators/Stubs/scaffold/views/form.stub @@ -0,0 +1,17 @@ +@include('errors.validation') + +
    + @if (isset($model)) + {!! Form::model($model, ['files' => true, 'method' => 'PUT', 'route' => ['$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.update', $model->id]]) !!} + @else + {!! Form::open(['files' => true, 'route' => '$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.store']) !!} + @endif + $FORM_FIELDS$ +
    + +
    + {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} +
    +
    + {!! Form::close() !!} +
    \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/index.stub b/src/Pingpong/Generators/Stubs/scaffold/views/index.stub new file mode 100644 index 00000000..6c675b4f --- /dev/null +++ b/src/Pingpong/Generators/Stubs/scaffold/views/index.stub @@ -0,0 +1,45 @@ +@extends('$VIEW_LAYOUT$') + +@section('content') +
    +
    + All $STUDLY_PLURAL_ENTITY$ +
    + Add New +
    +
    + + + + $TABLE_HEADING$ + + + + + @foreach ($$LOWER_PLURAL_ENTITY$ as $$LOWER_SINGULAR_ENTITY$) + + + $TABLE_BODY$ + + + + @endforeach + +
    #Created AtAction
    {!! $no !!} +
    + + + + @include('modals.delete', [ + 'url' => route('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.destroy', $$LOWER_SINGULAR_ENTITY$->id), + 'model' => $$LOWER_SINGULAR_ENTITY$ + ]) +
    +
    + @if($$LOWER_PLURAL_ENTITY$->hasMorePages()) + + @endif +
    +@stop \ No newline at end of file diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/show.stub b/src/Pingpong/Generators/Stubs/scaffold/views/show.stub new file mode 100644 index 00000000..a28430ac --- /dev/null +++ b/src/Pingpong/Generators/Stubs/scaffold/views/show.stub @@ -0,0 +1,24 @@ +@extends('$VIEW_LAYOUT$') + +@section('content') +
    +
    + Show $STUDLY_SINGULAR_ENTITY$ +
    + Edit + Back +
    +
    + + + + + + $SHOW_BODY$ + + + + +
    ID{!! $$LOWER_SINGULAR_ENTITY$->id !!}
    Created At{!! $$LOWER_SINGULAR_ENTITY$->created_at !!}
    +
    +@stop \ No newline at end of file diff --git a/src/Pingpong/Generators/ViewGenerator.php b/src/Pingpong/Generators/ViewGenerator.php new file mode 100644 index 00000000..914aab1c --- /dev/null +++ b/src/Pingpong/Generators/ViewGenerator.php @@ -0,0 +1,331 @@ +options = $options; + } + + /** + * @return string + */ + public function getStub() + { + return 'scaffold/views/' . $this->option('name', 'blank'); + } + + /** + * @return null|string + */ + public function getPrefixBackSlash() + { + return $this->prefix ? '\\' . $this->prefix : null; + } + + /** + * @return string + */ + public function getPrefixDot() + { + return Str::lower($this->prefix ? $this->prefix . '.' : null); + } + + /** + * @return mixed|string + */ + public function getStudlyEntityName() + { + return Str::studly(Str::singular($this->entity)); + } + + /** + * @return mixed|string + */ + public function getStudlyPluralEntityName() + { + return Str::studly(Str::plural($this->entity)); + } + + /** + * @return mixed|string + */ + public function getStudlySingularEntityName() + { + return Str::studly(Str::singular($this->entity)); + } + + /** + * @return string + */ + public function getLowerPluralEntityName() + { + return Str::lower(Str::plural($this->entity)); + } + + /** + * @return string + */ + public function getLowerSingularEntityName() + { + return Str::lower(Str::singular($this->entity)); + } + + /** + * @return array + */ + public function getStubReplacements() + { + return [ + 'VIEW_LAYOUT' => $this->option('view-layout'), + 'ENTITY' => $this->entity, + 'PREFIX_BACKSLASH' => $this->getPrefixBackSlash(), + 'PREFIX_DOT' => $this->getPrefixDot(), + 'STUDLY_ENTITY' => $this->getStudlyEntityName(), + 'LOWER_PLURAL_ENTITY' => $this->getLowerPluralEntityName(), + 'LOWER_SINGULAR_ENTITY' => $this->getLowerSingularEntityName(), + 'STUDLY_PLURAL_ENTITY' => $this->getStudlyPluralEntityName(), + 'STUDLY_SINGULAR_ENTITY' => $this->getStudlySingularEntityName(), + 'TABLE_HEADING' => $this->getTableHeading(), + 'TABLE_BODY' => $this->getTableBody(), + 'SHOW_BODY' => $this->getShowTableBody(), + 'FORM_FIELDS' => $this->getFormBody() + ]; + } + + /** + * @return string + */ + public function getShowTableBody() + { + $result = ''; + + $var = $this->getLowerPluralEntityName(); + + $heading = explode(',', $this->option('table-heading')); + + $template = ' + + :title + :value + + '; + + foreach ($heading as $value) + { + $entityGetter = '{!! $' . $var . '->' . strtolower($value) . ' !!}'; + + $result .= str_replace([':title', ':value'], [$value, $entityGetter], $template); + } + + return $result; + } + + /** + * @return string + */ + public function getTable() + { + if ($table = $this->option('table')) return Str::plural($table); + + return $this->getLowerPluralEntityName(); + } + + /** + * @return string + */ + protected function getFormBody() + { + return (new FormGenerator($this->option('form')))->generate(); + } + + /** + * Calculate correct Formbuilder method + * + * @param string $name + * @return string + */ + public function getInputType($name) + { + $tableInfo = $this->getTableInfo(); + + $dataType = $tableInfo[$name]->getType()->getName(); + + $lookup = array( + 'string' => 'text', + 'float' => 'text', + 'date' => 'text', + 'text' => 'textarea', + 'boolean' => 'checkbox' + ); + + return array_key_exists($dataType, $lookup) + ? $lookup[$dataType] + : 'text'; + } + + /** + * @return mixed + */ + public function getTableInfo() + { + return \DB::getDoctrineSchemaManager()->listTableDetails($this->getTable())->getColumns(); + } + + /** + * @return string + */ + public function getTableBody() + { + $result = ''; + + $var = $this->getLowerSingularEntityName(); + + foreach ($this->getTableInfo() as $name => $info) + { + if ($this->isDisplayable($name)) + { + $result .= '{!! $' . $var . '->' . $name . ' !!}' . PHP_EOL; + } + } + + return $result; + } + + /** + * @param $name + * @return bool + */ + public function isDisplayable($name) + { + return ! in_array($name, ['id', 'updated_at', 'deleted_at', 'password']); + } + + /** + * @return string + */ + public function getTableHeading() + { + $result = ''; + + if ($heading = $this->option('table-heading')) + { + $heading = explode(',', $heading); + + foreach ($heading as $key => $head) + { + $result .= '' . $head . '' . PHP_EOL; + } + } + + return $result; + } + + /** + * Get template contents. + * + * @return string + */ + public function getTemplateContents() + { + return new Stub($this->getStub(), $this->getStubReplacements()); + } + + /** + * Generate a new file. + * + * @throws FileAlreadyExistException + * @return bool + */ + public function generateFile() + { + $path = $this->getDestinationFilePath(); + + if ($this->filesystem->exists($path)) + { + throw new FileAlreadyExistException("File already exist : {$path}"); + } + + $this->autoCreateDirectory($path); + + $this->filesystem->put($path, $this->getTemplateContents()); + + return "File created : {$path}"; + } + + /** + * Auto create directory. + * + * @param string $path + * @return void + */ + protected function autoCreateDirectory($path) + { + if ( ! is_dir($dir = dirname($path))) + { + $this->filesystem->makeDirectory($dir); + } + } + + /** + * Get destination filepath. + * + * @return string + */ + public function getDestinationFilePath() + { + $prefix = Str::lower(($this->prefix ? $this->prefix . '/' : '')); + + return $this->path . '/' . $prefix . $this->getLowerPluralEntityName() . '/' . $this->getFilename(); + } + + /** + * Get filename. + * + * @return string + */ + public function getFilename() + { + return Str::lower($this->name) . '.blade.php'; + } + + /** + * Generate the file. + * + * @return bool + */ + public function generate() + { + return $this->generateFile(); + } + + /** + * @param $key + * @return mixed + */ + public function __get($key) + { + return $this->option($key); + } + +} \ No newline at end of file From 848f1b101b6bc3a089b9c07775bde5ef0283a553 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 15:51:11 +0700 Subject: [PATCH 103/357] Fix mission array wrapper --- src/Pingpong/Generators/Stubs/scaffold/views/edit.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub b/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub index 1116a357..8c331b78 100644 --- a/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub +++ b/src/Pingpong/Generators/Stubs/scaffold/views/edit.stub @@ -10,7 +10,7 @@
    - @include('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.form', ['model' => $$LOWER_SINGULAR_ENTITY$) + @include('$PREFIX_DOT$$LOWER_PLURAL_ENTITY$.form', ['model' => $$LOWER_SINGULAR_ENTITY$])
    From 688538bad85f403b1d26bfa04b5138cfcc83f548 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 15:51:35 +0700 Subject: [PATCH 104/357] Fix variable name --- src/Pingpong/Generators/ViewGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/ViewGenerator.php b/src/Pingpong/Generators/ViewGenerator.php index 914aab1c..b81d623d 100644 --- a/src/Pingpong/Generators/ViewGenerator.php +++ b/src/Pingpong/Generators/ViewGenerator.php @@ -120,7 +120,7 @@ public function getShowTableBody() { $result = ''; - $var = $this->getLowerPluralEntityName(); + $var = $this->getLowerSingularEntityName(); $heading = explode(',', $this->option('table-heading')); From 60453d0cf26b7a06b6000a07e4c62151cf489b70 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 15:51:46 +0700 Subject: [PATCH 105/357] Add CrudCommand --- .../Generators/Console/CrudCommand.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/Pingpong/Generators/Console/CrudCommand.php diff --git a/src/Pingpong/Generators/Console/CrudCommand.php b/src/Pingpong/Generators/Console/CrudCommand.php new file mode 100644 index 00000000..edc16055 --- /dev/null +++ b/src/Pingpong/Generators/Console/CrudCommand.php @@ -0,0 +1,76 @@ + $this->argument('entity'), + 'form' => $this->option('form'), + 'fields' => $this->option('fields'), + 'prefix' => $this->option('prefix'), + 'table-heading' => $this->option('table-heading'), + 'view-layout' => $this->option('view-layout'), + 'table' => $this->option('table'), + ]; + + (new CrudGenerator($options, $this))->generate(); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['entity', InputArgument::REQUIRED, 'An entity name.'], + ]; + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['fields', null, InputOption::VALUE_OPTIONAL, 'An fields data.', null], + ['form', null, InputOption::VALUE_OPTIONAL, 'An form data.', null], + ['table', null, InputOption::VALUE_OPTIONAL, 'An table name.', null], + ['prefix', null, InputOption::VALUE_OPTIONAL, 'An prefix path.', null], + ['table-heading', null, InputOption::VALUE_OPTIONAL, 'An table heading.', null], + ['view-layout', null, InputOption::VALUE_OPTIONAL, 'An view layout.', 'admin.layouts.master'], + ]; + } + +} From 89b41613aca448c7ce93a472e1a825cc7bcb99c7 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 16:22:28 +0700 Subject: [PATCH 106/357] Rename the migration files --- ...e_roles_table.php => 2014_11_02_051938_create_roles_table.php} | 0 ...s_table.php => 2014_11_02_052125_create_permissions_table.php} | 0 ...ser_table.php => 2014_11_02_052410_create_role_user_table.php} | 0 ...ble.php => 2014_11_02_092851_create_permission_role_table.php} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/Pingpong/Trusty/src/migrations/{2014_05_02_051938_create_roles_table.php => 2014_11_02_051938_create_roles_table.php} (100%) rename src/Pingpong/Trusty/src/migrations/{2014_05_02_052125_create_permissions_table.php => 2014_11_02_052125_create_permissions_table.php} (100%) rename src/Pingpong/Trusty/src/migrations/{2014_05_02_052410_create_role_user_table.php => 2014_11_02_052410_create_role_user_table.php} (100%) rename src/Pingpong/Trusty/src/migrations/{2014_05_02_092851_create_permission_role_table.php => 2014_11_02_092851_create_permission_role_table.php} (100%) diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_051938_create_roles_table.php b/src/Pingpong/Trusty/src/migrations/2014_11_02_051938_create_roles_table.php similarity index 100% rename from src/Pingpong/Trusty/src/migrations/2014_05_02_051938_create_roles_table.php rename to src/Pingpong/Trusty/src/migrations/2014_11_02_051938_create_roles_table.php diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052125_create_permissions_table.php b/src/Pingpong/Trusty/src/migrations/2014_11_02_052125_create_permissions_table.php similarity index 100% rename from src/Pingpong/Trusty/src/migrations/2014_05_02_052125_create_permissions_table.php rename to src/Pingpong/Trusty/src/migrations/2014_11_02_052125_create_permissions_table.php diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php b/src/Pingpong/Trusty/src/migrations/2014_11_02_052410_create_role_user_table.php similarity index 100% rename from src/Pingpong/Trusty/src/migrations/2014_05_02_052410_create_role_user_table.php rename to src/Pingpong/Trusty/src/migrations/2014_11_02_052410_create_role_user_table.php diff --git a/src/Pingpong/Trusty/src/migrations/2014_05_02_092851_create_permission_role_table.php b/src/Pingpong/Trusty/src/migrations/2014_11_02_092851_create_permission_role_table.php similarity index 100% rename from src/Pingpong/Trusty/src/migrations/2014_05_02_092851_create_permission_role_table.php rename to src/Pingpong/Trusty/src/migrations/2014_11_02_092851_create_permission_role_table.php From 2a1c43c6e87b5edbce6cd2bb77b74af34286df5f Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 16:58:45 +0700 Subject: [PATCH 107/357] Remove travis & phpunit file --- src/Pingpong/Generators/.travis.yml | 13 ------------- src/Pingpong/Generators/phpunit.xml | 18 ------------------ 2 files changed, 31 deletions(-) delete mode 100644 src/Pingpong/Generators/.travis.yml delete mode 100644 src/Pingpong/Generators/phpunit.xml diff --git a/src/Pingpong/Generators/.travis.yml b/src/Pingpong/Generators/.travis.yml deleted file mode 100644 index f60bbe00..00000000 --- a/src/Pingpong/Generators/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/src/Pingpong/Generators/phpunit.xml b/src/Pingpong/Generators/phpunit.xml deleted file mode 100644 index 3347b75b..00000000 --- a/src/Pingpong/Generators/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - From d3d80f9c98fa70b6133c5c074436a9a871a81094 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 16:59:33 +0700 Subject: [PATCH 108/357] remove phpunit file --- src/Pingpong/Trusty/phpunit.xml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/Pingpong/Trusty/phpunit.xml diff --git a/src/Pingpong/Trusty/phpunit.xml b/src/Pingpong/Trusty/phpunit.xml deleted file mode 100644 index 37d4d710..00000000 --- a/src/Pingpong/Trusty/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - From 69bbedb99999896e9413e5ef65e1367160de1a47 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 17:00:26 +0700 Subject: [PATCH 109/357] Fix wrong table preferrence for role_user --- .../src/migrations/2014_11_02_052410_create_role_user_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Trusty/src/migrations/2014_11_02_052410_create_role_user_table.php b/src/Pingpong/Trusty/src/migrations/2014_11_02_052410_create_role_user_table.php index 8fe897ff..1a63a3ec 100644 --- a/src/Pingpong/Trusty/src/migrations/2014_11_02_052410_create_role_user_table.php +++ b/src/Pingpong/Trusty/src/migrations/2014_11_02_052410_create_role_user_table.php @@ -19,7 +19,7 @@ public function up() $table->integer('role_id')->unsigned()->index(); $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); $table->integer('user_id')->unsigned()->index(); - $table->foreign('user_id')->references('id')->on(config('trusty.model.user'))->onDelete('cascade'); + $table->foreign('user_id')->references('id')->on(config('auth.table'))->onDelete('cascade'); $table->timestamps(); }); } From bd352d2a485164ea2f60ff308c98b4098d015bf4 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 17:53:37 +0700 Subject: [PATCH 110/357] remove useless config file --- src/Pingpong/Menus/src/config/menus.styles.php | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 src/Pingpong/Menus/src/config/menus.styles.php diff --git a/src/Pingpong/Menus/src/config/menus.styles.php b/src/Pingpong/Menus/src/config/menus.styles.php deleted file mode 100644 index c085d7cc..00000000 --- a/src/Pingpong/Menus/src/config/menus.styles.php +++ /dev/null @@ -1,8 +0,0 @@ - 'Pingpong\Menus\Presenters\Bootstrap\NavbarPresenter', - 'navbar-right' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarRightPresenter', - 'nav-pills' => 'Pingpong\Menus\Presenters\Bootstrap\NavPillsPresenter', - 'nav-tab' => 'Pingpong\Menus\Presenters\Bootstrap\NavTabPresenter', -); \ No newline at end of file From c955b7452cfc2989482fc04efd4dedf90895802b Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 17:54:14 +0700 Subject: [PATCH 111/357] Add new SidebarMenuPresenter class --- .../Bootstrap/SidebarMenuPresenter.php | 109 ++++++++++++++++++ src/Pingpong/Menus/src/config/config.php | 3 + 2 files changed, 112 insertions(+) create mode 100644 src/Pingpong/Menus/Presenters/Bootstrap/SidebarMenuPresenter.php diff --git a/src/Pingpong/Menus/Presenters/Bootstrap/SidebarMenuPresenter.php b/src/Pingpong/Menus/Presenters/Bootstrap/SidebarMenuPresenter.php new file mode 100644 index 00000000..7256fdb1 --- /dev/null +++ b/src/Pingpong/Menus/Presenters/Bootstrap/SidebarMenuPresenter.php @@ -0,0 +1,109 @@ +'; + } + + /** + * Get close tag wrapper. + * + * @return string + */ + public function getCloseTagWrapper() + { + return ''; + } + + /** + * Get menu tag without dropdown wrapper. + * + * @param \Pingpong\Menus\MenuItem $item + * @return string + */ + public function getMenuWithoutDropdownWrapper($item) + { + return 'getActiveState($item).'> + getAttributes() .'>' + .$item->getIcon().' '.$item->title.'' . PHP_EOL; + } + + /** + * {@inheritdoc } + */ + public function getActiveState($item, $state = ' class="active"') + { + return $item->isActive() ? $state : null; + } + /** + * Get active state on child items. + * + * @param $item + * @param string $state + * @return null|string + */ + public function getActiveStateOnChild($item, $state = 'active') + { + return $item->hasActiveOnChild() ? $state : null; + } + + /** + * {@inheritdoc } + */ + public function getDividerWrapper() + { + return '
  • '; + } + + /** + * {@inheritdoc } + */ + public function getHeaderWrapper($item) + { + return ''; + } + + /** + * {@inheritdoc } + */ + public function getMenuWithDropDownWrapper($item) + { + $id = str_random(); + + return ' + + ' . PHP_EOL; + } + + /** + * Get multilevel menu wrapper. + * + * @param \Pingpong\Menus\MenuItem $item + * @return string` + */ + public function getMultiLevelDropdownWrapper($item) + { + return $this->getMenuWithDropDownWrapper($item); + } + +} \ No newline at end of file diff --git a/src/Pingpong/Menus/src/config/config.php b/src/Pingpong/Menus/src/config/config.php index 7e9951e0..c795f78f 100644 --- a/src/Pingpong/Menus/src/config/config.php +++ b/src/Pingpong/Menus/src/config/config.php @@ -1,10 +1,13 @@ array( 'navbar' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarPresenter', 'navbar-right' => 'Pingpong\Menus\Presenters\Bootstrap\NavbarRightPresenter', 'nav-pills' => 'Pingpong\Menus\Presenters\Bootstrap\NavPillsPresenter', 'nav-tab' => 'Pingpong\Menus\Presenters\Bootstrap\NavTabPresenter', + 'sidebar' => 'Pingpong\Menus\Presenters\Bootstrap\SidebarMenuPresenter', ) + ); \ No newline at end of file From a10da01ddfaf56c9ea413ee106c1147fad0d84b2 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 18:26:28 +0700 Subject: [PATCH 112/357] Add doctrine/dbal --- composer.json | 3 ++- src/Pingpong/Generators/composer.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index df4af1d6..b0213867 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "php": ">=5.4.0", "laravel/framework": "5.0.*", "illuminate/html": "5.0.*", - "embed/embed": "~1" + "embed/embed": "~1", + "doctrine/dbal": "~2.5" }, "require-dev": { "mockery/mockery": "~0.9", diff --git a/src/Pingpong/Generators/composer.json b/src/Pingpong/Generators/composer.json index fe614e43..7fa386da 100644 --- a/src/Pingpong/Generators/composer.json +++ b/src/Pingpong/Generators/composer.json @@ -16,7 +16,8 @@ "require": { "php": ">=5.4.0", "illuminate/filesystem": "5.0.*", - "illuminate/support": "5.0.*" + "illuminate/support": "5.0.*", + "doctrine/dbal": "~2.5" }, "require-dev": { "mockery/mockery": "~0.9", From 7a9902af900973d1c1fa05070a2d36addb1efcb2 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Wed, 25 Feb 2015 18:41:30 +0700 Subject: [PATCH 113/357] Add missing semicolon --- src/Pingpong/Generators/Stubs/model.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/Stubs/model.stub b/src/Pingpong/Generators/Stubs/model.stub index e56f9ba7..e23a21a9 100644 --- a/src/Pingpong/Generators/Stubs/model.stub +++ b/src/Pingpong/Generators/Stubs/model.stub @@ -1,4 +1,4 @@ - Date: Wed, 25 Feb 2015 18:41:57 +0700 Subject: [PATCH 114/357] generate model using ModelGenerator class --- src/Pingpong/Generators/CrudGenerator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/CrudGenerator.php b/src/Pingpong/Generators/CrudGenerator.php index 1ebd5f05..cad8e3d5 100644 --- a/src/Pingpong/Generators/CrudGenerator.php +++ b/src/Pingpong/Generators/CrudGenerator.php @@ -5,9 +5,12 @@ use Pingpong\Generators\MigrationGenerator; use Pingpong\Generators\Scaffold\ControllerGenerator; use Pingpong\Generators\Exceptions\FileAlreadyExistException; +use Illuminate\Console\AppNamespaceDetectorTrait; class CrudGenerator { + use AppNamespaceDetectorTrait; + /** * @var array */ @@ -161,7 +164,9 @@ public function generateModel() if ($this->confirm("Do you want me to create a new model: {$name} ? [yes|no]")) { - $this->call('make:model', compact('name')); + $namespace = str_replace('\\', '', $this->getAppNamespace()); + + (new ModelGenerator(app_path(), $name, compact('namespace')))->generate(); } } From 7ee2c12a0a2220d9aaba5bbffb0e2de220e2cc1f Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 27 Feb 2015 21:40:18 +0700 Subject: [PATCH 115/357] Fix pingpong-labs/modules#107 --- src/Pingpong/Modules/Commands/MigrationCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/Commands/MigrationCommand.php b/src/Pingpong/Modules/Commands/MigrationCommand.php index 341638c2..a4cb80b8 100644 --- a/src/Pingpong/Modules/Commands/MigrationCommand.php +++ b/src/Pingpong/Modules/Commands/MigrationCommand.php @@ -150,7 +150,7 @@ public function fire() { parent::fire(); - $this->call('dump-autoload'); + $this->call('optimize'); } } From 7ab2686c536e47dcb63179554f57ecaec3128698 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 27 Feb 2015 21:41:03 +0700 Subject: [PATCH 116/357] allow to force the confirm command --- src/Pingpong/Generators/CrudGenerator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Generators/CrudGenerator.php b/src/Pingpong/Generators/CrudGenerator.php index cad8e3d5..89eed276 100644 --- a/src/Pingpong/Generators/CrudGenerator.php +++ b/src/Pingpong/Generators/CrudGenerator.php @@ -48,6 +48,8 @@ public function setConsole(Command $console) */ public function confirm($message) { + if($this->option('force')) return true; + return $this->console->confirm($message); } @@ -301,4 +303,4 @@ protected function dumpAutoload() $this->call('optimize', []); } -} \ No newline at end of file +} From b53dad511b4d1d766a56fd5c55644e9b5cfa6026 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 27 Feb 2015 22:30:11 +0700 Subject: [PATCH 117/357] make argument optional & fix generator path for route provider --- .../Modules/Commands/GenerateRouteProviderCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php b/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php index 9e7ee96c..b13b8d76 100644 --- a/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php +++ b/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php @@ -15,7 +15,7 @@ class GenerateRouteProviderCommand extends GeneratorCommand { protected function getArguments() { return array( - array('module', InputArgument::REQUIRED, 'The name of module will be used.'), + array('module', InputArgument::OPTIONAL, 'The name of module will be used.'), ); } @@ -41,7 +41,7 @@ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $generatorPath = $this->laravel['modules']->get('paths.generator.provider'); + $generatorPath = $this->laravel['modules']->config('paths.generator.provider'); return $path . $generatorPath . '/' . $this->getFileName() . '.php'; } From b8122c4f40e3e6a7771cdc30da4306ed3e4d525f Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 28 Feb 2015 02:20:46 +0700 Subject: [PATCH 118/357] Fix pingpong-labs/modules#85 --- src/Pingpong/Modules/Repository.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Modules/Repository.php b/src/Pingpong/Modules/Repository.php index 574bd8df..d8ee617a 100644 --- a/src/Pingpong/Modules/Repository.php +++ b/src/Pingpong/Modules/Repository.php @@ -138,7 +138,31 @@ public function scan() */ public function all() { - return $this->config('cache.enabled') ? $this->getCached() : $this->scan(); + if( ! $this->config('cache.enabled')) return $this->scan(); + + $cached = $this->getCached(); + + return $this->formatCached($cached); + } + + /** + * Format the cached data as array of modules. + * + * @param array $cached + * @return array + */ + protected function formatCached($cached) + { + $modules = []; + + foreach ($cached as $name => $module) + { + $path = $this->config('paths.modules') . '/' . $name; + + $modules[] = new Module($this->app, $name, $path); + } + + return $modules; } /** @@ -161,7 +185,7 @@ public function getCached() */ public function toCollection() { - return new Collection($this->all()); + return new Collection($this->scan()); } /** From 245788dd232b37622b3b8711fc91738268748f9c Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 28 Feb 2015 02:22:56 +0700 Subject: [PATCH 119/357] simplify --- src/Pingpong/Modules/Repository.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Pingpong/Modules/Repository.php b/src/Pingpong/Modules/Repository.php index d8ee617a..20122141 100644 --- a/src/Pingpong/Modules/Repository.php +++ b/src/Pingpong/Modules/Repository.php @@ -140,9 +140,7 @@ public function all() { if( ! $this->config('cache.enabled')) return $this->scan(); - $cached = $this->getCached(); - - return $this->formatCached($cached); + return $this->formatCached($this->getCached()); } /** From 314cfd9f0186de4384f37193cbdc504a8c46b66e Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 28 Feb 2015 02:44:58 +0700 Subject: [PATCH 120/357] test all service providers --- tests/PingpongTestCase.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/PingpongTestCase.php b/tests/PingpongTestCase.php index 23f8f08d..ef665bda 100644 --- a/tests/PingpongTestCase.php +++ b/tests/PingpongTestCase.php @@ -30,6 +30,13 @@ protected function getPackageProviders() { return [ 'Pingpong\Modules\ModulesServiceProvider', + 'Pingpong\Modules\ModulesServiceProvider', + 'Pingpong\Trusty\TrustyServiceProvider', + 'Pingpong\Menus\MenusServiceProvider', + 'Pingpong\Widget\WidgetServiceProvider', + 'Pingpong\Themes\ThemesServiceProvider', + 'Pingpong\Shortcode\ShortcodeServiceProvider', + 'Pingpong\Oembed\OembedServiceProvider', ]; } From c729dd9721d6a3926ed1747d0a1e76410ee976f1 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 28 Feb 2015 02:48:32 +0700 Subject: [PATCH 121/357] remove useless files --- src/Pingpong/Menus/phpunit.xml | 18 ------------------ src/Pingpong/Presenters/.travis.yml | 13 ------------- src/Pingpong/Presenters/phpunit.xml | 18 ------------------ src/Pingpong/Testing/.travis.yml | 13 ------------- src/Pingpong/Testing/phpunit.xml | 18 ------------------ src/Pingpong/Widget/phpunit.xml | 18 ------------------ 6 files changed, 98 deletions(-) delete mode 100644 src/Pingpong/Menus/phpunit.xml delete mode 100644 src/Pingpong/Presenters/.travis.yml delete mode 100644 src/Pingpong/Presenters/phpunit.xml delete mode 100644 src/Pingpong/Testing/.travis.yml delete mode 100644 src/Pingpong/Testing/phpunit.xml delete mode 100644 src/Pingpong/Widget/phpunit.xml diff --git a/src/Pingpong/Menus/phpunit.xml b/src/Pingpong/Menus/phpunit.xml deleted file mode 100644 index 3347b75b..00000000 --- a/src/Pingpong/Menus/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - diff --git a/src/Pingpong/Presenters/.travis.yml b/src/Pingpong/Presenters/.travis.yml deleted file mode 100644 index 2774819b..00000000 --- a/src/Pingpong/Presenters/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/src/Pingpong/Presenters/phpunit.xml b/src/Pingpong/Presenters/phpunit.xml deleted file mode 100644 index 37d4d710..00000000 --- a/src/Pingpong/Presenters/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - diff --git a/src/Pingpong/Testing/.travis.yml b/src/Pingpong/Testing/.travis.yml deleted file mode 100644 index 2774819b..00000000 --- a/src/Pingpong/Testing/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/src/Pingpong/Testing/phpunit.xml b/src/Pingpong/Testing/phpunit.xml deleted file mode 100644 index 37d4d710..00000000 --- a/src/Pingpong/Testing/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - diff --git a/src/Pingpong/Widget/phpunit.xml b/src/Pingpong/Widget/phpunit.xml deleted file mode 100644 index 37d4d710..00000000 --- a/src/Pingpong/Widget/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - From 79090ae138ec1226f7170a7a651d7924048705fd Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:03:57 +0700 Subject: [PATCH 122/357] update doc --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a38ec6bc..ae50e547 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ ### Documentation -Coming soon +Documentation is located [here](http://sky.pingpong-labs.com). ### License -This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) \ No newline at end of file +This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) From 3863f4e03cbeb32f63bd4b81d5c2420e98577b22 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:09:00 +0700 Subject: [PATCH 123/357] Fix typo --- src/Pingpong/Modules/Contracts/RepositoryInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/Contracts/RepositoryInterface.php b/src/Pingpong/Modules/Contracts/RepositoryInterface.php index 432aa174..09cbb836 100644 --- a/src/Pingpong/Modules/Contracts/RepositoryInterface.php +++ b/src/Pingpong/Modules/Contracts/RepositoryInterface.php @@ -26,7 +26,7 @@ public function scan(); /** * Get modules as modules collection instance. * - * @return \Pingpong\Modules\Collectio + * @return \Pingpong\Modules\Collection */ public function toCollection(); From e4b883752d38dcf0e518b5ed5fe172ef4604abd0 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:15:25 +0700 Subject: [PATCH 124/357] register binding for module repository class --- .../Modules/ModulesServiceProvider.php | 1 + .../Providers/ContractsServiceProvider.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/Pingpong/Modules/Providers/ContractsServiceProvider.php diff --git a/src/Pingpong/Modules/ModulesServiceProvider.php b/src/Pingpong/Modules/ModulesServiceProvider.php index 4df5729d..4bc20d6c 100644 --- a/src/Pingpong/Modules/ModulesServiceProvider.php +++ b/src/Pingpong/Modules/ModulesServiceProvider.php @@ -106,5 +106,6 @@ public function provides() protected function registerProviders() { $this->app->register(__NAMESPACE__ . '\\Providers\\ConsoleServiceProvider'); + $this->app->register('Pingpong\Modules\Providers\ContractsServiceProvider'); } } diff --git a/src/Pingpong/Modules/Providers/ContractsServiceProvider.php b/src/Pingpong/Modules/Providers/ContractsServiceProvider.php new file mode 100644 index 00000000..327175bf --- /dev/null +++ b/src/Pingpong/Modules/Providers/ContractsServiceProvider.php @@ -0,0 +1,20 @@ +app->bind( + 'Pingpong\Modules\Contracts\RepositoryInterface', + 'Pingpong\Modules\Repository' + ); + } + +} \ No newline at end of file From b0906d3d019e4f7646466e587228f76f74edc48b Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:16:16 +0700 Subject: [PATCH 125/357] clean up useless files --- src/Pingpong/Shortcode/.travis.yml | 13 ------------- src/Pingpong/Shortcode/phpunit.xml | 18 ------------------ 2 files changed, 31 deletions(-) delete mode 100644 src/Pingpong/Shortcode/.travis.yml delete mode 100644 src/Pingpong/Shortcode/phpunit.xml diff --git a/src/Pingpong/Shortcode/.travis.yml b/src/Pingpong/Shortcode/.travis.yml deleted file mode 100644 index 2774819b..00000000 --- a/src/Pingpong/Shortcode/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - -before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -script: phpunit diff --git a/src/Pingpong/Shortcode/phpunit.xml b/src/Pingpong/Shortcode/phpunit.xml deleted file mode 100644 index 37d4d710..00000000 --- a/src/Pingpong/Shortcode/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests/ - - - From 8d89a876942155aec78afc056ccf402cb03eae0f Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:17:14 +0700 Subject: [PATCH 126/357] add extra line --- src/Pingpong/Menus/MenuBuilder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Pingpong/Menus/MenuBuilder.php b/src/Pingpong/Menus/MenuBuilder.php index 8ea2ca28..7b1f29eb 100644 --- a/src/Pingpong/Menus/MenuBuilder.php +++ b/src/Pingpong/Menus/MenuBuilder.php @@ -87,6 +87,7 @@ public function style($name) { $this->setPresenter($this->getStyle($name)); } + return $this; } From 04699bc8c98bdf58b4d8987ddd45bd184eec6277 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:23:26 +0700 Subject: [PATCH 127/357] add docblock --- .../Scaffold/ControllerGenerator.php | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/src/Pingpong/Generators/Scaffold/ControllerGenerator.php b/src/Pingpong/Generators/Scaffold/ControllerGenerator.php index 51179a5f..77d408fe 100644 --- a/src/Pingpong/Generators/Scaffold/ControllerGenerator.php +++ b/src/Pingpong/Generators/Scaffold/ControllerGenerator.php @@ -11,57 +11,115 @@ class ControllerGenerator extends Generator { use OptionableTrait, AppNamespaceDetectorTrait; + /** + * The shortname of stub file path. + * + * @var string + */ protected $stub = 'scaffold/controller'; + /** + * The path of controllers. + * + * @var string + */ protected $path = 'app/Http/Controllers'; - public function __construct(array $options = []) + /** + * Create new instance of this class. + * + * @param array $options + */ + public function __construct(array $options = array()) { parent::__construct(); $this->options = $options; } + /** + * Get class name. + * + * @return string + */ public function getClassName() { return Str::studly(Str::plural(str_replace('Controller', '', $this->option('name')))) . 'Controller'; } + /** + * Get prefix path. + * + * @return string + */ public function getPrefixBackSlash() { return $this->prefix ? '\\' . $this->prefix : null; } + /** + * Get prefix dot. + * + * @return string + */ public function getPrefixDot() { return Str::lower($this->prefix ? $this->prefix . '.' : null); } + /** + * Get entity name in singular with studly case convention. + * + * @return string + */ public function getStudlyEntityName() { return Str::studly(Str::singular($this->entity)); } + /** + * Get entity name in plural with studly case convention. + * + * @return string + */ public function getStudlyPluralEntityName() { return Str::studly(Str::plural($this->entity)); } - + /** + * Get entity name in plural with lower case convention. + * + * @return string + */ public function getLowerPluralEntityName() { return Str::lower(Str::plural($this->entity)); } - + /** + * Get entity name in singular with lower case convention. + * + * @return string + */ public function getLowerSingularEntityName() { return Str::lower(Str::singular($this->entity)); } + /** + * Get model name. + * + * @return string + */ public function getModel() { return $this->getAppNamespace() . $this->model; } + /** + * Get stub replacements. + * + * @return array + */ public function getStubReplacements() { return [ From 60c6936929e634e204acdeba5f55b44f851021e1 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 16:26:00 +0700 Subject: [PATCH 128/357] add ConsoleServiceProvider --- .../Providers/ConsoleServiceProvider.php | 17 +++++++++++++++++ tests/PingpongTestCase.php | 1 + 2 files changed, 18 insertions(+) create mode 100644 src/Pingpong/Generators/Providers/ConsoleServiceProvider.php diff --git a/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php b/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php new file mode 100644 index 00000000..eac259ca --- /dev/null +++ b/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php @@ -0,0 +1,17 @@ +commands('Pingpong\Generators\Console\CrudCommand'); + } + +} \ No newline at end of file diff --git a/tests/PingpongTestCase.php b/tests/PingpongTestCase.php index ef665bda..553087b3 100644 --- a/tests/PingpongTestCase.php +++ b/tests/PingpongTestCase.php @@ -37,6 +37,7 @@ protected function getPackageProviders() 'Pingpong\Themes\ThemesServiceProvider', 'Pingpong\Shortcode\ShortcodeServiceProvider', 'Pingpong\Oembed\OembedServiceProvider', + 'Pingpong\Generators\Providers\ConsoleServiceProvider', ]; } From 431bb25e6dbb0afa27552bdf17c3e0b11f1c5c9e Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 7 Mar 2015 19:29:13 +0700 Subject: [PATCH 129/357] Fix grammar --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b0213867..59eec70b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "pingpong/sky", - "description": "Sky - The Extra Laravel Packages", + "description": "Sky - The Extra Laravel Package", "license": "BSD-3-Clause", "authors": [ { From 8c7e1298ce036cef2c2288cd0e7f3a09502a5b91 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Mon, 9 Mar 2015 14:58:12 +0700 Subject: [PATCH 130/357] Add helper --- composer.json | 3 +++ src/Pingpong/Support/helpers.php | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/Pingpong/Support/helpers.php diff --git a/composer.json b/composer.json index b0213867..c3c46b42 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,9 @@ "classmap": [ "tests/PingpongTestCase.php", "tests/Generators/GeneratorTestCase.php" + ], + "files": [ + "src/Pingpong/Support/helpers.php" ] } } diff --git a/src/Pingpong/Support/helpers.php b/src/Pingpong/Support/helpers.php new file mode 100644 index 00000000..6a1d8111 --- /dev/null +++ b/src/Pingpong/Support/helpers.php @@ -0,0 +1,27 @@ +getClientOriginalName()) . '.' . strtolower($file->getClientOriginalExtension()); + + $file->move(public_path($path), $filename); + + return $filename; + } + + return null; + } +} \ No newline at end of file From c2dc583f174fd419028d6b5c8ed05f2f1369a9f2 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Mon, 9 Mar 2015 16:48:54 +0700 Subject: [PATCH 131/357] Add set_active helper --- src/Pingpong/Support/helpers.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Support/helpers.php b/src/Pingpong/Support/helpers.php index 6a1d8111..90428a7a 100644 --- a/src/Pingpong/Support/helpers.php +++ b/src/Pingpong/Support/helpers.php @@ -24,4 +24,22 @@ function upload_image($file, $path) return null; } -} \ No newline at end of file +} + +if ( ! function_exists('set_active')) +{ + /** + * Set active to specified selector. + * + * @param array|string $paths + * @param string $class + * @return string + */ + function set_active($paths, $class = 'active') + { + foreach ((array) $paths as $path) + { + if(Request::is($path)) return $class; + } + } +} From 198c3a4822ddc7f241c805afc5667bc0be21e246 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Mon, 9 Mar 2015 16:49:02 +0700 Subject: [PATCH 132/357] Add ImageTrait --- src/Pingpong/Support/ImageTrait.php | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Pingpong/Support/ImageTrait.php diff --git a/src/Pingpong/Support/ImageTrait.php b/src/Pingpong/Support/ImageTrait.php new file mode 100644 index 00000000..7ae5cc5a --- /dev/null +++ b/src/Pingpong/Support/ImageTrait.php @@ -0,0 +1,37 @@ +getImagePath())) + { + @unlink($path); + + return true; + } + + return false; + } + + public function getImagePath() + { + return public_path(static::$path . $this->image); + } + + public function getImageUrl() + { + return asset(static::$path . $this->image); + } + + public function getImageUrlAttribute($value) + { + return $this->getImageUrl(); + } + + public function hasImage() + { + return ! empty($this->image) && file_exists($this->getImagePath()); + } + +} From 58e9b68e3b0d4b3f5c2777a42afd72e4915ecea5 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Mon, 9 Mar 2015 18:30:06 +0700 Subject: [PATCH 133/357] remove call to hasMorePages --- src/Pingpong/Generators/Stubs/scaffold/views/index.stub | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Pingpong/Generators/Stubs/scaffold/views/index.stub b/src/Pingpong/Generators/Stubs/scaffold/views/index.stub index 6c675b4f..4fa84856 100644 --- a/src/Pingpong/Generators/Stubs/scaffold/views/index.stub +++ b/src/Pingpong/Generators/Stubs/scaffold/views/index.stub @@ -36,10 +36,8 @@ @endforeach - @if($$LOWER_PLURAL_ENTITY$->hasMorePages()) - @endif @stop \ No newline at end of file From f45188bb598797a11419efb0b5d4c085275b09fd Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 06:16:42 +0700 Subject: [PATCH 134/357] Add namespace option & update default path of modules --- src/Pingpong/Modules/src/config/config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/src/config/config.php b/src/Pingpong/Modules/src/config/config.php index 2bcaf90a..aa2192d5 100644 --- a/src/Pingpong/Modules/src/config/config.php +++ b/src/Pingpong/Modules/src/config/config.php @@ -1,6 +1,8 @@ 'App\Modules', 'stubs' => [ 'enabled' => false, @@ -36,7 +38,7 @@ | */ - 'modules' => base_path('Modules'), + 'modules' => app_path('Modules'), /* |-------------------------------------------------------------------------- | Modules assets path From 5a06b8351b508770bb8a38213969122facaa65b0 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 06:34:30 +0700 Subject: [PATCH 135/357] Allow to use custom namespace for each module --- src/Pingpong/Modules/Commands/CommandCommand.php | 3 ++- .../Modules/Commands/ControllerCommand.php | 3 ++- .../Modules/Commands/GenerateFilterCommand.php | 3 ++- .../Modules/Commands/GenerateProviderCommand.php | 3 ++- .../Commands/GenerateRouteProviderCommand.php | 3 ++- src/Pingpong/Modules/Commands/ModelCommand.php | 3 ++- src/Pingpong/Modules/Commands/SeedCommand.php | 4 +++- src/Pingpong/Modules/Commands/SeedMakeCommand.php | 3 ++- src/Pingpong/Modules/Commands/stubs/command.stub | 2 +- src/Pingpong/Modules/Commands/stubs/composer.stub | 2 +- .../Modules/Commands/stubs/controller.stub | 2 +- src/Pingpong/Modules/Commands/stubs/filter.stub | 2 +- src/Pingpong/Modules/Commands/stubs/json.stub | 2 +- src/Pingpong/Modules/Commands/stubs/model.stub | 2 +- src/Pingpong/Modules/Commands/stubs/provider.stub | 2 +- .../Modules/Commands/stubs/route-provider.stub | 6 +++--- src/Pingpong/Modules/Commands/stubs/routes.stub | 2 +- .../Modules/Commands/stubs/scaffold/provider.stub | 2 +- src/Pingpong/Modules/Commands/stubs/seeder.stub | 2 +- .../Modules/Generators/ModuleGenerator.php | 14 +++++++++++++- 20 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/Pingpong/Modules/Commands/CommandCommand.php b/src/Pingpong/Modules/Commands/CommandCommand.php index 6813018e..42b97334 100644 --- a/src/Pingpong/Modules/Commands/CommandCommand.php +++ b/src/Pingpong/Modules/Commands/CommandCommand.php @@ -57,7 +57,8 @@ protected function getTemplateContents() return new Stub('command', [ 'MODULE' => $this->getModuleName(), 'NAME' => $this->getFileName(), - 'COMMAND_NAME' => $this->getCommandName() + 'COMMAND_NAME' => $this->getCommandName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/ControllerCommand.php b/src/Pingpong/Modules/Commands/ControllerCommand.php index a07eb328..07fe5190 100644 --- a/src/Pingpong/Modules/Commands/ControllerCommand.php +++ b/src/Pingpong/Modules/Commands/ControllerCommand.php @@ -46,7 +46,8 @@ protected function getTemplateContents() return new Stub('controller', [ 'MODULENAME' => $module->getStudlyName(), 'CONTROLLERNAME' => $this->getControllerName(), - 'NAMESPACE' => $module->getLowername() + 'NAMESPACE' => $module->getLowername(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/GenerateFilterCommand.php b/src/Pingpong/Modules/Commands/GenerateFilterCommand.php index 03ba1c64..0adfdd8f 100644 --- a/src/Pingpong/Modules/Commands/GenerateFilterCommand.php +++ b/src/Pingpong/Modules/Commands/GenerateFilterCommand.php @@ -43,7 +43,8 @@ protected function getTemplateContents() { return new Stub('filter', [ 'MODULE' => $this->getModuleName(), - 'NAME' => $this->getFileName() + 'NAME' => $this->getFileName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/GenerateProviderCommand.php b/src/Pingpong/Modules/Commands/GenerateProviderCommand.php index ebe03f6a..a1a227c0 100644 --- a/src/Pingpong/Modules/Commands/GenerateProviderCommand.php +++ b/src/Pingpong/Modules/Commands/GenerateProviderCommand.php @@ -59,7 +59,8 @@ protected function getTemplateContents() return new Stub($stub, [ 'MODULE' => $this->getModuleName(), 'LOWER_NAME' => strtolower($this->getModuleName()), - 'NAME' => $this->getFileName() + 'NAME' => $this->getFileName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php b/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php index b13b8d76..53480ac8 100644 --- a/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php +++ b/src/Pingpong/Modules/Commands/GenerateRouteProviderCommand.php @@ -28,7 +28,8 @@ protected function getTemplateContents() { return new Stub('route-provider', [ 'MODULE' => $this->getModuleName(), - 'NAME' => $this->getFileName() + 'NAME' => $this->getFileName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/ModelCommand.php b/src/Pingpong/Modules/Commands/ModelCommand.php index 755cae9c..0e473d50 100644 --- a/src/Pingpong/Modules/Commands/ModelCommand.php +++ b/src/Pingpong/Modules/Commands/ModelCommand.php @@ -57,7 +57,8 @@ protected function getTemplateContents() return new Stub('model', [ 'MODULE' => $this->getModuleName(), 'NAME' => $this->getModelName(), - 'FILLABLE' => $this->getFillable() + 'FILLABLE' => $this->getFillable(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/SeedCommand.php b/src/Pingpong/Modules/Commands/SeedCommand.php index 7b6dca03..03f08d43 100644 --- a/src/Pingpong/Modules/Commands/SeedCommand.php +++ b/src/Pingpong/Modules/Commands/SeedCommand.php @@ -85,7 +85,9 @@ public function getSeederName($name) { $name = Str::studly($name); - return 'Modules\\' . $name . '\Database\Seeders\\' . $name . 'DatabaseSeeder'; + $namespace = $this->laravel['modules']->config('namespace'); + + return $namespace . '\\' . $name . '\Database\Seeders\\' . $name . 'DatabaseSeeder'; } /** diff --git a/src/Pingpong/Modules/Commands/SeedMakeCommand.php b/src/Pingpong/Modules/Commands/SeedMakeCommand.php index d4ff5e74..0cc8728a 100644 --- a/src/Pingpong/Modules/Commands/SeedMakeCommand.php +++ b/src/Pingpong/Modules/Commands/SeedMakeCommand.php @@ -61,7 +61,8 @@ protected function getTemplateContents() { return new Stub('seeder', [ 'NAME' => $this->getSeederName(), - 'MODULE' => $this->getModuleName() + 'MODULE' => $this->getModuleName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace') ]); } diff --git a/src/Pingpong/Modules/Commands/stubs/command.stub b/src/Pingpong/Modules/Commands/stubs/command.stub index 5c36f13c..c14a4f4d 100644 --- a/src/Pingpong/Modules/Commands/stubs/command.stub +++ b/src/Pingpong/Modules/Commands/stubs/command.stub @@ -1,4 +1,4 @@ - '$LOWER_NAME$', 'namespace' => 'Modules\$STUDLY_NAME$\Http\Controllers'], function() +Route::group(['prefix' => '$LOWER_NAME$', 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'], function() { Route::get('/', '$STUDLY_NAME$Controller@index'); }); \ No newline at end of file diff --git a/src/Pingpong/Modules/Commands/stubs/scaffold/provider.stub b/src/Pingpong/Modules/Commands/stubs/scaffold/provider.stub index c4b80e5a..2b855f2a 100644 --- a/src/Pingpong/Modules/Commands/stubs/scaffold/provider.stub +++ b/src/Pingpong/Modules/Commands/stubs/scaffold/provider.stub @@ -1,4 +1,4 @@ -module->config('stubs.replacements'); + $namespace = $this->module->config('namespace'); + if ( ! isset($replacements[$stub])) return []; $keys = $replacements[$stub]; - $replaces = []; + $replaces = ['MODULE_NAMESPACE']; foreach ($keys as $key) { @@ -356,6 +358,16 @@ protected function getVendorReplacement() return $this->module->config('composer.vendor'); } + /** + * Get replacement for $VENDOR$ + * + * @return string + */ + protected function getModuleNamespaceReplacement() + { + return $this->module->config('namespace'); + } + /** * Get replacement for $AUTHOR_NAME$ * From 73ab9f019f02d59cad6f43e6db3240cfbe222b29 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 06:42:51 +0700 Subject: [PATCH 136/357] Add --force option to module:make command --- src/Pingpong/Modules/Commands/MakeCommand.php | 9 ++++++ .../Modules/Generators/ModuleGenerator.php | 29 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/Commands/MakeCommand.php b/src/Pingpong/Modules/Commands/MakeCommand.php index 1c3a3c5d..91942c59 100644 --- a/src/Pingpong/Modules/Commands/MakeCommand.php +++ b/src/Pingpong/Modules/Commands/MakeCommand.php @@ -3,6 +3,7 @@ use Illuminate\Console\Command; use Pingpong\Modules\Generators\ModuleGenerator; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; class MakeCommand extends Command { @@ -36,6 +37,7 @@ public function fire() ->setModule($this->laravel['modules']) ->setConfig($this->laravel['config']) ->setConsole($this) + ->setForce($this->option('force')) ->generate(); } } @@ -53,4 +55,11 @@ protected function getArguments() ); } + protected function getOptions() + { + return [ + array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when module already exist.'), + ]; + } + } diff --git a/src/Pingpong/Modules/Generators/ModuleGenerator.php b/src/Pingpong/Modules/Generators/ModuleGenerator.php index d5e6d167..27d095cc 100644 --- a/src/Pingpong/Modules/Generators/ModuleGenerator.php +++ b/src/Pingpong/Modules/Generators/ModuleGenerator.php @@ -44,6 +44,13 @@ class ModuleGenerator extends Generator { */ protected $module; + /** + * Force status. + * + * @var boolean + */ + protected $force = false; + /** * The constructor. * @@ -186,13 +193,33 @@ public function getFiles() return $this->module->config('stubs.files'); } + /** + * Set force status. + * + * @param boolean|int $force + * @return $this + */ + public function setForce($force) + { + $this->force = $force; + + return $this; + } + /** * Generate the module. */ public function generate() { - if ($this->module->has($name = $this->getName())) + $name = $this->getName(); + + if ($this->module->has($name)) { + if ($this->force) + { + $this->module->delete($name); + } + $this->console->error("Module [{$name}] already exist!"); return; From 5863a6eaa740694e5ab0e377cff3ed82ccb357fb Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 07:07:20 +0700 Subject: [PATCH 137/357] fix argument order --- docs/modules.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/modules.md b/docs/modules.md index a5cbb618..918d95d9 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -189,23 +189,23 @@ Create new command for the specified module. ``` php artisan module:command CustomCommand blog - php artisan module:command CustomCommand blog --command=custom:command + php artisan module:command CustomCommand --command=custom:command blog - php artisan module:command CustomCommand blog --namespace=Modules\Blog\Commands + php artisan module:command CustomCommand --namespace=Modules\Blog\Commands blog ``` Create new migration for the specified module. ``` - php artisan module:migration blog create_users_table + php artisan module:migration create_users_table blog - php artisan module:migration blog create_users_table --fields="username:string, password:string" + php artisan module:migration create_users_table --fields="username:string, password:string" blog - php artisan module:migration blog add_email_to_users_table --fields="email:string:unique" + php artisan module:migration add_email_to_users_table --fields="email:string:unique" blog - php artisan module:migration blog remove_email_from_users_table --fields="email:string:unique" + php artisan module:migration remove_email_from_users_table --fields="email:string:unique" blog - php artisan module:migration blog drop_users_table + php artisan module:migration drop_users_table blog ``` Rollback, Reset and Refresh The Modules Migrations. From 852c6822277f855be8cb28df6e63e332ca353565 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 09:45:55 +0700 Subject: [PATCH 138/357] Add MODULE_NAMESPACE replacement, update replacement value for MODULE_NAMESPACE, fix --force feature --- .../Modules/Generators/ModuleGenerator.php | 18 +++++++++--------- src/Pingpong/Modules/src/config/config.php | 7 +++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Pingpong/Modules/Generators/ModuleGenerator.php b/src/Pingpong/Modules/Generators/ModuleGenerator.php index 27d095cc..57896115 100644 --- a/src/Pingpong/Modules/Generators/ModuleGenerator.php +++ b/src/Pingpong/Modules/Generators/ModuleGenerator.php @@ -215,14 +215,14 @@ public function generate() if ($this->module->has($name)) { - if ($this->force) + if ($this->force) $this->module->delete($name); + + else { - $this->module->delete($name); - } - - $this->console->error("Module [{$name}] already exist!"); + $this->console->error("Module [{$name}] already exist!"); - return; + return; + } } $this->generateFolders(); @@ -338,7 +338,7 @@ protected function getReplacement($stub) $keys = $replacements[$stub]; - $replaces = ['MODULE_NAMESPACE']; + $replaces = []; foreach ($keys as $key) { @@ -386,13 +386,13 @@ protected function getVendorReplacement() } /** - * Get replacement for $VENDOR$ + * Get replacement for $MODULE_NAMESPACE$ * * @return string */ protected function getModuleNamespaceReplacement() { - return $this->module->config('namespace'); + return str_replace('\\', '\\\\', $this->module->config('namespace')); } /** diff --git a/src/Pingpong/Modules/src/config/config.php b/src/Pingpong/Modules/src/config/config.php index aa2192d5..22853a2a 100644 --- a/src/Pingpong/Modules/src/config/config.php +++ b/src/Pingpong/Modules/src/config/config.php @@ -19,11 +19,14 @@ 'replacements' => [ 'start' => ['LOWER_NAME'], 'routes' => ['LOWER_NAME', 'STUDLY_NAME'], - 'json' => ['LOWER_NAME', 'STUDLY_NAME'], + 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'], 'views/index' => ['LOWER_NAME'], 'views/master' => ['STUDLY_NAME'], 'scaffold/config' => ['STUDLY_NAME'], - 'composer' => ['LOWER_NAME', 'STUDLY_NAME', 'VENDOR', 'AUTHOR_NAME', 'AUTHOR_EMAIL'], + 'composer' => [ + 'LOWER_NAME', 'STUDLY_NAME', 'VENDOR', 'AUTHOR_NAME', 'AUTHOR_EMAIL', + 'MODULE_NAMESPACE' + ], ], ], From 34b7711f1f622759705223cd791a6455ef42a024 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 09:46:07 +0700 Subject: [PATCH 139/357] Add delete method --- src/Pingpong/Modules/Repository.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Pingpong/Modules/Repository.php b/src/Pingpong/Modules/Repository.php index 20122141..e06607f5 100644 --- a/src/Pingpong/Modules/Repository.php +++ b/src/Pingpong/Modules/Repository.php @@ -523,6 +523,17 @@ public function disable($name) return $this->findOrFail($name)->disable(); } + /** + * Delete a specific module. + * + * @param string $name + * @return bool + */ + public function delete($name) + { + return $this->findOrFail($name)->delete(); + } + /** * Update dependencies for the specified module. * From b63f7e5c1aad2dde53158a1ed081a5647bbb6744 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 09:46:59 +0700 Subject: [PATCH 140/357] use table instead of - (strip) --- src/Pingpong/Modules/Commands/ListCommand.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/Commands/ListCommand.php b/src/Pingpong/Modules/Commands/ListCommand.php index b732ebaa..6db75185 100644 --- a/src/Pingpong/Modules/Commands/ListCommand.php +++ b/src/Pingpong/Modules/Commands/ListCommand.php @@ -25,10 +25,27 @@ class ListCommand extends Command { */ public function fire() { + $this->table(['Name', 'Status'], $this->getRows()); + } + + /** + * Get table rows. + * + * @return array + */ + public function getRows() + { + $rows = []; + foreach ($this->laravel['modules']->all() as $module) { - $this->line('- ' . $module); + $rows[] = [ + $module->getName(), + $module->enabled() ? 'Enabled' : 'Disabled' + ]; } + + return $rows; } } From 73371aa9b64a0cc4258b2bd89d5a85fcaa985c57 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 09:49:05 +0700 Subject: [PATCH 141/357] Show priority & path --- src/Pingpong/Modules/Commands/ListCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Pingpong/Modules/Commands/ListCommand.php b/src/Pingpong/Modules/Commands/ListCommand.php index 6db75185..f66b3860 100644 --- a/src/Pingpong/Modules/Commands/ListCommand.php +++ b/src/Pingpong/Modules/Commands/ListCommand.php @@ -25,7 +25,7 @@ class ListCommand extends Command { */ public function fire() { - $this->table(['Name', 'Status'], $this->getRows()); + $this->table(['Name', 'Status', 'Priority', 'Path'], $this->getRows()); } /** @@ -40,8 +40,10 @@ public function getRows() foreach ($this->laravel['modules']->all() as $module) { $rows[] = [ - $module->getName(), - $module->enabled() ? 'Enabled' : 'Disabled' + $module->getStudlyName(), + $module->enabled() ? 'Enabled' : 'Disabled', + $module->get('priority'), + $module->getPath(), ]; } From 60c4d466a65d2afdc8326ed3997aa795523173be Mon Sep 17 00:00:00 2001 From: Gravitano Date: Fri, 20 Mar 2015 10:17:29 +0700 Subject: [PATCH 142/357] also replace MODULE_NAMESPACE in routes file --- src/Pingpong/Modules/src/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/src/config/config.php b/src/Pingpong/Modules/src/config/config.php index 22853a2a..f71994ca 100644 --- a/src/Pingpong/Modules/src/config/config.php +++ b/src/Pingpong/Modules/src/config/config.php @@ -18,7 +18,7 @@ ], 'replacements' => [ 'start' => ['LOWER_NAME'], - 'routes' => ['LOWER_NAME', 'STUDLY_NAME'], + 'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'], 'views/index' => ['LOWER_NAME'], 'views/master' => ['STUDLY_NAME'], From f939faf90c22223c6aec0ad79df71a32ce71506f Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 21 Mar 2015 09:12:49 +0700 Subject: [PATCH 143/357] Fix pingpong-labs/modules#117 --- src/Pingpong/Modules/ModulesServiceProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/ModulesServiceProvider.php b/src/Pingpong/Modules/ModulesServiceProvider.php index 4bc20d6c..9dac75db 100644 --- a/src/Pingpong/Modules/ModulesServiceProvider.php +++ b/src/Pingpong/Modules/ModulesServiceProvider.php @@ -21,6 +21,8 @@ class ModulesServiceProvider extends ServiceProvider { */ public function boot() { + $this->registerNamespaces(); + $this->app['modules']->boot(); $this->app['modules']->register(); @@ -33,7 +35,6 @@ public function boot() */ public function register() { - $this->registerNamespaces(); $this->registerServices(); $this->registerProviders(); From 47e2c8ec459260cffd470527b2d18552c46d9594 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 21 Mar 2015 09:24:15 +0700 Subject: [PATCH 144/357] Update vendor name --- src/Pingpong/Modules/ModulesServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pingpong/Modules/ModulesServiceProvider.php b/src/Pingpong/Modules/ModulesServiceProvider.php index 9dac75db..469d56af 100644 --- a/src/Pingpong/Modules/ModulesServiceProvider.php +++ b/src/Pingpong/Modules/ModulesServiceProvider.php @@ -63,11 +63,11 @@ protected function registerNamespaces() */ protected function registerHtml() { - $this->app->register('Illuminate\Html\HtmlServiceProvider'); + $this->app->register('Collective\Html\HtmlServiceProvider'); $aliases = [ - 'HTML' => 'Illuminate\Html\HtmlFacade', - 'Form' => 'Illuminate\Html\FormFacade', + 'HTML' => 'Collective\Html\HtmlFacade', + 'Form' => 'Collective\Html\FormFacade', 'Module' => 'Pingpong\Modules\Facades\Module', ]; From dc7b917b48548fdf16ed0c11e4777db9e5008e2c Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 21 Mar 2015 09:52:27 +0700 Subject: [PATCH 145/357] get ordered modules by priority in module:list command --- src/Pingpong/Modules/Commands/ListCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/Commands/ListCommand.php b/src/Pingpong/Modules/Commands/ListCommand.php index f66b3860..101d3519 100644 --- a/src/Pingpong/Modules/Commands/ListCommand.php +++ b/src/Pingpong/Modules/Commands/ListCommand.php @@ -37,7 +37,7 @@ public function getRows() { $rows = []; - foreach ($this->laravel['modules']->all() as $module) + foreach ($this->laravel['modules']->getOrdered() as $module) { $rows[] = [ $module->getStudlyName(), From 495343b52169af827cf2f658293b522eddb5ccce Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 21 Mar 2015 10:22:55 +0700 Subject: [PATCH 146/357] replace 'priority' with 'order', add new optional 'direction' argument to getOrdered method, fixes #116 --- src/Pingpong/Modules/Commands/stubs/json.stub | 2 +- src/Pingpong/Modules/Repository.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Pingpong/Modules/Commands/stubs/json.stub b/src/Pingpong/Modules/Commands/stubs/json.stub index 53820418..314ad897 100644 --- a/src/Pingpong/Modules/Commands/stubs/json.stub +++ b/src/Pingpong/Modules/Commands/stubs/json.stub @@ -4,7 +4,7 @@ "description": "", "keywords": [], "active": 1, - "priority": 0, + "order": 0, "providers": [ "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider" ], diff --git a/src/Pingpong/Modules/Repository.php b/src/Pingpong/Modules/Repository.php index e06607f5..8917735c 100644 --- a/src/Pingpong/Modules/Repository.php +++ b/src/Pingpong/Modules/Repository.php @@ -251,20 +251,26 @@ public function count() /** * Get all ordered modules. * + * @param string $direction * @return array */ - public function getOrdered() + public function getOrdered($direction = 'asc') { $modules = $this->enabled(); - uasort($modules, function ($a, $b) + uasort($modules, function ($a, $b) use ($direction) { - if ($a->priority == $b->priority) + if ($a->order == $b->order) { return 0; } - return $a->priority < $b->priority ? 1 : -1; + if($direction == 'desc') + { + return $a->order < $b->order ? 1 : -1; + } + + return $a->order > $b->order ? 1 : -1; }); return $modules; From 3dcc074c5f8a71b9152102bc4531d0189c5a57ce Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 21 Mar 2015 10:23:29 +0700 Subject: [PATCH 147/357] Add new option --only & --direction flags --- src/Pingpong/Modules/Commands/ListCommand.php | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/Pingpong/Modules/Commands/ListCommand.php b/src/Pingpong/Modules/Commands/ListCommand.php index 101d3519..65466de1 100644 --- a/src/Pingpong/Modules/Commands/ListCommand.php +++ b/src/Pingpong/Modules/Commands/ListCommand.php @@ -1,6 +1,7 @@ table(['Name', 'Status', 'Priority', 'Path'], $this->getRows()); + $this->table(['Name', 'Status', 'Order', 'Path'], $this->getRows()); } /** @@ -37,12 +38,12 @@ public function getRows() { $rows = []; - foreach ($this->laravel['modules']->getOrdered() as $module) + foreach ($this->getModules() as $module) { $rows[] = [ $module->getStudlyName(), $module->enabled() ? 'Enabled' : 'Disabled', - $module->get('priority'), + $module->get('order'), $module->getPath(), ]; } @@ -50,4 +51,38 @@ public function getRows() return $rows; } + public function getModules() + { + switch ($this->option('only')) { + case 'enabled': + return $this->laravel['modules']->getByStatus(1); + break; + + case 'disabled': + return $this->laravel['modules']->getByStatus(0); + break; + + case 'ordered': + return $this->laravel['modules']->getOrdered($this->option('direction')); + break; + + default: + return $this->laravel['modules']->all(); + break; + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('only', null, InputOption::VALUE_OPTIONAL, 'Types of modules will be displayed.', null), + array('direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'), + ); + } + } From 94029cf20245e0deb745e1a264333858d2612c9a Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sat, 21 Mar 2015 10:35:30 +0700 Subject: [PATCH 148/357] Use ordered modules instead of all modules, add new 'direction' option to module:make command and fixes #116 --- src/Pingpong/Modules/Commands/MigrateCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Modules/Commands/MigrateCommand.php b/src/Pingpong/Modules/Commands/MigrateCommand.php index f7aaea4c..0bcb8201 100644 --- a/src/Pingpong/Modules/Commands/MigrateCommand.php +++ b/src/Pingpong/Modules/Commands/MigrateCommand.php @@ -41,7 +41,7 @@ public function fire() return $this->migrate($name); } - foreach ($this->module->all() as $name) + foreach ($this->module->getOrdered($this->option('direction')) as $name) { $this->migrate($name); } @@ -121,6 +121,7 @@ protected function getArguments() protected function getOptions() { return array( + array('direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'), array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'), array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'), From cd4e15d2393d18bde1a4e92f6009a46ec992d662 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 15:03:18 +0700 Subject: [PATCH 149/357] get path from config if not defined in class --- src/Pingpong/Themes/Theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 59179788..73ae3e52 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -184,7 +184,7 @@ public function setPath($path) */ public function getPath() { - return $this->path; + return $this->path ?: $this->config->get('themes.path'); } /** From 9a84b5f124c5298a2ca8631d5a7cafcaa8b36e10 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 15:30:38 +0700 Subject: [PATCH 150/357] Fix pingpong-labs/modules#122 --- src/Pingpong/Modules/ModulesServiceProvider.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Pingpong/Modules/ModulesServiceProvider.php b/src/Pingpong/Modules/ModulesServiceProvider.php index 469d56af..ad988e36 100644 --- a/src/Pingpong/Modules/ModulesServiceProvider.php +++ b/src/Pingpong/Modules/ModulesServiceProvider.php @@ -36,11 +36,25 @@ public function boot() public function register() { $this->registerServices(); + $this->setupStubPath(); $this->registerProviders(); + } + /** + * Setup stub path. + * + * @return void + */ + public function setupStubPath() + { $this->app->booted(function ($app) { Stub::setPath(__DIR__ . '/Commands/stubs'); + + if ($app['modules']->config('stubs.enabled') === true) + { + Stub::setPath($app['modules']->config('stubs.path')); + } }); } From 3579aa37cb67fce87344912a81e28df14d340dc4 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 15:58:58 +0700 Subject: [PATCH 151/357] Add theme repository & theme entity class --- src/Pingpong/Themes/Finder.php | 14 +- src/Pingpong/Themes/Repository.php | 250 +++++++++++++++++++++++++++++ src/Pingpong/Themes/Theme.php | 202 ++++++++--------------- 3 files changed, 334 insertions(+), 132 deletions(-) create mode 100644 src/Pingpong/Themes/Repository.php diff --git a/src/Pingpong/Themes/Finder.php b/src/Pingpong/Themes/Finder.php index 629a05bc..c8e53bd7 100644 --- a/src/Pingpong/Themes/Finder.php +++ b/src/Pingpong/Themes/Finder.php @@ -1,6 +1,7 @@ finder->in($path)->files()->name($filename)->depth('<= 3')->followLinks(); - foreach ($found as $file) $themes[] = $file; + foreach ($found as $file) $themes[] = new Theme($this->getInfo($file)); } return $themes; } + + /** + * Get theme info from json file. + * + * @param SplFileInfo $file + * @return array + */ + protected function getInfo($file) + { + return Json::make($file->getRealPath())->toArray(); + } } \ No newline at end of file diff --git a/src/Pingpong/Themes/Repository.php b/src/Pingpong/Themes/Repository.php new file mode 100644 index 00000000..5838b276 --- /dev/null +++ b/src/Pingpong/Themes/Repository.php @@ -0,0 +1,250 @@ +finder = $finder; + $this->config = $config; + $this->lang = $lang; + $this->views = $views; + } + + /** + * Register the namespaces. + */ + public function registerNamespaces() + { + foreach($this->all() as $theme) + { + foreach(array('views', 'lang') as $hint) + { + $path = $this->getNamespacePath($theme->getName(), $hint); + + $this->{$hint}->addNamespace($theme, $path); + } + } + } + + /** + * Get path for namespace. + * + * @param $theme + * @param $type + * @return string + */ + protected function getNamespacePath($theme, $type) + { + return $this->getThemePath($theme) . "/{$type}"; + } + + /** + * Get theme path by given theme name. + * + * @param $theme + * @return null|string + */ + public function getThemePath($theme) + { + return $this->path ."/{$theme}"; + } + + /** + * Get current theme. + * + * @return string + */ + public function getCurrent() + { + return $this->current ?: $this->config->get('themes.default'); + } + + /** + * Set current theme. + * + * @param string $current + * @return $this + */ + public function setCurrent($current) + { + $this->current = $current; + + return $this; + } + + /** + * The alias "setCurrent" method. + * + * @param $theme + * @return $this + */ + public function set($theme) + { + return $this->setCurrent($theme); + } + + /** + * Get all themes. + * + * @return array + */ + public function all() + { + return $this->finder->find($this->getPath(), $this->filename); + } + + /** + * Check whether the given theme in all themes. + * + * @param $theme + * @return bool + */ + public function has($theme) + { + return in_array($theme, $this->all()); + } + + /** + * Alias for "has" method. + * + * @param $theme + * @return bool + */ + public function exists($theme) + { + return $this->has($theme); + } + + /** + * Set theme path on runtime. + * + * @param $path + * @return Finder + */ + public function setPath($path) + { + return $this->path = $path; + } + + /** + * Get theme path. + * + * @return mixed + */ + public function getPath() + { + return $this->path ?: $this->config->get('themes.path'); + } + + /** + * Get view from current theme. + * + * @param $view + * @param array $data + * @param array $mergeData + * @return mixed + */ + public function view($view, $data = array(), $mergeData = array()) + { + return $this->views->make($this->getThemeNamespace($view), $data, $mergeData); + } + + /** + * Get config from current theme. + * + * @param $key + * @param null $default + * @return mixed + */ + public function config($key, $default = null) + { + return $this->config->get($this->getThemeNamespace($key), $default); + } + + /** + * Get lang from current theme. + * + * @param $key + * @param array $replace + * @param null $locale + * @return string + */ + public function lang($key, $replace = array(), $locale = null) + { + return $this->lang->get($this->getThemeNamespace($key), $replace, $locale); + } + + /** + * Get theme namespace by given key. + * + * @param $key + * @return string + */ + protected function getThemeNamespace($key) + { + return $this->getCurrent() . "::{$key}"; + } +} \ No newline at end of file diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 73ae3e52..40435ce0 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -1,238 +1,178 @@ -finder = $finder; - $this->config = $config; - $this->lang = $lang; - $this->views = $views; - } - - /** - * Register the namespaces. - */ - public function registerNamespaces() - { - foreach($this->all() as $theme) - { - foreach(array('views', 'lang') as $hint) - { - $this->{$hint}->addNamespace($theme, $this->getNamespacePath($theme, $hint)); - } - } - } - /** - * Get path for namespace. + * Get name. * - * @param $theme - * @param $type * @return string */ - protected function getNamespacePath($theme, $type) - { - return $this->getThemePath($theme) . "/{$type}"; - } - - /** - * Get theme path by given theme name. - * - * @param $theme - * @return null|string - */ - public function getThemePath($theme) + public function getName() { - return $this->path ."/{$theme}"; + return $this->name; } /** - * Get current theme. + * Get description. * * @return string */ - public function getCurrent() + public function getDescription() { - return $this->current ?: $this->config->get('themes.default'); + return $this->description; } /** - * Set current theme. + * Get author info. * - * @param string $current - * @return $this + * @return array */ - public function setCurrent($current) + public function getAuthor() { - $this->current = $current; - - return $this; + return $this->author; } /** - * The alias "setCurrent" method. + * Determine whether this theme is disabled. * - * @param $theme - * @return $this + * @return bool */ - public function set($theme) + public function disabled() { - return $this->setCurrent($theme); + return ! $this->enabled(); } /** - * Get all themes. + * Determine whether this theme is enabled. * - * @return array - */ - public function all() - { - return $this->finder->find($this->path, $this->filename); - } - - /** - * Check whether the given theme in all themes. - * - * @param $theme * @return bool */ - public function has($theme) + public function enabled() { - return in_array($theme, $this->all()); + return $this->enabled == true; } /** - * Alias for "has" method. + * Determine whether the current theme is equal with this theme. * - * @param $theme * @return bool */ - public function exists($theme) + public function isActive() { - return $this->has($theme); + return ThemeFacade::getCurrent() == $this->name; } /** - * Set theme path on runtime. + * Get author info. * - * @param $path - * @return Finder + * @param string $type + * @param null $default + * @return string|null */ - public function setPath($path) + public function getAuthorInfo($type, $default = null) { - return $this->path = $path; + return array_get($this->author, $type, $default); } /** - * Get theme path. + * Get author name. * - * @return mixed + * @param null $default + * @return string|null */ - public function getPath() + public function getAuthorName($default = null) { - return $this->path ?: $this->config->get('themes.path'); + return $this->getAuthorInfo('name', $default); } /** - * Get view from current theme. + * Get author email. * - * @param $view - * @param array $data - * @param array $mergeData - * @return mixed + * @param null $default + * @return string|null */ - public function view($view, $data = array(), $mergeData = array()) + public function getAuthorEmail($default = null) { - return $this->views->make($this->getThemeNamespace($view), $data, $mergeData); + return $this->getAuthorInfo('email', $default); } /** - * Get config from current theme. + * Get info from this theme. * * @param $key * @param null $default * @return mixed */ - public function config($key, $default = null) + public function get($key, $default = null) { - return $this->config->get($this->getThemeNamespace($key), $default); + if (property_exists($this, $key)) + { + return $this->{$key}; + } + + return $default; } /** - * Get lang from current theme. + * Handle call to __get method. * * @param $key - * @param array $replace - * @param null $locale - * @return string + * @return mixed */ - public function lang($key, $replace = array(), $locale = null) + public function __get($key) { - return $this->lang->get($this->getThemeNamespace($key), $replace, $locale); + return $this->get($key); } /** - * Get theme namespace by given key. + * Handle call to __set method. * * @param $key - * @return string + * @param $value */ - protected function getThemeNamespace($key) + public function __set($key, $value) { - return $this->getCurrent() . "::{$key}"; + if (property_exists($this, $key)) + { + $this->{$key} = $value; + } } + } \ No newline at end of file From 42651c0b1b17e9706bceb1ed905104c5c8ee150e Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 16:07:11 +0700 Subject: [PATCH 152/357] Add Json class to Support component & add composer json to it --- src/Pingpong/Support/Json.php | 216 +++++++++++++++++++++++++++++ src/Pingpong/Support/composer.json | 26 ++++ 2 files changed, 242 insertions(+) create mode 100644 src/Pingpong/Support/Json.php create mode 100644 src/Pingpong/Support/composer.json diff --git a/src/Pingpong/Support/Json.php b/src/Pingpong/Support/Json.php new file mode 100644 index 00000000..e3cba4d7 --- /dev/null +++ b/src/Pingpong/Support/Json.php @@ -0,0 +1,216 @@ +path = (string)$path; + $this->filesystem = $filesystem ?: new Filesystem; + $this->attributes = Collection::make($this->getAttributes()); + } + + /** + * Get filesystem. + * + * @return Filesystem + */ + public function getFilesystem() + { + return $this->filesystem; + } + + /** + * Set filesystem. + * + * @param Filesystem $filesystem + * @return $this + */ + public function setFilesystem(Filesystem $filesystem) + { + $this->filesystem = $filesystem; + + return $this; + } + + /** + * Get path. + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set path. + * + * @param mixed $path + * @return $this + */ + public function setPath($path) + { + $this->path = (string)$path; + + return $this; + } + + /** + * Make new instance. + * + * @param string $path + * @param \Illuminate\Filesystem\Filesystem $filesystem + * @return static + */ + public static function make($path, Filesystem $filesystem = null) + { + return new static($path, $filesystem); + } + + /** + * Get file content. + * + * @return string + */ + public function getContents() + { + return $this->filesystem->get($this->getPath()); + } + + /** + * Get file contents as array. + * + * @return array + */ + public function getAttributes() + { + return json_decode($this->getContents(), 1); + } + + /** + * Convert the given array data to pretty json. + * + * @param array $data + * @return string + */ + public function toJsonPretty(array $data = null) + { + return json_encode($data ?: $this->attributes, JSON_PRETTY_PRINT); + } + + /** + * Update json contents from array data. + * + * @param array $data + * @return boolean + */ + public function update(array $data) + { + $this->attributes = new Collection(array_merge($this->attributes->toArray(), $data)); + + return $this->save(); + } + + /** + * Set a specific key & value. + * + * @param string $key + * @param mixed $value + * @return $this + */ + public function set($key, $value) + { + $this->attributes->offsetSet($key, $value); + + return $this; + } + + /** + * Save the current attributes array to the file storage. + * + * @return bool + */ + public function save() + { + return $this->filesystem->put($this->getPath(), $this->toJsonPretty()); + } + + /** + * Handle magic method __get. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this->get($key); + } + + /** + * Get the specified attribute from json file. + * + * @param $key + * @param null $default + * @return mixed + */ + public function get($key, $default = null) + { + return $this->attributes->get($key, $default); + } + + /** + * Handle call to __call method. + * + * @param string $method + * @param array $arguments + * @return mixed + */ + public function __call($method, $arguments = []) + { + if (method_exists($this, $method)) return call_user_func_array([$this, $method], $arguments); + + return call_user_func_array([$this->attributes, $method], $arguments); + } + + /** + * Handle call to __toString method. + * + * @return string + */ + public function __toString() + { + return $this->getContents(); + } + +} \ No newline at end of file diff --git a/src/Pingpong/Support/composer.json b/src/Pingpong/Support/composer.json new file mode 100644 index 00000000..ef6fea48 --- /dev/null +++ b/src/Pingpong/Support/composer.json @@ -0,0 +1,26 @@ +{ + "name": "pingpong/support", + "description": "Support Component of Pingpong Sky Package", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Pingpong Labs", + "email": "pingpong.labs@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "illuminate/filesystem": "5.0.x@dev", + }, + "require-dev": { + "phpunit/phpunit": "~4", + "mockery/mockery": "~0.9", + "pingpong/testing": "1.*" + }, + "autoload": { + "psr-4": { + "Pingpong\\Support\\": "" + } + }, + "minimum-stability": "dev" +} From 0b597fcc0504054ae21ed4744a3167f7f4782217 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 17:50:31 +0700 Subject: [PATCH 153/357] Fix wrong class --- src/Pingpong/Themes/ThemesServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/ThemesServiceProvider.php index f3e29eb2..08243101 100644 --- a/src/Pingpong/Themes/ThemesServiceProvider.php +++ b/src/Pingpong/Themes/ThemesServiceProvider.php @@ -54,7 +54,7 @@ public function register() { $this->app['themes'] = $this->app->share(function ($app) { - return new Theme(new Finder, $app['config'], $app['view'], $app['translator']); + return new Repository(new Finder, $app['config'], $app['view'], $app['translator']); }); } From 6eb686028f2227c17519dd4c3f77761dec664244 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 17:50:55 +0700 Subject: [PATCH 154/357] Add path to theme attributes --- src/Pingpong/Themes/Finder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Pingpong/Themes/Finder.php b/src/Pingpong/Themes/Finder.php index c8e53bd7..d44e0c01 100644 --- a/src/Pingpong/Themes/Finder.php +++ b/src/Pingpong/Themes/Finder.php @@ -52,7 +52,11 @@ public function find($path, $filename = 'theme.json') */ protected function getInfo($file) { - return Json::make($file->getRealPath())->toArray(); + $attributes = Json::make($path = $file->getRealPath())->toArray(); + + $attributes['path'] = dirname($path); + + return $attributes; } } \ No newline at end of file From 587924c590972f723bac5a256d745107157b8c3a Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 17:51:28 +0700 Subject: [PATCH 155/357] Fix register namespaces of themes --- src/Pingpong/Themes/Repository.php | 6 ++++-- src/Pingpong/Themes/Theme.php | 33 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/Pingpong/Themes/Repository.php b/src/Pingpong/Themes/Repository.php index 5838b276..29cd4943 100644 --- a/src/Pingpong/Themes/Repository.php +++ b/src/Pingpong/Themes/Repository.php @@ -82,9 +82,11 @@ public function registerNamespaces() { foreach(array('views', 'lang') as $hint) { - $path = $this->getNamespacePath($theme->getName(), $hint); + $name = $theme->getLowerName(); + + $path = $this->getNamespacePath($name, $hint); - $this->{$hint}->addNamespace($theme, $path); + $this->{$hint}->addNamespace($name, $path); } } } diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 40435ce0..983bfd35 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -39,6 +39,29 @@ class Theme { */ protected $path; + /** + * Create new instance. + * + * @param array $attributes + */ + public function __construct(array $attributes = array()) + { + $this->setAttributes($attributes); + } + + /** + * Set attributes. + * + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + foreach ($attributes as $key => $value) + { + $this->{$key} = $value; + } + } + /** * Get name. * @@ -49,6 +72,16 @@ public function getName() return $this->name; } + /** + * Get name as lowercase. + * + * @return string + */ + public function getLowerName() + { + return strtolower($this->name); + } + /** * Get description. * From fa75efb3b08c7fd43ff0f52945fd46e8726e1990 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 18:03:17 +0700 Subject: [PATCH 156/357] Add theme helper --- src/Pingpong/Themes/ThemesServiceProvider.php | 12 ++++++++++++ src/Pingpong/Themes/helpers.php | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/Pingpong/Themes/helpers.php diff --git a/src/Pingpong/Themes/ThemesServiceProvider.php b/src/Pingpong/Themes/ThemesServiceProvider.php index 08243101..8f033b24 100644 --- a/src/Pingpong/Themes/ThemesServiceProvider.php +++ b/src/Pingpong/Themes/ThemesServiceProvider.php @@ -21,6 +21,18 @@ public function boot() $this->registerConfig(); $this->registerNamespaces(); + + $this->registerHelpers(); + } + + /** + * Register the helpers file. + * + * @return void + */ + public function registerHelpers() + { + require __DIR__ . '/helpers.php'; } /** diff --git a/src/Pingpong/Themes/helpers.php b/src/Pingpong/Themes/helpers.php new file mode 100644 index 00000000..88621ce7 --- /dev/null +++ b/src/Pingpong/Themes/helpers.php @@ -0,0 +1,17 @@ +view($view, $data, $mergeData); + } +} \ No newline at end of file From 4418152de6bcdb9cc95e313883aacb1709ebc008 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 18:16:36 +0700 Subject: [PATCH 157/357] Fix register namespace for each themes & add getPath method to Theme class --- src/Pingpong/Themes/Repository.php | 18 +----------------- src/Pingpong/Themes/Theme.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Pingpong/Themes/Repository.php b/src/Pingpong/Themes/Repository.php index 29cd4943..66461fd8 100644 --- a/src/Pingpong/Themes/Repository.php +++ b/src/Pingpong/Themes/Repository.php @@ -82,27 +82,11 @@ public function registerNamespaces() { foreach(array('views', 'lang') as $hint) { - $name = $theme->getLowerName(); - - $path = $this->getNamespacePath($name, $hint); - - $this->{$hint}->addNamespace($name, $path); + $this->{$hint}->addNamespace($theme->getLowerName(), $theme->getPath($hint)); } } } - /** - * Get path for namespace. - * - * @param $theme - * @param $type - * @return string - */ - protected function getNamespacePath($theme, $type) - { - return $this->getThemePath($theme) . "/{$type}"; - } - /** * Get theme path by given theme name. * diff --git a/src/Pingpong/Themes/Theme.php b/src/Pingpong/Themes/Theme.php index 983bfd35..0d44e3a7 100644 --- a/src/Pingpong/Themes/Theme.php +++ b/src/Pingpong/Themes/Theme.php @@ -62,6 +62,19 @@ public function setAttributes(array $attributes) } } + /** + * Get theme path. + * + * @param string $hint + * @return string + */ + public function getPath($hint = null) + { + if( ! is_null($hint)) return $this->path . '/' . $hint; + + return $this->hint; + } + /** * Get name. * From 8b17af05442158b98d316524e2eabfc3d4baa844 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 18:18:35 +0700 Subject: [PATCH 158/357] Add find method, used for find a specified theme --- src/Pingpong/Themes/Repository.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Pingpong/Themes/Repository.php b/src/Pingpong/Themes/Repository.php index 66461fd8..08c5b7f3 100644 --- a/src/Pingpong/Themes/Repository.php +++ b/src/Pingpong/Themes/Repository.php @@ -87,6 +87,22 @@ public function registerNamespaces() } } + /** + * Find the specified theme. + * + * @param string $search + * @return \Pingpong\Themes\Theme|null + */ + public function find($search) + { + foreach ($this->all() as $theme) + { + if($theme->getLowerName() == strtolower($earch)) return $theme; + } + + return null; + } + /** * Get theme path by given theme name. * From bc93059969ce99989d350fdb73dccbb0c0bb9fa2 Mon Sep 17 00:00:00 2001 From: Gravitano Date: Sun, 22 Mar 2015 20:22:05 +0700 Subject: [PATCH 159/357] reformat code --- src/Pingpong/Generators/CommandGenerator.php | 4 +- .../Generators/Console/CrudCommand.php | 4 +- .../Contracts/GeneratorInterface.php | 10 +- src/Pingpong/Generators/CrudGenerator.php | 18 +- .../Exceptions/FileAlreadyExistException.php | 4 +- .../InvalidMigrationNameException.php | 4 +- src/Pingpong/Generators/FileGenerator.php | 36 ++-- src/Pingpong/Generators/Generator.php | 6 +- .../Generators/GeneratorsServiceProvider.php | 67 ++++---- .../Generators/MigrationGenerator.php | 62 ++++--- .../Providers/ConsoleServiceProvider.php | 18 +- .../Scaffold/ControllerGenerator.php | 162 +++++++++--------- .../Generators/Scaffold/FormGenerator.php | 58 +++---- src/Pingpong/Generators/Stub.php | 12 +- .../Generators/Traits/NamespaceTrait.php | 4 +- .../Generators/Traits/OptionableTrait.php | 6 +- src/Pingpong/Generators/ViewGenerator.php | 10 +- src/Pingpong/Generators/composer.json | 2 +- src/Pingpong/Menus/Menu.php | 154 ++++++++--------- src/Pingpong/Menus/MenuBuilder.php | 2 +- src/Pingpong/Menus/MenuItem.php | 6 +- src/Pingpong/Menus/MenusServiceProvider.php | 7 +- .../Bootstrap/NavPillsPresenter.php | 16 +- .../Presenters/Bootstrap/NavTabPresenter.php | 16 +- .../Presenters/Bootstrap/NavbarPresenter.php | 102 ++++++----- .../Bootstrap/NavbarRightPresenter.php | 37 ++-- .../Bootstrap/SidebarMenuPresenter.php | 115 +++++++------ src/Pingpong/Menus/Presenters/Presenter.php | 127 +++++++------- .../Menus/Presenters/PresenterInterface.php | 88 +++++----- src/Pingpong/Menus/src/config/config.php | 2 +- src/Pingpong/Menus/src/views/style.blade.php | 14 +- src/Pingpong/Modules/Collection.php | 5 +- src/Pingpong/Modules/Commands/DumpCommand.php | 6 +- .../Modules/Commands/GeneratorCommand.php | 2 +- src/Pingpong/Modules/Commands/ListCommand.php | 9 +- .../Modules/Commands/MigrationCommand.php | 2 +- src/Pingpong/Modules/Commands/SeedCommand.php | 2 +- .../Exceptions/ModuleNotFoundException.php | 4 +- .../Modules/Generators/ModuleGenerator.php | 25 ++- src/Pingpong/Modules/Json.php | 5 +- src/Pingpong/Modules/Module.php | 2 +- .../Modules/ModulesServiceProvider.php | 12 +- .../Providers/ContractsServiceProvider.php | 24 +-- src/Pingpong/Modules/Repository.php | 31 +++- .../Modules/Traits/ModuleCommandTrait.php | 2 - src/Pingpong/Modules/composer.json | 88 +++++----- src/Pingpong/Modules/src/config/config.php | 40 +++-- src/Pingpong/Shortcode/Shortcode.php | 10 +- src/Pingpong/Support/ImageTrait.php | 2 +- src/Pingpong/Support/Json.php | 5 +- src/Pingpong/Support/composer.json | 48 +++--- src/Pingpong/Support/helpers.php | 59 ++++--- src/Pingpong/Testing/Console/Kernel.php | 2 +- src/Pingpong/Testing/Exceptions/Handler.php | 6 +- src/Pingpong/Testing/TestCase.php | 5 - src/Pingpong/Themes/Finder.php | 24 +-- src/Pingpong/Themes/Repository.php | 16 +- src/Pingpong/Themes/Theme.php | 13 +- src/Pingpong/Themes/ThemesServiceProvider.php | 6 +- src/Pingpong/Themes/composer.json | 61 ++++--- src/Pingpong/Themes/helpers.php | 24 +-- src/Pingpong/Themes/src/config/config.php | 5 +- src/Pingpong/Trusty/Entities/Role.php | 10 +- .../Exceptions/PermissionDeniedException.php | 4 +- .../Trusty/Traits/PermissionTrait.php | 4 +- src/Pingpong/Trusty/Traits/TrustyTrait.php | 12 +- src/Pingpong/Trusty/Trusty.php | 9 +- src/Pingpong/Trusty/TrustyServiceProvider.php | 4 +- src/Pingpong/Trusty/src/config/config.php | 10 +- src/Pingpong/Widget/Widget.php | 11 +- src/Pingpong/Widget/WidgetServiceProvider.php | 5 +- src/Pingpong/Widget/composer.json | 60 ++++--- 72 files changed, 974 insertions(+), 873 deletions(-) diff --git a/src/Pingpong/Generators/CommandGenerator.php b/src/Pingpong/Generators/CommandGenerator.php index 414f7b25..a11e7d33 100644 --- a/src/Pingpong/Generators/CommandGenerator.php +++ b/src/Pingpong/Generators/CommandGenerator.php @@ -1,7 +1,7 @@ $this->argument('entity'), 'form' => $this->option('form'), diff --git a/src/Pingpong/Generators/Contracts/GeneratorInterface.php b/src/Pingpong/Generators/Contracts/GeneratorInterface.php index 2dd103a3..6ae010a5 100644 --- a/src/Pingpong/Generators/Contracts/GeneratorInterface.php +++ b/src/Pingpong/Generators/Contracts/GeneratorInterface.php @@ -2,11 +2,11 @@ interface GeneratorInterface { - /** - * Generate something amazing. - * - * @return void - */ + /** + * Generate something amazing. + * + * @return void + */ public function generate(); } \ No newline at end of file diff --git a/src/Pingpong/Generators/CrudGenerator.php b/src/Pingpong/Generators/CrudGenerator.php index 89eed276..b7d970c0 100644 --- a/src/Pingpong/Generators/CrudGenerator.php +++ b/src/Pingpong/Generators/CrudGenerator.php @@ -1,11 +1,10 @@ option('force')) return true; - + if ($this->option('force')) + { + return true; + } + return $this->console->confirm($message); } @@ -290,10 +292,10 @@ protected function runMigration() $this->call('migrate', []); } } - + /** * Dump autoload. - * + * * @return void */ protected function dumpAutoload() diff --git a/src/Pingpong/Generators/Exceptions/FileAlreadyExistException.php b/src/Pingpong/Generators/Exceptions/FileAlreadyExistException.php index 2daa266d..30d7c75b 100644 --- a/src/Pingpong/Generators/Exceptions/FileAlreadyExistException.php +++ b/src/Pingpong/Generators/Exceptions/FileAlreadyExistException.php @@ -1,3 +1,5 @@ $this->getClassName()]; + return ['CLASS_NAME' => $this->getClassName()]; } /** @@ -105,8 +105,8 @@ public function getDefaultReplacements() public function getTemplateContents() { return new Stub($this->stub, array_merge( - $this->getDefaultReplacements(), - $this->getStubReplacements() + $this->getDefaultReplacements(), + $this->getStubReplacements() ) ); } @@ -121,7 +121,7 @@ public function generateFile() { $path = $this->getDestinationFilePath(); - if($this->filesystem->exists($path)) + if ($this->filesystem->exists($path)) { throw new FileAlreadyExistException("File already exist : {$path}"); } @@ -135,13 +135,13 @@ public function generateFile() /** * Auto create directory. - * - * @param string $path - * @return void + * + * @param string $path + * @return void */ protected function autoCreateDirectory($path) { - if( ! is_dir($dir = dirname($path))) + if ( ! is_dir($dir = dirname($path))) { $this->filesystem->makeDirectory($dir); } @@ -149,7 +149,7 @@ protected function autoCreateDirectory($path) /** * Get destination filepath. - * + * * @return string */ public function getDestinationFilePath() diff --git a/src/Pingpong/Generators/Generator.php b/src/Pingpong/Generators/Generator.php index 949dea15..485551ba 100644 --- a/src/Pingpong/Generators/Generator.php +++ b/src/Pingpong/Generators/Generator.php @@ -7,7 +7,7 @@ abstract class Generator implements GeneratorInterface { /** * The filesystem instance. - * + * * @var \Illuminate\Filesystem\Filesystem */ protected $filesystem; @@ -22,7 +22,7 @@ public function __construct() /** * Get the filesystem instance. - * + * * @return \Illuminate\Filesystem\Filesystem */ public function getFilesystem() @@ -32,7 +32,7 @@ public function getFilesystem() /** * Set the filesystem instance. - * + * * @param \Illuminate\Filesystem\Filesystem $filesystem * @return $this */ diff --git a/src/Pingpong/Generators/GeneratorsServiceProvider.php b/src/Pingpong/Generators/GeneratorsServiceProvider.php index 83cf7327..05652be7 100644 --- a/src/Pingpong/Generators/GeneratorsServiceProvider.php +++ b/src/Pingpong/Generators/GeneratorsServiceProvider.php @@ -1,45 +1,44 @@ getSchemaParser(); - - if ($this->plain) return $this->getPlainStubContents(); - - elseif ($schema->isCreate()) return $this->getCreatingStubContents(); - - elseif ($schema->isAdd()) return $this->getAddingStubContents(); - - elseif ($schema->isDelete()) return $this->getDeletingStubContents(); - elseif ($schema->isDrop()) return $this->getDroppingStubContents(); + if ($this->plain) + { + return $this->getPlainStubContents(); + } + elseif ($schema->isCreate()) + { + return $this->getCreatingStubContents(); + } + elseif ($schema->isAdd()) + { + return $this->getAddingStubContents(); + } + elseif ($schema->isDelete()) + { + return $this->getDeletingStubContents(); + } + elseif ($schema->isDrop()) + { + return $this->getDroppingStubContents(); + } throw new InvalidMigrationNameException; } /** * Get fields. - * + * * @return Field */ public function getFields() @@ -107,8 +117,8 @@ public function getFields() /** * Get schema parser. - * - * @return Parser + * + * @return Parser */ public function getSchemaParser() { @@ -117,7 +127,7 @@ public function getSchemaParser() /** * Get stub contents for dropping action. - * + * * @return Stub */ protected function getPlainStubContents() @@ -127,7 +137,7 @@ protected function getPlainStubContents() /** * Get stub contents for creating action. - * + * * @return Stub */ protected function getCreatingStubContents() @@ -141,7 +151,7 @@ protected function getCreatingStubContents() /** * Get stub contents for adding action. - * + * * @return Stub */ protected function getAddingStubContents() @@ -156,7 +166,7 @@ protected function getAddingStubContents() /** * Get stub contents for deleting action. - * + * * @return Stub */ protected function getDeletingStubContents() @@ -171,11 +181,11 @@ protected function getDeletingStubContents() /** * Get stub contents for dropping action. - * + * * @return Stub */ protected function getDroppingStubContents() - { + { return new Stub('migration/drop', [ 'CLASS' => $this->getClassName(), 'FIELDS' => $this->getFields()->getSchemaCreate(), @@ -185,7 +195,7 @@ protected function getDroppingStubContents() /** * Get filename. - * + * * @return string */ public function getFilename() diff --git a/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php b/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php index eac259ca..4874b850 100644 --- a/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php +++ b/src/Pingpong/Generators/Providers/ConsoleServiceProvider.php @@ -4,14 +4,14 @@ class ConsoleServiceProvider extends ServiceProvider { - /** - * Register the commands. - * - * @return void - */ - public function register() - { - $this->commands('Pingpong\Generators\Console\CrudCommand'); - } + /** + * Register the commands. + * + * @return void + */ + public function register() + { + $this->commands('Pingpong\Generators\Console\CrudCommand'); + } } \ No newline at end of file diff --git a/src/Pingpong/Generators/Scaffold/ControllerGenerator.php b/src/Pingpong/Generators/Scaffold/ControllerGenerator.php index 77d408fe..b7b034ea 100644 --- a/src/Pingpong/Generators/Scaffold/ControllerGenerator.php +++ b/src/Pingpong/Generators/Scaffold/ControllerGenerator.php @@ -1,138 +1,140 @@ options = $options; - } + $this->options = $options; + } /** * Get class name. - * + * * @return string */ - public function getClassName() - { - return Str::studly(Str::plural(str_replace('Controller', '', $this->option('name')))) . 'Controller'; - } + public function getClassName() + { + return Str::studly(Str::plural(str_replace('Controller', '', $this->option('name')))) . 'Controller'; + } /** * Get prefix path. - * + * * @return string */ - public function getPrefixBackSlash() - { - return $this->prefix ? '\\' . $this->prefix : null; - } + public function getPrefixBackSlash() + { + return $this->prefix ? '\\' . $this->prefix : null; + } /** * Get prefix dot. - * + * * @return string */ - public function getPrefixDot() - { - return Str::lower($this->prefix ? $this->prefix . '.' : null); - } + public function getPrefixDot() + { + return Str::lower($this->prefix ? $this->prefix . '.' : null); + } /** * Get entity name in singular with studly case convention. - * + * * @return string */ - public function getStudlyEntityName() - { - return Str::studly(Str::singular($this->entity)); - } + public function getStudlyEntityName() + { + return Str::studly(Str::singular($this->entity)); + } /** * Get entity name in plural with studly case convention. - * + * * @return string */ - public function getStudlyPluralEntityName() - { - return Str::studly(Str::plural($this->entity)); - } + public function getStudlyPluralEntityName() + { + return Str::studly(Str::plural($this->entity)); + } + /** * Get entity name in plural with lower case convention. - * + * * @return string */ - public function getLowerPluralEntityName() - { - return Str::lower(Str::plural($this->entity)); - } + public function getLowerPluralEntityName() + { + return Str::lower(Str::plural($this->entity)); + } + /** * Get entity name in singular with lower case convention. - * + * * @return string */ - public function getLowerSingularEntityName() - { - return Str::lower(Str::singular($this->entity)); - } + public function getLowerSingularEntityName() + { + return Str::lower(Str::singular($this->entity)); + } /** * Get model name. - * + * * @return string */ - public function getModel() - { - return $this->getAppNamespace() . $this->model; - } + public function getModel() + { + return $this->getAppNamespace() . $this->model; + } /** * Get stub replacements. - * + * * @return array */ - public function getStubReplacements() - { - return [ - 'MODEL' => $this->getModel(), - 'ENTITY' => $this->entity, - 'PREFIX_BACKSLASH' => $this->getPrefixBackSlash(), - 'PREFIX_DOT' => $this->getPrefixDot(), - 'STUDLY_ENTITY' => $this->getStudlyEntityName(), - 'LOWER_PLURAL_ENTITY' => $this->getLowerPluralEntityName(), - 'LOWER_SINGULAR_ENTITY' => $this->getLowerSingularEntityName(), - 'STUDLY_PLURAL_ENTITY' => $this->getStudlyPluralEntityName() - ]; - } + public function getStubReplacements() + { + return [ + 'MODEL' => $this->getModel(), + 'ENTITY' => $this->entity, + 'PREFIX_BACKSLASH' => $this->getPrefixBackSlash(), + 'PREFIX_DOT' => $this->getPrefixDot(), + 'STUDLY_ENTITY' => $this->getStudlyEntityName(), + 'LOWER_PLURAL_ENTITY' => $this->getLowerPluralEntityName(), + 'LOWER_SINGULAR_ENTITY' => $this->getLowerSingularEntityName(), + 'STUDLY_PLURAL_ENTITY' => $this->getStudlyPluralEntityName() + ]; + } /** * Get template contents. @@ -142,8 +144,8 @@ public function getStubReplacements() public function getTemplateContents() { return new Stub($this->stub, array_merge( - $this->getDefaultReplacements(), - $this->getStubReplacements() + $this->getDefaultReplacements(), + $this->getStubReplacements() ) ); } @@ -158,7 +160,7 @@ public function generateFile() { $path = $this->getDestinationFilePath(); - if($this->filesystem->exists($path)) + if ($this->filesystem->exists($path)) { throw new FileAlreadyExistException("File already exist : {$path}"); } @@ -170,13 +172,13 @@ public function generateFile() /** * Auto create directory. - * - * @param string $path - * @return void + * + * @param string $path + * @return void */ protected function autoCreateDirectory($path) { - if( ! is_dir($dir = dirname($path))) + if ( ! is_dir($dir = dirname($path))) { $this->filesystem->makeDirectory($dir); } @@ -184,7 +186,7 @@ protected function autoCreateDirectory($path) /** * Get destination filepath. - * + * * @return string */ public function getDestinationFilePath() @@ -214,17 +216,17 @@ public function generate() /** * Get default replacements. - * - * @return array + * + * @return array */ public function getDefaultReplacements() { - return ['CLASS_NAME' => $this->getClassName()]; + return ['CLASS_NAME' => $this->getClassName()]; } public function __get($key) { - return $this->option($key); + return $this->option($key); } } \ No newline at end of file diff --git a/src/Pingpong/Generators/Scaffold/FormGenerator.php b/src/Pingpong/Generators/Scaffold/FormGenerator.php index 93898014..c0327c61 100644 --- a/src/Pingpong/Generators/Scaffold/FormGenerator.php +++ b/src/Pingpong/Generators/Scaffold/FormGenerator.php @@ -1,34 +1,34 @@ fields = $fields; - } - - /** - * Generate the form. - * - * @return string - */ - public function generate() - { + /** + * The list of form fields will be created. + * + * @var string + */ + protected $fields; + + /** + * Create a new instance. + * + * @param void + */ + public function __construct($fields) + { + $this->fields = $fields; + } + + /** + * Generate the form. + * + * @return string + */ + public function generate() + { $fields = explode(',', $this->fields); $result = ''; @@ -39,17 +39,17 @@ public function generate() $label = ucfirst($name); - $result .= PHP_EOL.$this->getStub($type, compact('name', 'label', 'type'))->getContents().PHP_EOL; + $result .= PHP_EOL . $this->getStub($type, compact('name', 'label', 'type'))->getContents() . PHP_EOL; } return $result; - } + } /** * Get stub for specified form type. - * + * * @param string $type - * @param array $replacements + * @param array $replacements * @return string */ protected function getStub($type, array $replacements) diff --git a/src/Pingpong/Generators/Stub.php b/src/Pingpong/Generators/Stub.php index 1da1acb1..fa074b64 100644 --- a/src/Pingpong/Generators/Stub.php +++ b/src/Pingpong/Generators/Stub.php @@ -18,14 +18,14 @@ class Stub { /** * The stub path. - * + * * @var string */ protected static $path; /** * The stub extension. - * + * * @var string */ protected $extension = '.stub'; @@ -56,17 +56,17 @@ public static function create($name, array $replaces = []) /** * Register the default stub path. - * + * * @return void */ public static function register() { - static::$path = __DIR__. '/Stubs'; + static::$path = __DIR__ . '/Stubs'; } /** * Set stub path. - * + * * @param string $path */ public static function setPath($path) @@ -76,7 +76,7 @@ public static function setPath($path) /** * Get stub path. - * + * * @return string */ public static function getPath() diff --git a/src/Pingpong/Generators/Traits/NamespaceTrait.php b/src/Pingpong/Generators/Traits/NamespaceTrait.php index 06f4eb05..251f376b 100644 --- a/src/Pingpong/Generators/Traits/NamespaceTrait.php +++ b/src/Pingpong/Generators/Traits/NamespaceTrait.php @@ -4,7 +4,7 @@ trait NamespaceTrait { /** * Get class namespace. - * + * * @return string */ public function getNamespace() @@ -20,7 +20,7 @@ public function getNamespace() */ public function appendNamespaceStub(array $replacements = []) { - return array_merge(['NAMESPACE' => $this->getNamespace()], $replacements); + return array_merge(['NAMESPACE' => $this->getNamespace()], $replacements); } } \ No newline at end of file diff --git a/src/Pingpong/Generators/Traits/OptionableTrait.php b/src/Pingpong/Generators/Traits/OptionableTrait.php index 2548781a..cb173f86 100644 --- a/src/Pingpong/Generators/Traits/OptionableTrait.php +++ b/src/Pingpong/Generators/Traits/OptionableTrait.php @@ -9,9 +9,9 @@ trait OptionableTrait { /** * Get the specified option by given key. - * - * @param string $key - * @param mixed $default + * + * @param string $key + * @param mixed $default * @return mixed */ public function option($key, $default = null) diff --git a/src/Pingpong/Generators/ViewGenerator.php b/src/Pingpong/Generators/ViewGenerator.php index b81d623d..34d1e30b 100644 --- a/src/Pingpong/Generators/ViewGenerator.php +++ b/src/Pingpong/Generators/ViewGenerator.php @@ -1,12 +1,9 @@ option('table')) return Str::plural($table); + if ($table = $this->option('table')) + { + return Str::plural($table); + } return $this->getLowerPluralEntityName(); } diff --git a/src/Pingpong/Generators/composer.json b/src/Pingpong/Generators/composer.json index 7fa386da..b8dc5005 100644 --- a/src/Pingpong/Generators/composer.json +++ b/src/Pingpong/Generators/composer.json @@ -17,7 +17,7 @@ "php": ">=5.4.0", "illuminate/filesystem": "5.0.*", "illuminate/support": "5.0.*", - "doctrine/dbal": "~2.5" + "doctrine/dbal": "~2.5" }, "require-dev": { "mockery/mockery": "~0.9", diff --git a/src/Pingpong/Menus/Menu.php b/src/Pingpong/Menus/Menu.php index da9f11fe..d529a8d5 100644 --- a/src/Pingpong/Menus/Menu.php +++ b/src/Pingpong/Menus/Menu.php @@ -2,92 +2,92 @@ use Closure; use Countable; -use Illuminate\View\Factory; use Illuminate\Config\Repository; +use Illuminate\View\Factory; class Menu implements Countable { - /** + /** * The menus collections. * - * @var array - */ - protected $menus = array(); - - /** - * The constructor. - * - * @param Factory $views - * @param Repository $config - */ - public function __construct(Factory $views, Repository $config) - { - $this->views = $views; - $this->config = $config; - } - - /** - * Make new menu. - * - * @param string $name - * @return \Pingpong\Menus\MenuBuilder - */ - public function make($name) - { - $builder = new MenuBuilder($name, $this->config); + * @var array + */ + protected $menus = array(); + + /** + * The constructor. + * + * @param Factory $views + * @param Repository $config + */ + public function __construct(Factory $views, Repository $config) + { + $this->views = $views; + $this->config = $config; + } + + /** + * Make new menu. + * + * @param string $name + * @return \Pingpong\Menus\MenuBuilder + */ + public function make($name) + { + $builder = new MenuBuilder($name, $this->config); $this->menus[$name] = $builder; - return $builder; - } + return $builder; + } - /** - * Create new menu. - * + /** + * Create new menu. + * * @param string $name * @param Callable $resolver * @return \Pingpong\Menus\MenuBuilder - */ - public function create($name, Closure $resolver) - { - $menus = $this->make($name); - - return $resolver($menus); - } - - /** - * Check if the menu exists. - * - * @param string $name - * @return boolean - */ - public function has($name) - { - return array_key_exists($name, $this->menus); - } - - /** - * Get instance of the given menu if exists. - * - * @param string $name - * @return string|null - */ - public function instance($name) - { - return $this->has($name) ? $this->menus[$name] : null; - } - - /** - * Render the menu tag by given name. - * - * @param string $name - * @param string $presenter - * @return string|null - */ - public function get($name, $presenter = null) - { - return $this->has($name) ? $this->menus[$name]->render($presenter) : null; - } + */ + public function create($name, Closure $resolver) + { + $menus = $this->make($name); + + return $resolver($menus); + } + + /** + * Check if the menu exists. + * + * @param string $name + * @return boolean + */ + public function has($name) + { + return array_key_exists($name, $this->menus); + } + + /** + * Get instance of the given menu if exists. + * + * @param string $name + * @return string|null + */ + public function instance($name) + { + return $this->has($name) ? $this->menus[$name] : null; + } + + /** + * Render the menu tag by given name. + * + * @param string $name + * @param string $presenter + * @return string|null + */ + public function get($name, $presenter = null) + { + return $this->has($name) ? $this->menus[$name]->render($presenter) : null; + } /** * Render the menu tag by given name. @@ -97,9 +97,9 @@ public function get($name, $presenter = null) * @return string */ public function render($name, $presenter = null) - { - return $this->get($name, $presenter); - } + { + return $this->get($name, $presenter); + } /** * Get a stylesheet for enable multilevel menu. @@ -128,7 +128,7 @@ public function all() */ public function count() { - return count($this->menus); + return count($this->menus); } /** diff --git a/src/Pingpong/Menus/MenuBuilder.php b/src/Pingpong/Menus/MenuBuilder.php index 7b1f29eb..5c57dd44 100644 --- a/src/Pingpong/Menus/MenuBuilder.php +++ b/src/Pingpong/Menus/MenuBuilder.php @@ -87,7 +87,7 @@ public function style($name) { $this->setPresenter($this->getStyle($name)); } - + return $this; } diff --git a/src/Pingpong/Menus/MenuItem.php b/src/Pingpong/Menus/MenuItem.php index a0953b95..b8002816 100644 --- a/src/Pingpong/Menus/MenuItem.php +++ b/src/Pingpong/Menus/MenuItem.php @@ -1,12 +1,11 @@ ' . PHP_EOL; - } - + /** + * {@inheritdoc } + */ + public function getOpenTagWrapper() + { + return PHP_EOL . '