@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | */ |
30 | 30 | public function getCurrentUser() { |
31 | - return $this->request->getServer ()->get ( 'REMOTE_USER', null ); |
|
31 | + return $this->request->getServer()->get('REMOTE_USER', null); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function isUserDeleteable($username) { |
35 | - $eResult = $this->getEventManager ()->trigger ( 'pre_' . __FUNCTION__, $this, array( |
|
35 | + $eResult = $this->getEventManager()->trigger('pre_' . __FUNCTION__, $this, array( |
|
36 | 36 | $username |
37 | - ) ); |
|
37 | + )); |
|
38 | 38 | |
39 | - if ($eResult->stopped ()) |
|
40 | - return $eResult->last (); |
|
39 | + if ($eResult->stopped()) |
|
40 | + return $eResult->last(); |
|
41 | 41 | |
42 | - return ! in_array ( $username, $this->not_deletable_users ); |
|
42 | + return !in_array($username, $this->not_deletable_users); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function isUserAllowedToManageUsers($username) { |
46 | - $eResult = $this->getEventManager ()->trigger ( 'pre_' . __FUNCTION__, $this, array( |
|
46 | + $eResult = $this->getEventManager()->trigger('pre_' . __FUNCTION__, $this, array( |
|
47 | 47 | 'user' => $username |
48 | - ) ); |
|
48 | + )); |
|
49 | 49 | |
50 | - if ($eResult->stopped ()) |
|
51 | - return $eResult->last (); |
|
50 | + if ($eResult->stopped()) |
|
51 | + return $eResult->last(); |
|
52 | 52 | |
53 | 53 | /* If parameter is an array => allow only users in list. IF parameter is boolean, return boolean value */ |
54 | - if (is_array ( $this->user_with_management_permission )) { |
|
55 | - $accessAllowed = in_array ( $username, $this->user_with_management_permission ); |
|
54 | + if (is_array($this->user_with_management_permission)) { |
|
55 | + $accessAllowed = in_array($username, $this->user_with_management_permission); |
|
56 | 56 | } else { |
57 | 57 | $accessAllowed = ($this->user_with_management_permission === true); |
58 | 58 | } |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | public function setEventManager(EventManagerInterface $eventManager) { |
64 | - $eventManager->setIdentifiers ( array( |
|
64 | + $eventManager->setIdentifiers(array( |
|
65 | 65 | __CLASS__, |
66 | - get_class ( $this ) |
|
67 | - ) ); |
|
66 | + get_class($this) |
|
67 | + )); |
|
68 | 68 | $this->eventManager = $eventManager; |
69 | 69 | } |
70 | 70 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | 'Zend\Loader\StandardAutoloader' => array( |
22 | 22 | 'namespaces' => array( |
23 | 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__ ) |
|
24 | + __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/', __NAMESPACE__) |
|
25 | 25 | ) |
26 | 26 | ) |
27 | 27 | ); |
@@ -34,23 +34,23 @@ discard block |
||
34 | 34 | public function onBootstrap(MvcEvent $e) { |
35 | 35 | // You may not need to do this if you're doing it elsewhere in your |
36 | 36 | // application |
37 | - $eventManager = $e->getApplication ()->getEventManager (); |
|
38 | - $moduleRouteListener = new ModuleRouteListener (); |
|
39 | - $moduleRouteListener->attach ( $eventManager ); |
|
37 | + $eventManager = $e->getApplication()->getEventManager(); |
|
38 | + $moduleRouteListener = new ModuleRouteListener(); |
|
39 | + $moduleRouteListener->attach($eventManager); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getServiceConfig() { |
43 | 43 | return array( |
44 | 44 | 'factories' => array( |
45 | - 'HtpasswdManager\Service\HtpasswdService' => function ($sm) { |
|
46 | - $config = $sm->get ( 'Config' ); |
|
45 | + 'HtpasswdManager\Service\HtpasswdService' => function($sm) { |
|
46 | + $config = $sm->get('Config'); |
|
47 | 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' ); |
|
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 | 50 | } |
51 | 51 | |
52 | 52 | $htpasswd_filename = $config ['HtpasswdManager'] ['htpasswd']; |
53 | - $service = new HtpasswdService ( $htpasswd_filename ); |
|
53 | + $service = new HtpasswdService($htpasswd_filename); |
|
54 | 54 | |
55 | 55 | return $service; |
56 | 56 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $userService = $this->getServiceLocator()->get('HtpasswdManager\Service\UserService'); |
50 | 50 | |
51 | - $model = new ViewModel (array( |
|
51 | + $model = new ViewModel(array( |
|
52 | 52 | 'userList' => $result, |
53 | 53 | 'currentUser' => $userService->getCurrentUser() |
54 | 54 | )); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $messages = array(); |
80 | 80 | $htpasswd = $this->getHtpasswdService(); |
81 | 81 | |
82 | - $model = new ViewModel (); |
|
82 | + $model = new ViewModel(); |
|
83 | 83 | $model->setVariable('user', $user); |
84 | 84 | |
85 | 85 | $post = $this->getRequest()->getPost(); |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | $username = $this->getRequest()->getPost('username', ''); |
110 | 110 | $password = $this->getRequest()->getPost('password', ''); |
111 | 111 | $messages = array(); |
112 | - $model = new ViewModel (); |
|
112 | + $model = new ViewModel(); |
|
113 | 113 | |
114 | 114 | $post = $this->getRequest()->getPost(); |
115 | 115 | if (!isset ($post ['username'])) { |
116 | - return new ViewModel (array( |
|
116 | + return new ViewModel(array( |
|
117 | 117 | 'username' => $username, |
118 | 118 | 'password' => $password, |
119 | 119 | 'messages' => $messages |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $service = new HtpasswdService($testFile); |
44 | 44 | |
45 | 45 | $userList = $service->getUserList(); |
46 | - $this->assertEquals($expected = [ ], $userList, "UserList"); |
|
46 | + $this->assertEquals($expected = [], $userList, "UserList"); |
|
47 | 47 | |
48 | 48 | // Cleanup |
49 | 49 | unlink($testFile); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $userList = $service->getUserList(); |
59 | 59 | $this->assertEquals( |
60 | - $expected = [ 'steven' => '$apr1$UF1l/6iv$tT3IJUH.QL82HAraXetNo0', |
|
60 | + $expected = ['steven' => '$apr1$UF1l/6iv$tT3IJUH.QL82HAraXetNo0', |
|
61 | 61 | 'blub' => '$apr1$jVosh5nC$q6KJ5EZNU6thOPETMQw8O/' |
62 | 62 | ], $userList, "UserList"); |
63 | 63 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $userList = $service->getUserList(); |
87 | 87 | $this->assertCount(3, $userList); |
88 | - $this->assertEquals($expected = [ 'steven', 'blub', 'test' ], |
|
88 | + $this->assertEquals($expected = ['steven', 'blub', 'test'], |
|
89 | 89 | array_keys($userList)); |
90 | 90 | $this->assertEquals(3, $this->getNumberOfLines($testFile), "Number of Lines"); |
91 | 91 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $service->deleteUser('steven'); |
118 | 118 | $userList = $service->getUserList(); |
119 | 119 | $this->assertCount(1, $userList); |
120 | - $this->assertEquals($expected = [ 'blub' ], |
|
120 | + $this->assertEquals($expected = ['blub'], |
|
121 | 121 | array_keys($userList)); |
122 | 122 | $this->assertEquals(1, $this->getNumberOfLines($testFile), "Number of Lines"); |
123 | 123 |
@@ -7,25 +7,25 @@ |
||
7 | 7 | class UserServiceFactory { |
8 | 8 | |
9 | 9 | public function __invoke($sm) { |
10 | - $config = $sm->get ( 'Config' ); |
|
10 | + $config = $sm->get('Config'); |
|
11 | 11 | |
12 | 12 | // Default |
13 | 13 | $not_deletable_users = array(); |
14 | - if (isset ( $config ['HtpasswdManager'] ['not_deletable_users'] ) && is_array ( $config ['HtpasswdManager'] ['not_deletable_users'] )) { |
|
14 | + if (isset ($config ['HtpasswdManager'] ['not_deletable_users']) && is_array($config ['HtpasswdManager'] ['not_deletable_users'])) { |
|
15 | 15 | $not_deletable_users = $config ['HtpasswdManager'] ['not_deletable_users']; |
16 | 16 | } |
17 | 17 | |
18 | 18 | // Default |
19 | 19 | $user_with_management_permission = true; |
20 | - if (isset ( $config ['HtpasswdManager'] ['usermanagement_users'] ) && is_array ( $config ['HtpasswdManager'] ['usermanagement_users'] )) { |
|
20 | + if (isset ($config ['HtpasswdManager'] ['usermanagement_users']) && is_array($config ['HtpasswdManager'] ['usermanagement_users'])) { |
|
21 | 21 | $user_with_management_permission = $config ['HtpasswdManager'] ['usermanagement_users']; |
22 | 22 | } else if ($config ['HtpasswdManager'] ['usermanagement_users'] === false) { |
23 | 23 | $user_with_management_permission = false; |
24 | 24 | } |
25 | 25 | |
26 | - $request = $sm->get ( 'Request' ); |
|
26 | + $request = $sm->get('Request'); |
|
27 | 27 | |
28 | - return new UserService ( $request, $not_deletable_users, $user_with_management_permission ); |
|
28 | + return new UserService($request, $not_deletable_users, $user_with_management_permission); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | } |