-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdependencies.php
More file actions
32 lines (26 loc) · 825 Bytes
/
dependencies.php
File metadata and controls
32 lines (26 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
* Registra as dependências no Container
*/
use src\Core\Container;
use src\Repositories\UsuarioRepository;
use src\Repositories\UsuarioRepositoryPgsql;
use src\Services\UsuarioService;
use src\Controllers\UsuarioController;
$container = Container::getInstance();
// Registra o Repository como singleton (uma única conexão)
$container->singleton(UsuarioRepository::class, function ($container) {
return new UsuarioRepositoryPgsql();
});
// Registra o Service
$container->bind(UsuarioService::class, function ($container) {
return new UsuarioService(
$container->make(UsuarioRepository::class)
);
});
// Registra o Controller
$container->bind(UsuarioController::class, function ($container) {
return new UsuarioController(
$container->make(UsuarioService::class)
);
});