Initial Commit
This commit is contained in:
commit
88b5850c32
12 changed files with 11441 additions and 0 deletions
55
src/DataObjectServiceProvider.php
Normal file
55
src/DataObjectServiceProvider.php
Normal 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' => [],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue