From 21ed43e229ebe81db576b7786d27272183898df2 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Thu, 3 Oct 2019 00:52:52 +0100 Subject: [PATCH] Updating the package * Allow to install laravel 6 minor releases * Updating the service provider + defer interface * Cleaning some code --- README.md | 4 +- _docs/0-Home.md | 2 +- _docs/1-Installation-and-Setup.md | 20 +++++----- _docs/2-Configuration.md | 36 ++++++++++++++++- composer.json | 8 ++-- helpers.php | 6 ++- src/BreadcrumbsServiceProvider.php | 51 +++++++----------------- src/Builder.php | 2 +- tests/BreadcrumbsServiceProviderTest.php | 5 ++- 9 files changed, 74 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 58013e2..5455885 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Breadcrumbs/r * Well tested with maximum code quality. * Easy setup & configuration. - * Laravel `5.0` to ` 6.0` are supported. + * Laravel `5.0` to ` 6.x` are supported. * Twitter Bootstrap `v3 | v4` are supported. * ZURB Foundation `v5 | v6` are supported. * Well documented & IDE Friendly. @@ -45,7 +45,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. - [ARCANEDEV][link-author] - [All Contributors][link-contributors] -[badge_laravel]: https://img.shields.io/badge/Laravel%20supported-5.0%20to%206.0-orange.svg?style=flat-square +[badge_laravel]: https://img.shields.io/badge/Laravel%20supported-5.0%20to%206.x-orange.svg?style=flat-square [badge_license]: https://img.shields.io/packagist/l/arcanedev/breadcrumbs.svg?style=flat-square [badge_build]: https://img.shields.io/travis/ARCANEDEV/Breadcrumbs.svg?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Breadcrumbs.svg?style=flat-square diff --git a/_docs/0-Home.md b/_docs/0-Home.md index 946d7b9..5cd24f3 100644 --- a/_docs/0-Home.md +++ b/_docs/0-Home.md @@ -6,7 +6,7 @@ A simple breadcrumbs generator helper. * Well tested with maximum code quality. * Easy setup & configuration. - * Laravel `5.0` to ` 6.0` are supported. + * Laravel `5.0` to ` 6.x` are supported. * Twitter Bootstrap `v3 | v4` are supported. * ZURB Foundation `v5 | v6` are supported. * Well documented & IDE Friendly. diff --git a/_docs/1-Installation-and-Setup.md b/_docs/1-Installation-and-Setup.md index d7dbe2d..07c1423 100644 --- a/_docs/1-Installation-and-Setup.md +++ b/_docs/1-Installation-and-Setup.md @@ -16,7 +16,7 @@ | ![Breadcrumbs v3.2.x][breadcrumbs_3_2_x] | ![Laravel v5.6][laravel_5_6] | | ![Breadcrumbs v3.3.x][breadcrumbs_3_3_x] | ![Laravel v5.7][laravel_5_7] | | ![Breadcrumbs v3.4.x][breadcrumbs_3_4_x] | ![Laravel v5.8][laravel_5_8] | -| ![Breadcrumbs v4.0.x][breadcrumbs_4_0_x] | ![Laravel v6.0][laravel_6_0] | +| ![Breadcrumbs v4.x][breadcrumbs_4_x] | ![Laravel v6.x][laravel_6_x] | [laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0" [laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1" @@ -27,15 +27,15 @@ [laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6" [laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7" [laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8" -[laravel_6_0]: https://img.shields.io/badge/v6.0-supported-brightgreen.svg?style=flat-square "Laravel v6.0" - -[breadcrumbs_2_x]: https://img.shields.io/badge/version-2.*-blue.svg?style=flat-square "Breadcrumbs v2.*" -[breadcrumbs_3_0_x]: https://img.shields.io/badge/version-3.0.*-blue.svg?style=flat-square "Breadcrumbs v3.0.*" -[breadcrumbs_3_1_x]: https://img.shields.io/badge/version-3.1.*-blue.svg?style=flat-square "Breadcrumbs v3.1.*" -[breadcrumbs_3_2_x]: https://img.shields.io/badge/version-3.2.*-blue.svg?style=flat-square "Breadcrumbs v3.2.*" -[breadcrumbs_3_3_x]: https://img.shields.io/badge/version-3.3.*-blue.svg?style=flat-square "Breadcrumbs v3.3.*" -[breadcrumbs_3_4_x]: https://img.shields.io/badge/version-3.4.*-blue.svg?style=flat-square "Breadcrumbs v3.4.*" -[breadcrumbs_4_0_x]: https://img.shields.io/badge/version-4.0.*-blue.svg?style=flat-square "Breadcrumbs v4.0.*" +[laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.x" + +[breadcrumbs_2_x]: https://img.shields.io/badge/version-2.x-blue.svg?style=flat-square "Breadcrumbs v2.x" +[breadcrumbs_3_0_x]: https://img.shields.io/badge/version-3.0.x-blue.svg?style=flat-square "Breadcrumbs v3.0.x" +[breadcrumbs_3_1_x]: https://img.shields.io/badge/version-3.1.x-blue.svg?style=flat-square "Breadcrumbs v3.1.x" +[breadcrumbs_3_2_x]: https://img.shields.io/badge/version-3.2.x-blue.svg?style=flat-square "Breadcrumbs v3.2.x" +[breadcrumbs_3_3_x]: https://img.shields.io/badge/version-3.3.x-blue.svg?style=flat-square "Breadcrumbs v3.3.x" +[breadcrumbs_3_4_x]: https://img.shields.io/badge/version-3.4.x-blue.svg?style=flat-square "Breadcrumbs v3.4.x" +[breadcrumbs_4_x]: https://img.shields.io/badge/version-4.x-blue.svg?style=flat-square "Breadcrumbs v4.x" ## Composer diff --git a/_docs/2-Configuration.md b/_docs/2-Configuration.md index 1276d8a..9b31c60 100644 --- a/_docs/2-Configuration.md +++ b/_docs/2-Configuration.md @@ -6,4 +6,38 @@ 2. [Configuration](2-Configuration.md) 3. [Usage](3-Usage.md) -> Coming Soon... +```php + [ + + 'default' => Arcanedev\Breadcrumbs\Breadcrumbs::DEFAULT_TEMPLATE, + + 'supported' => [ + // Twitter Bootstrap + 'bootstrap-3' => 'breadcrumbs::bootstrap-3', + 'bootstrap-4' => 'breadcrumbs::bootstrap-4', + + // Zurb Foundation + 'foundation-5' => 'breadcrumbs::foundation-5', + 'foundation-6' => 'breadcrumbs::foundation-6', + ], + + ], + + /* ----------------------------------------------------------------- + | Route + | ----------------------------------------------------------------- + */ + + 'home-route' => 'public::home', + +]; +``` diff --git a/composer.json b/composer.json index 861cc9b..6f2aba3 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,12 @@ "license": "MIT", "require": { "php": ">=7.2.0", - "arcanedev/support": "~5.0.0" + "arcanedev/support": "^5.0" }, "require-dev": { - "orchestra/testbench": "~4.0.0", - "phpunit/phpcov": "~6.0", - "phpunit/phpunit": "~8.0" + "orchestra/testbench": "^4.0", + "phpunit/phpcov": "^6.0", + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { diff --git a/helpers.php b/helpers.php index ec4a696..5fff884 100644 --- a/helpers.php +++ b/helpers.php @@ -1,12 +1,14 @@ */ -class BreadcrumbsServiceProvider extends PackageServiceProvider +class BreadcrumbsServiceProvider extends PackageServiceProvider implements DeferrableProvider { /* ----------------------------------------------------------------- | Properties @@ -22,13 +23,6 @@ class BreadcrumbsServiceProvider extends PackageServiceProvider */ protected $package = 'breadcrumbs'; - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = true; - /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- @@ -37,22 +31,26 @@ class BreadcrumbsServiceProvider extends PackageServiceProvider /** * Register the service provider. */ - public function register() + public function register(): void { parent::register(); $this->registerConfig(); - $this->registerBreadcrumbsService(); + + // Register the Breadcrumbs service. + $this->singleton(Contracts\Breadcrumbs::class, function ($app) { + return new Breadcrumbs( + $app['config']->get('breadcrumbs.template.supported', []), + $app['config']->get('breadcrumbs.template.default', '') + ); + }); } /** * Boot the service provider. */ - public function boot() + public function boot(): void { - parent::boot(); - - // Publishes $this->publishConfig(); $this->publishViews(); $this->publishTranslations(); @@ -63,31 +61,10 @@ public function boot() * * @return array */ - public function provides() + public function provides(): array { return [ Contracts\Breadcrumbs::class, ]; } - - /* ----------------------------------------------------------------- - | Other Methods - | ----------------------------------------------------------------- - */ - - /** - * Register the Breadcrumbs service. - */ - private function registerBreadcrumbsService() - { - $this->singleton(Contracts\Breadcrumbs::class, function ($app) { - /** @var \Illuminate\Contracts\Config\Repository $config */ - $config = $app['config']; - - return new Breadcrumbs( - $config->get('breadcrumbs.template.supported', []), - $config->get('breadcrumbs.template.default', '') - ); - }); - } } diff --git a/src/Builder.php b/src/Builder.php index 5e8f44e..62f7d70 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -156,7 +156,7 @@ private function checkName($name) { if ( ! is_string($name)) { throw new Exceptions\InvalidTypeException( - 'The name value must be a string, ' . gettype($name) . ' given' + 'The name value must be a string, '.gettype($name).' given' ); } diff --git a/tests/BreadcrumbsServiceProviderTest.php b/tests/BreadcrumbsServiceProviderTest.php index ae27901..d7a2c9c 100644 --- a/tests/BreadcrumbsServiceProviderTest.php +++ b/tests/BreadcrumbsServiceProviderTest.php @@ -47,8 +47,9 @@ public function it_can_be_instantiated() { $expectations = [ \Illuminate\Support\ServiceProvider::class, - \Arcanedev\Support\ServiceProvider::class, - \Arcanedev\Support\PackageServiceProvider::class, + \Illuminate\Contracts\Support\DeferrableProvider::class, + \Arcanedev\Support\Providers\ServiceProvider::class, + \Arcanedev\Support\Providers\PackageServiceProvider::class, BreadcrumbsServiceProvider::class, ];