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
|
|
|
protected $coreServices = [ |
26
|
|
|
'config.singleton' => Repository::class, |
27
|
|
|
]; |
28
|
|
|
|
29
|
5 |
|
public function __construct() |
30
|
|
|
{ |
31
|
5 |
|
$this->app = Container::getInstance(); |
32
|
5 |
|
} |
33
|
|
|
|
34
|
3 |
|
public function bootstrapping() : void |
35
|
|
|
{ |
36
|
3 |
|
$this->loadCoreServiceProvider(); |
37
|
3 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get type storage (Note: in config file) |
41
|
|
|
*/ |
42
|
1 |
|
public function getStorage() : CartDriverContract |
43
|
|
|
{ |
44
|
1 |
|
return $this->app->make(config('cart.storage')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get all of the configuration files for the application. |
49
|
|
|
* @param SourceConfiguration $configuration |
50
|
|
|
*/ |
51
|
1 |
|
public function loadConfiguration(SourceConfiguration $configuration) : void |
52
|
|
|
{ |
53
|
1 |
|
config()->set($configuration->getName(), $configuration->get()); |
|
|
|
|
54
|
1 |
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Load service provider from config file |
58
|
|
|
*/ |
59
|
1 |
|
public function loadServiceProvider() : void |
60
|
|
|
{ |
61
|
1 |
|
foreach (config('cart.services') as $services) { |
62
|
|
|
/** @var ServiceProviderContract */ |
63
|
1 |
|
(new $services)->register($this->app); |
64
|
|
|
} |
65
|
1 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Load mandatory services for application |
69
|
|
|
*/ |
70
|
3 |
|
protected function loadCoreServiceProvider() : void |
71
|
|
|
{ |
72
|
3 |
|
foreach ($this->coreServices as $abstract => $service) { |
73
|
3 |
|
list($abstract, $type) = explode('.', $abstract); |
74
|
|
|
|
75
|
3 |
|
if (app()->resolved($abstract) === false) { |
76
|
1 |
|
if ($type == 'singleton') { |
77
|
1 |
|
$this->app->singleton($abstract, $service); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
3 |
|
} |
82
|
|
|
} |
83
|
|
|
|
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.