This repository was archived by the owner on Sep 26, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathModule.php
More file actions
129 lines (121 loc) · 4.64 KB
/
Copy pathModule.php
File metadata and controls
129 lines (121 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace Profile;
use Profile\View\Helper\UserAdmin;
use Profile\Service\ProfileService as profile;
use Profile\Controller\Plugin\UserIdent;
use Profile\View\Helper\DisplayName;
use Profile\View\Helper\LoginWidget;
use Profile\Form\LoginForm;
use Zend\Mail\Storage;
use Profile\View\Helper\UserIdentity;
use Doctrine\ORM\EntityManager;
use Profile\Mapper\UserMapper;
use Profile\View\Helper\Bbcode;
use Zend\Authentication\AuthenticationService;
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\Session\Config\SessionConfig;
use Zend\Session\Container;
use Zend\Session\SessionManager;
class Module implements ServiceProviderInterface
{
public function getAutoloaderConfig()
{
return array ('Zend\Loader\ClassMapAutoloader' => array (__DIR__ . '/autoload_classmap.php'),
'Zend\Loader\StandardAutoloader' => array ('namespaces' => array (
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'Service\Profile' => function($sm)
{
return new Service\ProfileService($sm);
},
'Zend\Authentication\AuthenticationService' => function($sm) {
return $sm->get('doctrine.authenticationservice.orm_default');
},
'userMapper' => function ($sm) {
$mapper = new UserMapper($sm->get('Doctrine\ORM\EntityManager'));
return $mapper;
},
'emailRenderer' => function($sm) {
$obj = $sm->get('Zend\View\Renderer\PhpRenderer');
return $obj;
},
'auth_service' => function ($sm) {
return new \Zend\Authentication\AuthenticationService();
},
'login_form' => function($sm) {
$form = new LoginForm();
return $form;
},
),
);
}
public function onBootstrap(\Zend\EventManager\EventInterface $e)
{
$application = $e->getApplication();
$serviceManager = $application->getServiceManager();
$controllerLoader = $serviceManager->get('ControllerLoader');
// Add initializer to Controller Service Manager that check if controllers needs entity manager injection
$controllerLoader->addInitializer(function ($instance) use ($serviceManager) {
if (method_exists($instance, 'setEntityManager')) {
$instance->setEntityManager($serviceManager->get('doctrine.entitymanager.orm_default'));
}
});
}
public function getViewHelperConfig()
{
return array(
'factories' => array(
'DisplayName' => function ($sm) {
$locator = $sm->getServiceLocator();
$viewHelper = new DisplayName($locator);
$viewHelper->setAuthService($locator->get('auth_service'));
return $viewHelper;
},
'UserId' => function ($sm) {
$locator = $sm->getServiceLocator();
$viewHelper = new UserIdentity();
$viewHelper->setAuthService($locator->get('auth_service'));
return $viewHelper;
},
'isAdmin' => function ($sm) {
$locator = $sm->getServiceLocator();
$viewHelper = new UserAdmin($sm);
$viewHelper->setAuthService($locator->get('auth_service'));
return $viewHelper;
},
'UserLoginWidget' => function ($sm) {
$locator = $sm->getServiceLocator();
$viewHelper = new LoginWidget();
$viewHelper->setLoginForm($locator->get('login_form'));
return $viewHelper;
},
),
);
}
public function getControllerPluginConfig()
{
return array(
'factories' => array(
'UserIdent' => function ($sm) {
$locator = $sm->getServiceLocator();
$plugin = new UserIdent();
$plugin->setAuthService($locator->get('auth_service'));
$plugin->setUserMapper($locator->get('userMapper'));
return $plugin;
},
),
);
}
}