Skip to content

Commit

Permalink
Working through issues sample application test environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Nov 14, 2024
1 parent 604d387 commit b0337f5
Show file tree
Hide file tree
Showing 19 changed files with 562 additions and 273 deletions.
8 changes: 3 additions & 5 deletions src/Commands/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Lunarstorm\LaravelDDD\Commands;

use Illuminate\Console\Command;
use Lunarstorm\LaravelDDD\Support\DomainAutoloader;
use Lunarstorm\LaravelDDD\Facades\DDD;
use Lunarstorm\LaravelDDD\Support\DomainMigration;

class OptimizeCommand extends Command
Expand All @@ -24,11 +24,9 @@ protected function configure()
public function handle()
{
$this->components->info('Caching DDD providers, commands, migration paths.');

$this->components->task('domain providers', fn () => DomainAutoloader::cacheProviders());
$this->components->task('domain commands', fn () => DomainAutoloader::cacheCommands());
$this->components->task('domain providers', fn () => DDD::autoloader()->cacheProviders());
$this->components->task('domain commands', fn () => DDD::autoloader()->cacheCommands());
$this->components->task('domain migration paths', fn () => DomainMigration::cachePaths());

$this->newLine();
}
}
23 changes: 13 additions & 10 deletions src/DomainManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lunarstorm\LaravelDDD;

use Lunarstorm\LaravelDDD\Support\Autoloader;
use Lunarstorm\LaravelDDD\Support\GeneratorBlueprint;
use Lunarstorm\LaravelDDD\Support\Path;

Expand Down Expand Up @@ -35,26 +36,33 @@ class DomainManager

protected ?GeneratorBlueprint $commandContext;

protected StubManager $stubs;

public function __construct()
{
$this->autoloadFilter = null;
$this->applicationLayerFilter = null;
$this->commandContext = null;
$this->stubs = new StubManager;
}

public function config(): ConfigManager
public function autoloader(): Autoloader
{
return app(ConfigManager::class);
return app(Autoloader::class);
}

public function composer(): ComposerManager
{
return app(ComposerManager::class);
}

public function config(): ConfigManager
{
return app(ConfigManager::class);
}

public function stubs(): StubManager
{
return app(StubManager::class);
}

public function filterAutoloadPathsUsing(callable $filter): void
{
$this->autoloadFilter = $filter;
Expand Down Expand Up @@ -94,9 +102,4 @@ public function laravelVersion($value)
{
return version_compare(app()->version(), $value, '>=');
}

public function stubs(): StubManager
{
return $this->stubs;
}
}
1 change: 1 addition & 0 deletions src/Facades/DDD.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @method static void filterAutoloadPathsUsing(callable $filter)
* @method static void resolveObjectSchemaUsing(callable $resolver)
* @method static string packagePath(string $path = '')
* @method static \Lunarstorm\LaravelDDD\Support\Autoloader autoloader()
* @method static \Lunarstorm\LaravelDDD\ConfigManager config()
* @method static \Lunarstorm\LaravelDDD\StubManager stubs()
* @method static \Lunarstorm\LaravelDDD\ComposerManager composer()
Expand Down
26 changes: 21 additions & 5 deletions src/LaravelDDDServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Lunarstorm\LaravelDDD;

use Illuminate\Database\Migrations\MigrationCreator;
use Lunarstorm\LaravelDDD\Support\DomainAutoloader;
use Lunarstorm\LaravelDDD\Support\Autoloader;
use Lunarstorm\LaravelDDD\Support\DomainMigration;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand All @@ -16,15 +16,27 @@ public function configurePackage(Package $package): void
return new DomainManager;
});

$this->app->scoped(ConfigManager::class, function () {
return new ConfigManager(config_path('ddd.php'));
$this->app->scoped(Autoloader::class, function () {
return new Autoloader;
});

$this->app->scoped(ComposerManager::class, function () {
return ComposerManager::make(app()->basePath('composer.json'));
});

$this->app->scoped(ConfigManager::class, function () {
return new ConfigManager(config_path('ddd.php'));
});

$this->app->scoped(StubManager::class, function () {
return new StubManager;
});

$this->app->bind('ddd', DomainManager::class);
$this->app->bind('ddd.autoloader', Autoloader::class);
$this->app->bind('ddd.config', ConfigManager::class);
$this->app->bind('ddd.composer', ComposerManager::class);
$this->app->bind('ddd.stubs', StubManager::class);

/*
* This class is a Package Service Provider
Expand Down Expand Up @@ -120,12 +132,16 @@ public function packageBooted()
key: 'laravel-ddd',
);
}

// dump([
// 'package booted' => config('ddd')
// ]);

app('ddd.autoloader')->boot();
}

public function packageRegistered()
{
(new DomainAutoloader)->autoload();

$this->registerMigrations();
}
}
Loading

0 comments on commit b0337f5

Please sign in to comment.