|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Cart; |
|
5
|
|
|
|
|
6
|
|
|
use Cart\Contracts\CartDriverContract; |
|
7
|
|
|
use Cart\Contracts\ServiceProviderContract; |
|
8
|
|
|
use Cart\Contracts\SourceConfiguration; |
|
9
|
|
|
use Illuminate\Container\Container; |
|
10
|
|
|
use Illuminate\Config\Repository; |
|
11
|
|
|
use Symfony\Component\Finder\Finder; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Kernel |
|
15
|
|
|
* |
|
16
|
|
|
* @package Cart |
|
17
|
|
|
*/ |
|
18
|
|
|
class Kernel |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var Container |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $app; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $configPath = __DIR__. '/../config'; |
|
29
|
|
|
/** |
|
30
|
|
|
* @var CartDriverContract |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $currentDriver; |
|
33
|
|
|
|
|
34
|
|
|
protected $coreServices = [ |
|
35
|
|
|
'config.singleton' => Repository::class, |
|
36
|
|
|
]; |
|
37
|
|
|
|
|
38
|
4 |
|
public function __construct() |
|
39
|
|
|
{ |
|
40
|
4 |
|
$this->app = Container::getInstance(); |
|
41
|
4 |
|
} |
|
42
|
|
|
|
|
43
|
3 |
|
public function bootstrapping() : void |
|
44
|
|
|
{ |
|
45
|
3 |
|
$this->loadCoreServiceProvider(); |
|
46
|
3 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Get type storage (Note: in config file) |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function getStorage() : CartDriverContract |
|
52
|
|
|
{ |
|
53
|
1 |
|
return $this->app->make(config('cart.storage')); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get all of the configuration files for the application. |
|
58
|
|
|
* @param SourceConfiguration $configuration |
|
59
|
|
|
*/ |
|
60
|
1 |
|
public function loadConfiguration(SourceConfiguration $configuration) : void |
|
61
|
|
|
{ |
|
62
|
1 |
|
config()->set($configuration->getName(), $configuration->get()); |
|
|
|
|
|
|
63
|
1 |
|
$this->loadServiceProvider(); |
|
64
|
1 |
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Load mandatory services for application |
|
68
|
|
|
*/ |
|
69
|
3 |
|
protected function loadCoreServiceProvider() : void |
|
70
|
|
|
{ |
|
71
|
3 |
|
foreach ($this->coreServices as $abstract => $service) { |
|
72
|
3 |
|
list($abstract, $type) = explode('.', $abstract); |
|
73
|
|
|
|
|
74
|
3 |
|
if (app()->resolved($abstract) === false) { |
|
75
|
1 |
|
if ($type == 'singleton') { |
|
76
|
1 |
|
$this->app->singleton($abstract, $service); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
3 |
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Load service provider from config file |
|
84
|
|
|
*/ |
|
85
|
1 |
|
protected function loadServiceProvider() : void |
|
86
|
|
|
{ |
|
87
|
1 |
|
foreach (config('cart.services') as $services) { |
|
88
|
|
|
/** @var ServiceProviderContract */ |
|
89
|
1 |
|
(new $services)->register($this->app); |
|
90
|
|
|
} |
|
91
|
1 |
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.