Closed
Description
The server class is currently constructed in \LaravelJsonApi\Core\Server\ServerRepository
like this:
$server = new $class($this->container, $name);
I like to always use DI instead of facades and global helpers but that is not possible at the moment because of this line (for example when adding a scope that needs some dependency in the serving
method of the server).
My suggestion would be to have the server bound in the container under a convention key, like jsonapi_server_{$name}
.
So the line from above would become
$server = $this->container->make("jsonapi_server_{$name}");
That way we could completely override the binding in our code (or just contextually bind a dependency, like a guard for example if needed).
What do you think?