@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function __construct($action, $users, $roles, $verb = '', $ipRules = '') |
79 | 79 | { |
80 | 80 | $action = strtolower(trim($action)); |
81 | - if($action === 'allow' || $action === 'deny') |
|
81 | + if ($action === 'allow' || $action === 'deny') |
|
82 | 82 | $this->_action = $action; |
83 | 83 | else |
84 | 84 | throw new TInvalidDataValueException('authorizationrule_action_invalid', $action); |
@@ -89,46 +89,46 @@ discard block |
||
89 | 89 | $this->_guest = false; |
90 | 90 | $this->_authenticated = false; |
91 | 91 | |
92 | - if(trim($users) === '') |
|
92 | + if (trim($users) === '') |
|
93 | 93 | $users = '*'; |
94 | - foreach(explode(',', $users) as $user) |
|
94 | + foreach (explode(',', $users) as $user) |
|
95 | 95 | { |
96 | - if(($user = trim(strtolower($user))) !== '') |
|
96 | + if (($user = trim(strtolower($user))) !== '') |
|
97 | 97 | { |
98 | - if($user === '*') |
|
98 | + if ($user === '*') |
|
99 | 99 | { |
100 | 100 | $this->_everyone = true; |
101 | 101 | break; |
102 | 102 | } |
103 | - elseif($user === '?') |
|
103 | + elseif ($user === '?') |
|
104 | 104 | $this->_guest = true; |
105 | - elseif($user === '@') |
|
105 | + elseif ($user === '@') |
|
106 | 106 | $this->_authenticated = true; |
107 | 107 | else |
108 | 108 | $this->_users[] = $user; |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if(trim($roles) === '') |
|
112 | + if (trim($roles) === '') |
|
113 | 113 | $roles = '*'; |
114 | - foreach(explode(',', $roles) as $role) |
|
114 | + foreach (explode(',', $roles) as $role) |
|
115 | 115 | { |
116 | - if(($role = trim(strtolower($role))) !== '') |
|
116 | + if (($role = trim(strtolower($role))) !== '') |
|
117 | 117 | $this->_roles[] = $role; |
118 | 118 | } |
119 | 119 | |
120 | - if(($verb = trim(strtolower($verb))) === '') |
|
120 | + if (($verb = trim(strtolower($verb))) === '') |
|
121 | 121 | $verb = '*'; |
122 | - if($verb === '*' || $verb === 'get' || $verb === 'post') |
|
122 | + if ($verb === '*' || $verb === 'get' || $verb === 'post') |
|
123 | 123 | $this->_verb = $verb; |
124 | 124 | else |
125 | 125 | throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb); |
126 | 126 | |
127 | - if(trim($ipRules) === '') |
|
127 | + if (trim($ipRules) === '') |
|
128 | 128 | $ipRules = '*'; |
129 | - foreach(explode(',', $ipRules) as $ipRule) |
|
129 | + foreach (explode(',', $ipRules) as $ipRule) |
|
130 | 130 | { |
131 | - if(($ipRule = trim($ipRule)) !== '') |
|
131 | + if (($ipRule = trim($ipRule)) !== '') |
|
132 | 132 | $this->_ipRules[] = $ipRule; |
133 | 133 | } |
134 | 134 | } |
@@ -206,19 +206,19 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function isUserAllowed(IUser $user, $verb, $ip) |
208 | 208 | { |
209 | - if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
|
210 | - return ($this->_action === 'allow')?1:-1; |
|
209 | + if ($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
|
210 | + return ($this->_action === 'allow') ? 1 : -1; |
|
211 | 211 | else |
212 | 212 | return 0; |
213 | 213 | } |
214 | 214 | |
215 | 215 | private function isIpMatched($ip) |
216 | 216 | { |
217 | - if(empty($this->_ipRules)) |
|
217 | + if (empty($this->_ipRules)) |
|
218 | 218 | return 1; |
219 | - foreach($this->_ipRules as $rule) |
|
219 | + foreach ($this->_ipRules as $rule) |
|
220 | 220 | { |
221 | - if($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0)) |
|
221 | + if ($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0)) |
|
222 | 222 | return 1; |
223 | 223 | } |
224 | 224 | return 0; |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | |
232 | 232 | private function isRoleMatched($user) |
233 | 233 | { |
234 | - foreach($this->_roles as $role) |
|
234 | + foreach ($this->_roles as $role) |
|
235 | 235 | { |
236 | - if($role === '*' || $user->isInRole($role)) |
|
236 | + if ($role === '*' || $user->isInRole($role)) |
|
237 | 237 | return true; |
238 | 238 | } |
239 | 239 | return false; |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function isUserAllowed($user, $verb, $ip) |
34 | 34 | { |
35 | - if($user instanceof IUser) |
|
35 | + if ($user instanceof IUser) |
|
36 | 36 | { |
37 | 37 | $verb = strtolower(trim($verb)); |
38 | - foreach($this as $rule) |
|
38 | + foreach ($this as $rule) |
|
39 | 39 | { |
40 | - if(($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0) |
|
40 | + if (($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0) |
|
41 | 41 | return ($decision > 0); |
42 | 42 | } |
43 | 43 | return true; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function insertAt($index, $item) |
58 | 58 | { |
59 | - if($item instanceof TAuthorizationRule) |
|
59 | + if ($item instanceof TAuthorizationRule) |
|
60 | 60 | parent::insertAt($index, $item); |
61 | 61 | else |
62 | 62 | throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required'); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function setIsGuest($value) |
93 | 93 | { |
94 | - if($isGuest = TPropertyValue::ensureBoolean($value)) |
|
94 | + if ($isGuest = TPropertyValue::ensureBoolean($value)) |
|
95 | 95 | { |
96 | 96 | $this->setName($this->_manager->getGuestName()); |
97 | 97 | $this->setRoles([]); |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function setRoles($value) |
114 | 114 | { |
115 | - if(is_array($value)) |
|
115 | + if (is_array($value)) |
|
116 | 116 | $this->setState('Roles', $value, []); |
117 | 117 | else |
118 | 118 | { |
119 | 119 | $roles = []; |
120 | - foreach(explode(',', $value) as $role) |
|
120 | + foreach (explode(',', $value) as $role) |
|
121 | 121 | { |
122 | - if(($role = trim($role)) !== '') |
|
122 | + if (($role = trim($role)) !== '') |
|
123 | 123 | $roles[] = $role; |
124 | 124 | } |
125 | 125 | $this->setState('Roles', $roles, []); |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function isInRole($role) |
134 | 134 | { |
135 | - foreach($this->getRoles() as $r) |
|
136 | - if(strcasecmp($role, $r) === 0) |
|
135 | + foreach ($this->getRoles() as $r) |
|
136 | + if (strcasecmp($role, $r) === 0) |
|
137 | 137 | return true; |
138 | 138 | return false; |
139 | 139 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function loadFromString($data) |
154 | 154 | { |
155 | - if(!empty($data)) |
|
155 | + if (!empty($data)) |
|
156 | 156 | $this->_state = unserialize($data); |
157 | - if(!is_array($this->_state)) |
|
157 | + if (!is_array($this->_state)) |
|
158 | 158 | $this->_state = []; |
159 | 159 | return $this; |
160 | 160 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | protected function getState($key, $defaultValue = null) |
176 | 176 | { |
177 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
177 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function setState($key, $value, $defaultValue = null) |
195 | 195 | { |
196 | - if($value === $defaultValue) |
|
196 | + if ($value === $defaultValue) |
|
197 | 197 | unset($this->_state[$key]); |
198 | 198 | else |
199 | 199 | $this->_state[$key] = $value; |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function init($config) |
63 | 63 | { |
64 | - if($this->_userClass === '') |
|
64 | + if ($this->_userClass === '') |
|
65 | 65 | throw new TConfigurationException('dbusermanager_userclass_required'); |
66 | 66 | $this->_userFactory = Prado::createComponent($this->_userClass, $this); |
67 | - if(!($this->_userFactory instanceof TDbUser)) |
|
67 | + if (!($this->_userFactory instanceof TDbUser)) |
|
68 | 68 | throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass); |
69 | 69 | } |
70 | 70 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function getUser($username = null) |
120 | 120 | { |
121 | - if($username === null) |
|
121 | + if ($username === null) |
|
122 | 122 | { |
123 | 123 | $user = Prado::createComponent($this->_userClass, $this); |
124 | 124 | $user->setIsGuest(true); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function getDbConnection() |
154 | 154 | { |
155 | - if($this->_conn === null) |
|
155 | + if ($this->_conn === null) |
|
156 | 156 | { |
157 | 157 | $this->_conn = $this->createDbConnection($this->_connID); |
158 | 158 | $this->_conn->setActive(true); |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | */ |
169 | 169 | protected function createDbConnection($connectionID) |
170 | 170 | { |
171 | - if($connectionID !== '') |
|
171 | + if ($connectionID !== '') |
|
172 | 172 | { |
173 | 173 | $conn = $this->getApplication()->getModule($connectionID); |
174 | - if($conn instanceof TDataSourceConfig) |
|
174 | + if ($conn instanceof TDataSourceConfig) |
|
175 | 175 | return $conn->getDbConnection(); |
176 | 176 | else |
177 | 177 | throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | public function saveUserToCookie($cookie) |
200 | 200 | { |
201 | 201 | $user = $this->getApplication()->getUser(); |
202 | - if($user instanceof TDbUser) |
|
202 | + if ($user instanceof TDbUser) |
|
203 | 203 | $user->saveUserToCookie($cookie); |
204 | 204 | } |
205 | 205 | } |
206 | 206 | \ No newline at end of file |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getValidationKey() |
86 | 86 | { |
87 | - if(null === $this->_validationKey) { |
|
88 | - if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
87 | + if (null === $this->_validationKey) { |
|
88 | + if (null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) { |
|
89 | 89 | $this->_validationKey = $this->generateRandomKey(); |
90 | 90 | $this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true); |
91 | 91 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function setValidationKey($value) |
101 | 101 | { |
102 | - if('' === $value) |
|
102 | + if ('' === $value) |
|
103 | 103 | throw new TInvalidDataValueException('securitymanager_validationkey_invalid'); |
104 | 104 | |
105 | 105 | $this->_validationKey = $value; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getEncryptionKey() |
113 | 113 | { |
114 | - if(null === $this->_encryptionKey) { |
|
115 | - if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
114 | + if (null === $this->_encryptionKey) { |
|
115 | + if (null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) { |
|
116 | 116 | $this->_encryptionKey = $this->generateRandomKey(); |
117 | 117 | $this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true); |
118 | 118 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function setEncryptionKey($value) |
128 | 128 | { |
129 | - if('' === $value) |
|
129 | + if ('' === $value) |
|
130 | 130 | throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid'); |
131 | 131 | |
132 | 132 | $this->_encryptionKey = $value; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function setHashAlgorithm($value) |
149 | 149 | { |
150 | 150 | $this->_hashAlgorithm = TPropertyValue::ensureString($value); |
151 | - if(!in_array($this->_hashAlgorithm, hash_algos())) |
|
151 | + if (!in_array($this->_hashAlgorithm, hash_algos())) |
|
152 | 152 | throw new TInvalidDataValueException('securitymanager_hash_algorithm_invalid'); |
153 | 153 | } |
154 | 154 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function setCryptAlgorithm($value) |
168 | 168 | { |
169 | 169 | $this->_cryptAlgorithm = TPropertyValue::ensureString($value); |
170 | - if(!in_array($this->_hashAlgorithm, openssl_get_cipher_methods())) |
|
170 | + if (!in_array($this->_hashAlgorithm, openssl_get_cipher_methods())) |
|
171 | 171 | throw new TInvalidDataValueException('securitymanager_crypt_algorithm_invalid'); |
172 | 172 | } |
173 | 173 | |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function encrypt($data) |
181 | 181 | { |
182 | - if(extension_loaded('openssl')) |
|
182 | + if (extension_loaded('openssl')) |
|
183 | 183 | { |
184 | 184 | $key = md5($this->getEncryptionKey()); |
185 | 185 | $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->_cryptAlgorithm)); |
186 | - return $iv . openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv); |
|
186 | + return $iv.openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv); |
|
187 | 187 | } |
188 | 188 | else |
189 | 189 | throw new TNotSupportedException('securitymanager_openssl_required'); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function decrypt($data) |
199 | 199 | { |
200 | - if(extension_loaded('openssl')) |
|
200 | + if (extension_loaded('openssl')) |
|
201 | 201 | { |
202 | 202 | $key = md5($this->getEncryptionKey()); |
203 | 203 | $iv = $this->substr($data, 0, openssl_cipher_iv_length($this->_cryptAlgorithm)); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function hashData($data) |
216 | 216 | { |
217 | 217 | $hmac = $this->computeHMAC($data); |
218 | - return $hmac . $data; |
|
218 | + return $hmac.$data; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | $len = $this->strlen($this->computeHMAC('test')); |
231 | 231 | |
232 | - if($this->strlen($data) < $len) |
|
232 | + if ($this->strlen($data) < $len) |
|
233 | 233 | return false; |
234 | 234 | |
235 | 235 | $hmac = $this->substr($data, 0, $len); |
@@ -58,7 +58,7 @@ |
||
58 | 58 | { |
59 | 59 | $id = "cb_$tableName"; |
60 | 60 | $obj = $this->tableNames->findControl($id); |
61 | - if($obj !== null && $obj->Checked) |
|
61 | + if ($obj !== null && $obj->Checked) |
|
62 | 62 | { |
63 | 63 | $scf_generator->generateCRUD($tableName); |
64 | 64 | } |
@@ -98,10 +98,10 @@ |
||
98 | 98 | */ |
99 | 99 | public function publishAsset($assetPath, $className = null) |
100 | 100 | { |
101 | - if($className === null) |
|
101 | + if ($className === null) |
|
102 | 102 | $className = get_class($this); |
103 | 103 | $class = new \ReflectionClass($className); |
104 | - $fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath; |
|
104 | + $fullPath = dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath; |
|
105 | 105 | return $this->publishFilePath($fullPath); |
106 | 106 | } |
107 | 107 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function loadFromFile($fname) |
68 | 68 | { |
69 | - if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
69 | + if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
70 | 70 | { |
71 | 71 | $fcontent = include $fname; |
72 | 72 | $this->loadFromPhp($fcontent, dirname($fname)); |
@@ -95,28 +95,28 @@ discard block |
||
95 | 95 | public function loadFromPhp($config, $configPath) |
96 | 96 | { |
97 | 97 | // application properties |
98 | - if(isset($config['application'])) |
|
98 | + if (isset($config['application'])) |
|
99 | 99 | { |
100 | - foreach($config['application'] as $name => $value) |
|
100 | + foreach ($config['application'] as $name => $value) |
|
101 | 101 | { |
102 | 102 | $this->_properties[$name] = $value; |
103 | 103 | } |
104 | 104 | $this->_empty = false; |
105 | 105 | } |
106 | 106 | |
107 | - if(isset($config['paths']) && is_array($config['paths'])) |
|
107 | + if (isset($config['paths']) && is_array($config['paths'])) |
|
108 | 108 | $this->loadPathsPhp($config['paths'], $configPath); |
109 | 109 | |
110 | - if(isset($config['modules']) && is_array($config['modules'])) |
|
110 | + if (isset($config['modules']) && is_array($config['modules'])) |
|
111 | 111 | $this->loadModulesPhp($config['modules'], $configPath); |
112 | 112 | |
113 | - if(isset($config['services']) && is_array($config['services'])) |
|
113 | + if (isset($config['services']) && is_array($config['services'])) |
|
114 | 114 | $this->loadServicesPhp($config['services'], $configPath); |
115 | 115 | |
116 | - if(isset($config['parameters']) && is_array($config['parameters'])) |
|
116 | + if (isset($config['parameters']) && is_array($config['parameters'])) |
|
117 | 117 | $this->loadParametersPhp($config['parameters'], $configPath); |
118 | 118 | |
119 | - if(isset($config['includes']) && is_array($config['includes'])) |
|
119 | + if (isset($config['includes']) && is_array($config['includes'])) |
|
120 | 120 | $this->loadExternalXml($config['includes'], $configPath); |
121 | 121 | } |
122 | 122 | |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | public function loadFromXml($dom, $configPath) |
129 | 129 | { |
130 | 130 | // application properties |
131 | - foreach($dom->getAttributes() as $name => $value) |
|
131 | + foreach ($dom->getAttributes() as $name => $value) |
|
132 | 132 | { |
133 | 133 | $this->_properties[$name] = $value; |
134 | 134 | $this->_empty = false; |
135 | 135 | } |
136 | 136 | |
137 | - foreach($dom->getElements() as $element) |
|
137 | + foreach ($dom->getElements() as $element) |
|
138 | 138 | { |
139 | - switch($element->getTagName()) |
|
139 | + switch ($element->getTagName()) |
|
140 | 140 | { |
141 | 141 | case 'paths': |
142 | 142 | $this->loadPathsXml($element, $configPath); |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function loadPathsPhp($pathsNode, $configPath) |
169 | 169 | { |
170 | - if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) |
|
170 | + if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) |
|
171 | 171 | { |
172 | - foreach($pathsNode['aliases'] as $id => $path) |
|
172 | + foreach ($pathsNode['aliases'] as $id => $path) |
|
173 | 173 | { |
174 | 174 | $path = str_replace('\\', '/', $path); |
175 | - if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
175 | + if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
176 | 176 | $p = realpath($path); |
177 | 177 | else |
178 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
179 | - if($p === false || !is_dir($p)) |
|
178 | + $p = realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
179 | + if ($p === false || !is_dir($p)) |
|
180 | 180 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
181 | - if(isset($this->_aliases[$id])) |
|
181 | + if (isset($this->_aliases[$id])) |
|
182 | 182 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
183 | 183 | $this->_aliases[$id] = $p; |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - if(isset($pathsNode['using']) && is_array($pathsNode['using'])) |
|
187 | + if (isset($pathsNode['using']) && is_array($pathsNode['using'])) |
|
188 | 188 | { |
189 | - foreach($pathsNode['using'] as $namespace) |
|
189 | + foreach ($pathsNode['using'] as $namespace) |
|
190 | 190 | { |
191 | 191 | $this->_usings[] = $namespace; |
192 | 192 | } |
@@ -200,22 +200,22 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function loadPathsXml($pathsNode, $configPath) |
202 | 202 | { |
203 | - foreach($pathsNode->getElements() as $element) |
|
203 | + foreach ($pathsNode->getElements() as $element) |
|
204 | 204 | { |
205 | - switch($element->getTagName()) |
|
205 | + switch ($element->getTagName()) |
|
206 | 206 | { |
207 | 207 | case 'alias': |
208 | 208 | { |
209 | - if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
|
209 | + if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
|
210 | 210 | { |
211 | 211 | $path = str_replace('\\', '/', $path); |
212 | - if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
212 | + if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
213 | 213 | $p = realpath($path); |
214 | 214 | else |
215 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
216 | - if($p === false || !is_dir($p)) |
|
215 | + $p = realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
216 | + if ($p === false || !is_dir($p)) |
|
217 | 217 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
218 | - if(isset($this->_aliases[$id])) |
|
218 | + if (isset($this->_aliases[$id])) |
|
219 | 219 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
220 | 220 | $this->_aliases[$id] = $p; |
221 | 221 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | case 'using': |
228 | 228 | { |
229 | - if(($namespace = $element->getAttribute('namespace')) !== null) |
|
229 | + if (($namespace = $element->getAttribute('namespace')) !== null) |
|
230 | 230 | $this->_usings[] = $namespace; |
231 | 231 | else |
232 | 232 | throw new TConfigurationException('appconfig_using_invalid'); |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function loadModulesPhp($modulesNode, $configPath) |
248 | 248 | { |
249 | - foreach($modulesNode as $id => $module) |
|
249 | + foreach ($modulesNode as $id => $module) |
|
250 | 250 | { |
251 | - if(!isset($module['class'])) |
|
251 | + if (!isset($module['class'])) |
|
252 | 252 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
253 | 253 | $type = $module['class']; |
254 | 254 | unset($module['class']); |
255 | 255 | $properties = []; |
256 | - if(isset($module['properties'])) |
|
256 | + if (isset($module['properties'])) |
|
257 | 257 | { |
258 | 258 | $properties = $module['properties']; |
259 | 259 | unset($module['properties']); |
260 | 260 | } |
261 | 261 | $properties['id'] = $id; |
262 | - $this->_modules[$id] = [$type,$properties,$module]; |
|
262 | + $this->_modules[$id] = [$type, $properties, $module]; |
|
263 | 263 | $this->_empty = false; |
264 | 264 | } |
265 | 265 | } |
@@ -271,20 +271,20 @@ discard block |
||
271 | 271 | */ |
272 | 272 | protected function loadModulesXml($modulesNode, $configPath) |
273 | 273 | { |
274 | - foreach($modulesNode->getElements() as $element) |
|
274 | + foreach ($modulesNode->getElements() as $element) |
|
275 | 275 | { |
276 | - if($element->getTagName() === 'module') |
|
276 | + if ($element->getTagName() === 'module') |
|
277 | 277 | { |
278 | 278 | $properties = $element->getAttributes(); |
279 | 279 | $id = $properties->itemAt('id'); |
280 | 280 | $type = $properties->remove('class'); |
281 | - if($type === null) |
|
281 | + if ($type === null) |
|
282 | 282 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
283 | 283 | $element->setParent(null); |
284 | - if($id === null) |
|
285 | - $this->_modules[] = [$type,$properties->toArray(),$element]; |
|
284 | + if ($id === null) |
|
285 | + $this->_modules[] = [$type, $properties->toArray(), $element]; |
|
286 | 286 | else |
287 | - $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
|
287 | + $this->_modules[$id] = [$type, $properties->toArray(), $element]; |
|
288 | 288 | $this->_empty = false; |
289 | 289 | } |
290 | 290 | else |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function loadServicesPhp($servicesNode, $configPath) |
301 | 301 | { |
302 | - foreach($servicesNode as $id => $service) |
|
302 | + foreach ($servicesNode as $id => $service) |
|
303 | 303 | { |
304 | - if(!isset($service['class'])) |
|
304 | + if (!isset($service['class'])) |
|
305 | 305 | throw new TConfigurationException('appconfig_servicetype_required'); |
306 | 306 | $type = $service['class']; |
307 | 307 | $properties = isset($service['properties']) ? $service['properties'] : []; |
308 | 308 | unset($service['properties']); |
309 | 309 | $properties['id'] = $id; |
310 | - $this->_services[$id] = [$type,$properties,$service]; |
|
310 | + $this->_services[$id] = [$type, $properties, $service]; |
|
311 | 311 | $this->_empty = false; |
312 | 312 | } |
313 | 313 | } |
@@ -319,17 +319,17 @@ discard block |
||
319 | 319 | */ |
320 | 320 | protected function loadServicesXml($servicesNode, $configPath) |
321 | 321 | { |
322 | - foreach($servicesNode->getElements() as $element) |
|
322 | + foreach ($servicesNode->getElements() as $element) |
|
323 | 323 | { |
324 | - if($element->getTagName() === 'service') |
|
324 | + if ($element->getTagName() === 'service') |
|
325 | 325 | { |
326 | 326 | $properties = $element->getAttributes(); |
327 | - if(($id = $properties->itemAt('id')) === null) |
|
327 | + if (($id = $properties->itemAt('id')) === null) |
|
328 | 328 | throw new TConfigurationException('appconfig_serviceid_required'); |
329 | - if(($type = $properties->remove('class')) === null) |
|
329 | + if (($type = $properties->remove('class')) === null) |
|
330 | 330 | throw new TConfigurationException('appconfig_servicetype_required', $id); |
331 | 331 | $element->setParent(null); |
332 | - $this->_services[$id] = [$type,$properties->toArray(),$element]; |
|
332 | + $this->_services[$id] = [$type, $properties->toArray(), $element]; |
|
333 | 333 | $this->_empty = false; |
334 | 334 | } |
335 | 335 | else |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | */ |
345 | 345 | protected function loadParametersPhp($parametersNode, $configPath) |
346 | 346 | { |
347 | - foreach($parametersNode as $id => $parameter) |
|
347 | + foreach ($parametersNode as $id => $parameter) |
|
348 | 348 | { |
349 | - if(is_array($parameter)) |
|
349 | + if (is_array($parameter)) |
|
350 | 350 | { |
351 | - if(isset($parameter['class'])) |
|
351 | + if (isset($parameter['class'])) |
|
352 | 352 | { |
353 | 353 | $type = $parameter['class']; |
354 | 354 | unset($parameter['class']); |
355 | 355 | $properties = isset($service['properties']) ? $service['properties'] : []; |
356 | 356 | $properties['id'] = $id; |
357 | - $this->_parameters[$id] = [$type,$properties]; |
|
357 | + $this->_parameters[$id] = [$type, $properties]; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | else |
@@ -371,22 +371,22 @@ discard block |
||
371 | 371 | */ |
372 | 372 | protected function loadParametersXml($parametersNode, $configPath) |
373 | 373 | { |
374 | - foreach($parametersNode->getElements() as $element) |
|
374 | + foreach ($parametersNode->getElements() as $element) |
|
375 | 375 | { |
376 | - if($element->getTagName() === 'parameter') |
|
376 | + if ($element->getTagName() === 'parameter') |
|
377 | 377 | { |
378 | 378 | $properties = $element->getAttributes(); |
379 | - if(($id = $properties->remove('id')) === null) |
|
379 | + if (($id = $properties->remove('id')) === null) |
|
380 | 380 | throw new TConfigurationException('appconfig_parameterid_required'); |
381 | - if(($type = $properties->remove('class')) === null) |
|
381 | + if (($type = $properties->remove('class')) === null) |
|
382 | 382 | { |
383 | - if(($value = $properties->remove('value')) === null) |
|
383 | + if (($value = $properties->remove('value')) === null) |
|
384 | 384 | $this->_parameters[$id] = $element; |
385 | 385 | else |
386 | 386 | $this->_parameters[$id] = $value; |
387 | 387 | } |
388 | 388 | else |
389 | - $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
389 | + $this->_parameters[$id] = [$type, $properties->toArray()]; |
|
390 | 390 | $this->_empty = false; |
391 | 391 | } |
392 | 392 | else |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | */ |
402 | 402 | protected function loadExternalPhp($includeNode, $configPath) |
403 | 403 | { |
404 | - foreach($includeNode as $include) |
|
404 | + foreach ($includeNode as $include) |
|
405 | 405 | { |
406 | - $when = isset($include['when'])?true:false; |
|
407 | - if(!isset($include['file'])) |
|
406 | + $when = isset($include['when']) ?true:false; |
|
407 | + if (!isset($include['file'])) |
|
408 | 408 | throw new TConfigurationException('appconfig_includefile_required'); |
409 | 409 | $filePath = $include['file']; |
410 | - if(isset($this->_includes[$filePath])) |
|
411 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
410 | + if (isset($this->_includes[$filePath])) |
|
411 | + $this->_includes[$filePath] = '('.$this->_includes[$filePath].') || ('.$when.')'; |
|
412 | 412 | else |
413 | 413 | $$this->_includes[$filePath] = $when; |
414 | 414 | $this->_empty = false; |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | */ |
423 | 423 | protected function loadExternalXml($includeNode, $configPath) |
424 | 424 | { |
425 | - if(($when = $includeNode->getAttribute('when')) === null) |
|
425 | + if (($when = $includeNode->getAttribute('when')) === null) |
|
426 | 426 | $when = true; |
427 | - if(($filePath = $includeNode->getAttribute('file')) === null) |
|
427 | + if (($filePath = $includeNode->getAttribute('file')) === null) |
|
428 | 428 | throw new TConfigurationException('appconfig_includefile_required'); |
429 | - if(isset($this->_includes[$filePath])) |
|
430 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
429 | + if (isset($this->_includes[$filePath])) |
|
430 | + $this->_includes[$filePath] = '('.$this->_includes[$filePath].') || ('.$when.')'; |
|
431 | 431 | else |
432 | 432 | $this->_includes[$filePath] = $when; |
433 | 433 | $this->_empty = false; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function current() |
71 | 71 | { |
72 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
72 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $this->_key = next($this->_keys); |
84 | 84 | } |
85 | - while(!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
85 | + while (!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |