|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Steven Bühner |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Steven Bühner |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace HtpasswdManager; |
|
10
|
|
|
|
|
11
|
|
|
use Zend\ModuleManager\Feature\AutoloaderProviderInterface; |
|
12
|
|
|
use Zend\Mvc\ModuleRouteListener; |
|
13
|
|
|
use Zend\Mvc\MvcEvent; |
|
14
|
|
|
use HtpasswdManager\Service\HtpasswdService; |
|
15
|
|
|
use HtpasswdManager\Service\UserService; |
|
16
|
|
|
|
|
17
|
|
|
class Module implements AutoloaderProviderInterface { |
|
18
|
|
|
|
|
19
|
|
|
public function getAutoloaderConfig() { |
|
20
|
|
|
return array( |
|
21
|
|
|
'Zend\Loader\StandardAutoloader' => array( |
|
22
|
|
|
'namespaces' => array( |
|
23
|
|
|
// if we're in a namespace deeper than one level we need to fix the \ in the path |
|
24
|
|
|
__NAMESPACE__ => __DIR__ . '/src/' . str_replace ( '\\', '/', __NAMESPACE__ ) |
|
25
|
|
|
) |
|
26
|
|
|
) |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getConfig() { |
|
|
|
|
|
|
31
|
|
|
return include __DIR__ . '/config/module.config.php'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function onBootstrap(MvcEvent $e) { |
|
35
|
|
|
// You may not need to do this if you're doing it elsewhere in your |
|
36
|
|
|
// application |
|
37
|
|
|
$eventManager = $e->getApplication ()->getEventManager (); |
|
38
|
|
|
$moduleRouteListener = new ModuleRouteListener (); |
|
39
|
|
|
$moduleRouteListener->attach ( $eventManager ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getServiceConfig() { |
|
43
|
|
|
return array( |
|
44
|
|
|
'factories' => array( |
|
45
|
|
|
'HtpasswdManager\Service\HtpasswdService' => function ($sm) { |
|
46
|
|
|
$config = $sm->get ( 'Config' ); |
|
47
|
|
|
|
|
48
|
|
|
if (! isset ( $config ['HtpasswdManager'] ) || ! is_array ( $config ['HtpasswdManager'] ) || ! isset ( $config ['HtpasswdManager'] ['htpasswd'] ) || empty ( $config ['HtpasswdManager'] ['htpasswd'] )) { |
|
49
|
|
|
throw new \Exception ( 'HtpasswdManager Config not found' ); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$htpasswd_filename = $config ['HtpasswdManager'] ['htpasswd']; |
|
53
|
|
|
$service = new HtpasswdService ( $htpasswd_filename ); |
|
54
|
|
|
|
|
55
|
|
|
return $service; |
|
56
|
|
|
} |
|
57
|
|
|
) |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
} |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.