1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JhFlexiTime; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Exception\Exception; |
6
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
7
|
|
|
use Zend\ModuleManager\Feature\AutoloaderProviderInterface; |
8
|
|
|
use Zend\EventManager\EventInterface; |
9
|
|
|
use Zend\Console\Adapter\AdapterInterface as Console; |
10
|
|
|
use JhInstaller\Install\Installable; |
11
|
|
|
use JhInstaller\Install\Exception as InstallException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* JhFlexiTime Module |
15
|
|
|
* |
16
|
|
|
* @author Ben Lill <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class Module implements |
19
|
|
|
ConfigProviderInterface, |
20
|
|
|
AutoloaderProviderInterface, |
21
|
|
|
Installable |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
public function onBootstrap(EventInterface $e) |
25
|
|
|
{ |
26
|
|
|
$sl = $e->getTarget()->getServiceManager(); |
27
|
|
|
$eventManager = $e->getTarget()->getEventManager(); |
28
|
|
|
$eventManager->attach($sl->get('JhFlexiTime\Listener\BookingSaveListener')); |
29
|
|
|
$eventManager->attach($sl->get('JhFlexiTime\Listener\CappedCreditListener')); |
30
|
|
|
|
31
|
|
|
$sharedEvm = $eventManager->getSharedManager(); |
32
|
|
|
|
33
|
|
|
//add roles to users created via HybridAuth |
34
|
|
|
$sharedEvm->attach( |
35
|
|
|
'ScnSocialAuth\Authentication\Adapter\HybridAuth', |
36
|
|
|
'registerViaProvider.post', |
37
|
|
|
[$this, 'onRegister'] |
38
|
|
|
); |
39
|
|
|
|
40
|
|
|
//add roles to users created via ZfcUser |
41
|
|
|
$sharedEvm->attach('ZfcUser\Service\User', 'register.post', [$this, 'onRegister']); |
42
|
|
|
|
43
|
|
|
$notificationService = $sl->get('JhHubBase\Notification\NotificationService'); |
44
|
|
|
$notificationService->addHandler( |
45
|
|
|
$sl->get('JhFlexiTime\NotificationHandler\MissedBookingEmailNotificationHandler') |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create User FlexiTime Settings |
51
|
|
|
* @param EventInterface $e |
52
|
|
|
*/ |
53
|
|
|
public function onRegister(EventInterface $e) |
54
|
|
|
{ |
55
|
|
|
$application = $e->getTarget(); |
|
|
|
|
56
|
|
|
$sl = $application->getServiceManager(); |
57
|
|
|
$installer = $sl->get('JhFlexiTime\Install\Installer'); |
58
|
|
|
$user = $e->getParam('user'); |
|
|
|
|
59
|
|
|
|
60
|
|
|
try { |
61
|
|
|
$installer->createSettingsRow($user); |
62
|
|
|
$installer->createRunningBalanceRow($user); |
63
|
|
|
} catch (InstallException $e) { |
64
|
|
|
//will only happen if database schema not created |
65
|
|
|
//log here |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritDoc} |
71
|
|
|
*/ |
72
|
|
|
public function getConfig() |
73
|
|
|
{ |
74
|
|
|
return include __DIR__ . '/../../config/module.config.php'; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritDoc} |
79
|
|
|
*/ |
80
|
|
|
public function getAutoloaderConfig() |
81
|
|
|
{ |
82
|
|
|
return [ |
83
|
|
|
'Zend\Loader\StandardAutoloader' => [ |
84
|
|
|
'namespaces' => [ |
85
|
|
|
__NAMESPACE__ => __DIR__ . '/../../src/' . __NAMESPACE__, |
86
|
|
|
], |
87
|
|
|
], |
88
|
|
|
]; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param Console $console |
93
|
|
|
* @return array|null|string |
94
|
|
|
*/ |
95
|
|
|
public function getConsoleUsage(Console $console) |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
return [ |
98
|
|
|
're-calc-balance-user <userEmail>' => |
99
|
|
|
"Recalculate a User's running balance", |
100
|
|
|
're-calc-balance-all ' => |
101
|
|
|
"Recalculate all User's running balance", |
102
|
|
|
'calc-prev-month-balance' => |
103
|
|
|
"Calculate the previous month balance for all users and add it on to their running balance", |
104
|
|
|
'set user init-balance <userEmail> <balance>' => |
105
|
|
|
"Set a user's starting balance", |
106
|
|
|
'notify-missing-bookings' => |
107
|
|
|
'Send reminder e-mail to any user who has missed bookings for the period specified in the config' |
108
|
|
|
]; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
|
|
public function getInstallService() |
115
|
|
|
{ |
116
|
|
|
return 'JhFlexiTime\Install\Installer'; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: