Skip to content

Commit

Permalink
refactor(web): resolve HttpApplication via the container (#1)
Browse files Browse the repository at this point in the history
resolving `HttpApplication` via the container, and setting-up the `Singleton` attribute.
  • Loading branch information
yassiNebeL authored Oct 21, 2024
1 parent 2acdf9a commit 47b8e27
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Tempest/Http/src/HttpApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Tempest\Http;

use Tempest\Container\Container;
use Tempest\Container\Singleton;
use Tempest\Core\AppConfig;
use Tempest\Core\Application;
use Tempest\Core\Kernel;
Expand All @@ -16,6 +17,7 @@
use Tempest\Support\PathHelper;
use Throwable;

#[Singleton]
final readonly class HttpApplication implements Application
{
public function __construct(private Container $container)
Expand All @@ -29,17 +31,11 @@ public static function boot(
): self {
$container = Tempest::boot($root, $discoveryLocations);

// Application,
// TODO: can be refactored to resolve via the container
$application = new HttpApplication($container);

$container->singleton(Application::class, fn () => $application);

$root = $container->get(Kernel::class)->root;
$application = $container->get(HttpApplication::class);

// Application-specific setup
$logConfig = $container->get(LogConfig::class);
$logConfig->debugLogPath = PathHelper::make($root, '/log/debug.log');
$logConfig->debugLogPath = PathHelper::make($container->get(Kernel::class)->root, '/log/debug.log');
$logConfig->serverLogPath = env('SERVER_LOG');
$logConfig->channels[] = new AppendLogChannel(PathHelper::make($root, '/log/tempest.log'));

Expand Down

0 comments on commit 47b8e27

Please sign in to comment.