-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathioc.php
49 lines (44 loc) · 1.42 KB
/
ioc.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// Namespace declaration for the ioc class
namespace Lumenity\Framework\config\common\app;
// Importing the Container class from the Illuminate\Container namespace
use Illuminate\Container\Container;
/**
* Class ioc
*
* This class extends the Container class from the Illuminate\Container namespace.
* It provides methods to register service providers.
*/
class ioc extends Container
{
/**
* Method register
*
* This method is used to register a single service provider.
* It creates an instance of the service provider class and calls its register method.
*
* @param string $provider The fully qualified class name of the service provider.
*/
public function register(string $provider): void
{
$providerInstance = new $provider($this);
$providerInstance->register();
if (method_exists($providerInstance, 'boot')) {
$providerInstance->boot();
}
}
/**
* Method registerProviders
*
* This method is used to register multiple service providers.
* It loops through an array of service providers and calls the register method for each one.
*
* @param array $providers An array of fully qualified class names of the service providers.
*/
public function registerProviders(array $providers): void
{
foreach ($providers as $provider) {
$this->register($provider);
}
}
}