Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/Events/AddedRepositories.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/LaravelRestifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
use Binaryk\LaravelRestify\Commands\SetupCommand;
use Binaryk\LaravelRestify\Commands\StoreCommand;
use Binaryk\LaravelRestify\Commands\StubCommand;
use Binaryk\LaravelRestify\Events\AddedRepositories;
use Binaryk\LaravelRestify\Http\Middleware\RestifyInjector;
use Binaryk\LaravelRestify\Listeners\MountMissingRepositories;
use Binaryk\LaravelRestify\Repositories\Repository;
use Illuminate\Contracts\Http\Kernel as HttpKernel;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;

Expand All @@ -38,8 +35,6 @@ public function boot(): void
$this->registerPublishing();
}

$this->listeners();

$this->app->make(HttpKernel::class)->pushMiddleware(RestifyInjector::class);
}

Expand Down Expand Up @@ -95,12 +90,4 @@ public static function migrationFileExists(string $migrationFileName): bool

return false;
}

private function listeners(): void
{
Event::listen(
AddedRepositories::class,
[MountMissingRepositories::class, 'handle'],
);
}
}
16 changes: 0 additions & 16 deletions src/Listeners/MountMissingRepositories.php

This file was deleted.

28 changes: 16 additions & 12 deletions src/Restify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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;
}
Expand All @@ -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;
}
}
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -162,7 +166,7 @@ public static function starting($callback)
}

/**
* @param \Closure|string $callback
* @param \Closure|string $callback
*/
public static function beforeEach($callback)
{
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/RestifyApplicationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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'));
}
Expand Down