1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* Organizations Module Bootstrap |
5
|
|
|
* |
6
|
|
|
* @copyright https://yawik.org/COPYRIGHT.php |
7
|
|
|
* @license GPLv3 |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Organizations; |
11
|
|
|
|
12
|
|
|
use Core\ModuleManager\Feature\VersionProviderInterface; |
13
|
|
|
use Core\ModuleManager\Feature\VersionProviderTrait; |
14
|
|
|
use Core\ModuleManager\ModuleConfigLoader; |
15
|
|
|
use Core\Options\ModuleOptions as CoreOptions; |
16
|
|
|
use Yawik\Composer\RequireDirectoryPermissionInterface; |
17
|
|
|
use Laminas\EventManager\EventInterface; |
18
|
|
|
use Laminas\ModuleManager\Feature\DependencyIndicatorInterface; |
19
|
|
|
use Laminas\Mvc\MvcEvent; |
20
|
|
|
use Laminas\ModuleManager\Feature\BootstrapListenerInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Bootstrap class of the organizations module |
24
|
|
|
*/ |
25
|
|
|
class Module implements |
26
|
|
|
BootstrapListenerInterface, |
27
|
|
|
DependencyIndicatorInterface, |
28
|
|
|
RequireDirectoryPermissionInterface, |
29
|
|
|
VersionProviderInterface |
30
|
|
|
{ |
31
|
|
|
use VersionProviderTrait; |
32
|
|
|
|
33
|
|
|
const VERSION = \Core\Module::VERSION; |
34
|
|
|
/** |
35
|
|
|
* @param CoreOptions $options |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
|
|
public function getRequiredDirectoryLists(CoreOptions $options) |
39
|
|
|
{ |
40
|
|
|
return [ |
41
|
|
|
$options->getPublicDir().'/static/Organizations', |
42
|
|
|
$options->getPublicDir().'/static/Organizations/Image', |
43
|
|
|
]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Loads module specific configuration. |
48
|
|
|
* |
49
|
|
|
* @return array |
50
|
|
|
*/ |
51
|
5 |
|
public function getConfig() |
52
|
|
|
{ |
53
|
5 |
|
return ModuleConfigLoader::load(__DIR__ . '/../config'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
4 |
|
public function onBootstrap(EventInterface $e) |
58
|
|
|
{ |
59
|
|
|
/* @var $e MvcEvent */ |
60
|
4 |
|
$eventManager = $e->getApplication()->getEventManager(); |
61
|
4 |
|
$sharedManager = $eventManager->getSharedManager(); |
62
|
|
|
|
63
|
4 |
|
$createJobListener = new \Organizations\Acl\Listener\CheckJobCreatePermissionListener(); |
64
|
4 |
|
$createJobListener->attachShared($sharedManager); |
|
|
|
|
65
|
|
|
|
66
|
4 |
|
if ($e->getRequest() instanceof \Laminas\Http\Request) { |
67
|
|
|
$eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $event) { |
68
|
|
|
$serviceManager = $event->getApplication() |
69
|
|
|
->getServiceManager(); |
70
|
|
|
$options = $serviceManager->get('Organizations/ImageFileCacheOptions'); |
71
|
|
|
|
72
|
|
|
if ($options->getEnabled()) { |
73
|
|
|
$serviceManager->get('Organizations\ImageFileCache\ApplicationListener') |
74
|
|
|
->onDispatchError($event); |
75
|
|
|
} |
76
|
4 |
|
}); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
5 |
|
public function getModuleDependencies() |
81
|
|
|
{ |
82
|
|
|
return [ |
83
|
5 |
|
'Core', |
84
|
|
|
'Auth', |
85
|
|
|
]; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|