1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AbterPhp\PropellerAdmin\Bootstrappers\Events; |
6
|
|
|
|
7
|
|
|
use AbterPhp\Framework\Assets\AssetManager; |
8
|
|
|
use AbterPhp\PropellerAdmin\Events\Listeners\AdminDecorator; |
9
|
|
|
use AbterPhp\PropellerAdmin\Events\Listeners\LoginDecorator; |
10
|
|
|
use Opulence\Ioc\Bootstrappers\Bootstrapper; |
11
|
|
|
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper; |
12
|
|
|
use Opulence\Ioc\IContainer; |
13
|
|
|
|
14
|
|
|
class ListenersBootstrapper extends Bootstrapper implements ILazyBootstrapper |
15
|
|
|
{ |
16
|
|
|
const MODULE_IDENTIFIER = 'AbterPhp\\PropellerAdmin'; |
17
|
|
|
|
18
|
|
|
const PROPELLER_PATH = 'propeller/'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @return array |
22
|
|
|
*/ |
23
|
|
|
public function getBindings(): array |
24
|
|
|
{ |
25
|
|
|
return [ |
26
|
|
|
AdminDecorator::class, |
27
|
|
|
LoginDecorator::class, |
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @inheritdoc |
33
|
|
|
*/ |
34
|
|
|
public function registerBindings(IContainer $container) |
35
|
|
|
{ |
36
|
|
|
$resourceDir = $this->getResourceDir(); |
37
|
|
|
|
38
|
|
|
$header = file_get_contents($resourceDir . 'header.html'); |
39
|
|
|
$footer = file_get_contents($resourceDir . 'footer.html'); |
40
|
|
|
|
41
|
|
|
/** @var AssetManager $assetManager */ |
42
|
|
|
$assetManager = $container->resolve(AssetManager::class); |
43
|
|
|
|
44
|
|
|
$adminDecorator = new AdminDecorator($assetManager, $header, $footer); |
45
|
|
|
$loginDecorator = new LoginDecorator($assetManager, $header, $footer); |
46
|
|
|
|
47
|
|
|
$container->bindInstance(AdminDecorator::class, $adminDecorator); |
48
|
|
|
$container->bindInstance(LoginDecorator::class, $loginDecorator); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
protected function getResourceDir(): string |
55
|
|
|
{ |
56
|
|
|
global $abterModuleManager; |
57
|
|
|
|
58
|
|
|
foreach ($abterModuleManager->getResourcePaths() as $id => $path) { |
59
|
|
|
if ($id !== static::MODULE_IDENTIFIER) { |
60
|
|
|
continue; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return sprintf('%s/%s', $path, static::PROPELLER_PATH); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return ''; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|