Initial Commit

This commit is contained in:
icefox 2026-02-18 19:06:59 -03:00
commit 88b5850c32
No known key found for this signature in database
12 changed files with 11441 additions and 0 deletions

View file

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace Icefox\DTO;
use Icefox\DTO\Support\DataObjectRegistrar;
use Illuminate\Support\ServiceProvider;
class DataObjectServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/config/dto.php', 'dto');
$registrar = new DataObjectRegistrar($this->app);
// Register from configured namespaces or manual class list
$config = $this->getConfig();
if (!empty($config['classes'])) {
// Manual registration (zero overhead)
$registrar->registerMany($config['classes']);
} elseif (!empty($config['namespaces'])) {
// Automatic namespace scanning
$registrar->registerFromNamespaces($config['namespaces']);
}
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// Commands will be registered here
}
/**
* Get DataObject configuration.
*
* @return array{namespaces: string[], classes: class-string[]}
*/
protected function getConfig(): array
{
return config('dataobject', [
'namespaces' => [
'App\DataObjects',
],
'classes' => [],
]);
}
}