http tests
This commit is contained in:
parent
b827038df3
commit
30706c3521
8 changed files with 216 additions and 214 deletions
23
src/Providers/DataObjectServiceProvider.php
Normal file
23
src/Providers/DataObjectServiceProvider.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Icefox\DTO\Providers;
|
||||
|
||||
use Icefox\DTO\Factories\DataObjectFactory;
|
||||
use Icefox\DTO\IDataObject;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class DataObjectServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->beforeResolving(function ($abstract, $parameters, $app) {
|
||||
if ($app->has($abstract)) {
|
||||
return;
|
||||
}
|
||||
if (is_subclass_of($abstract, IDataObject::class)) {
|
||||
$app->bind($abstract, fn($container) => DataObjectFactory::fromRequest($abstract, $container['request']));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue