diff --git a/UPGRADING.md b/UPGRADING.md index 97b9253d1..0eab387fd 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -2,6 +2,10 @@ Because there are many breaking changes an upgrade is not that easy. There are many edge cases this guide does not cover. We accept PRs to improve this guide. +## From 6.2.1 to 6.3.0 + +- The `src/Events/AddedRepositories.php` event was removed because of a [conflict with telescope](https://github.com/laravel/telescope/issues/1152). + ## From 5.x to 6.x ### Filtering diff --git a/src/Events/AddedRepositories.php b/src/Events/AddedRepositories.php deleted file mode 100644 index ed257c3c2..000000000 --- a/src/Events/AddedRepositories.php +++ /dev/null @@ -1,11 +0,0 @@ -registerPublishing(); } - $this->listeners(); - $this->app->make(HttpKernel::class)->pushMiddleware(RestifyInjector::class); } @@ -95,12 +90,4 @@ public static function migrationFileExists(string $migrationFileName): bool return false; } - - private function listeners(): void - { - Event::listen( - AddedRepositories::class, - [MountMissingRepositories::class, 'handle'], - ); - } } diff --git a/src/Listeners/MountMissingRepositories.php b/src/Listeners/MountMissingRepositories.php deleted file mode 100644 index 57c120bf3..000000000 --- a/src/Listeners/MountMissingRepositories.php +++ /dev/null @@ -1,16 +0,0 @@ -repositories)->each(function (string $repository) { - (new BootRepository($repository))->boot(); - }); - } -} diff --git a/src/Restify.php b/src/Restify.php index 119fa2a33..f4d744388 100644 --- a/src/Restify.php +++ b/src/Restify.php @@ -2,7 +2,7 @@ namespace Binaryk\LaravelRestify; -use Binaryk\LaravelRestify\Events\AddedRepositories; +use Binaryk\LaravelRestify\Bootstrap\BootRepository; use Binaryk\LaravelRestify\Events\RestifyBeforeEach; use Binaryk\LaravelRestify\Events\RestifyStarting; use Binaryk\LaravelRestify\Http\Requests\RestifyRequest; @@ -58,7 +58,7 @@ public static function repositoryForKey(string $key): ?string /** * Get the repository class name for a given model. * - * @param string $model + * @param string $model * @return string */ public static function repositoryForModel($model) @@ -75,7 +75,7 @@ public static function repositoryForModel($model) /** * Get the repository class name for a given table name. * - * @param string $table + * @param string $table * @return string */ public static function repositoryForTable($table) @@ -88,7 +88,7 @@ public static function repositoryForTable($table) /** * Register the given repositories. * - * @param array $repositories + * @param array $repositories * @return static */ public static function repositories(array $repositories) @@ -97,8 +97,9 @@ public static function repositories(array $repositories) array_merge(static::$repositories, $repositories) ); - - event(new AddedRepositories($repositories)); + collect($repositories)->each(function (string $repository) { + (new BootRepository($repository))->boot(); + }); return new static; } @@ -123,7 +124,10 @@ public static function repositoriesFrom(string $directory): void Str::after($repository->getPathname(), app_path().DIRECTORY_SEPARATOR) ); - if (is_subclass_of($repository, Repository::class) && (new ReflectionClass($repository))->isInstantiable()) { + if (is_subclass_of( + $repository, + Repository::class + ) && (new ReflectionClass($repository))->isInstantiable()) { $repositories[] = $repository; } } @@ -136,7 +140,7 @@ public static function repositoriesFrom(string $directory): void /** * Get the URI path prefix utilized by Restify. * - * @param null $plus + * @param null $plus * @return string */ public static function path($plus = null) @@ -153,7 +157,7 @@ public static function path($plus = null) * * This listener is added in the RestifyApplicationServiceProvider * - * @param \Closure|string $callback + * @param \Closure|string $callback * @return void */ public static function starting($callback) @@ -162,7 +166,7 @@ public static function starting($callback) } /** - * @param \Closure|string $callback + * @param \Closure|string $callback */ public static function beforeEach($callback) { @@ -172,7 +176,7 @@ public static function beforeEach($callback) /** * Set the callback used for intercepting any request exception. * - * @param \Closure|string $callback + * @param \Closure|string $callback */ public static function exceptionHandler($callback) { @@ -198,7 +202,7 @@ public static function sortResourcesWith() /** * Humanize the given value into a proper name. * - * @param string $value + * @param string $value * @return string */ public static function humanize($value) diff --git a/src/RestifyApplicationServiceProvider.php b/src/RestifyApplicationServiceProvider.php index 91170297a..d86ce4fb0 100644 --- a/src/RestifyApplicationServiceProvider.php +++ b/src/RestifyApplicationServiceProvider.php @@ -7,11 +7,11 @@ use Binaryk\LaravelRestify\Http\Controllers\Auth\RegisterController; use Binaryk\LaravelRestify\Http\Controllers\Auth\ResetPasswordController; use Binaryk\LaravelRestify\Http\Controllers\Auth\VerifyController; +use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use ReflectionException; -use RuntimeException; class RestifyApplicationServiceProvider extends ServiceProvider { @@ -33,9 +33,7 @@ public function boot() */ protected function repositories(): void { - if ((false === is_dir(app_path('Restify'))) && ! mkdir($concurrentDirectory = app_path('Restify')) && ! is_dir($concurrentDirectory)) { - throw new RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); - } + app(Filesystem::class)->ensureDirectoryExists(app_path('Restify')); Restify::repositoriesFrom(app_path('Restify')); }