@@ -28,6 +28,7 @@ discard block |
||
| 28 | 28 | public function getName(); |
| 29 | 29 | /** |
| 30 | 30 | * @param string username |
| 31 | + * @return void |
|
| 31 | 32 | */ |
| 32 | 33 | public function setName($value); |
| 33 | 34 | /** |
@@ -36,6 +37,7 @@ discard block |
||
| 36 | 37 | public function getIsGuest(); |
| 37 | 38 | /** |
| 38 | 39 | * @param boolean if the user is a guest |
| 40 | + * @return void |
|
| 39 | 41 | */ |
| 40 | 42 | public function setIsGuest($value); |
| 41 | 43 | /** |
@@ -37,6 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Returns a user instance according to auth data stored in a cookie. |
| 39 | 39 | * @param THttpCookie the cookie storing user authentication information |
| 40 | + * @param \Prado\Web\THttpCookie $cookie |
|
| 40 | 41 | * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data. |
| 41 | 42 | * @since 3.1.1 |
| 42 | 43 | */ |
@@ -44,7 +45,9 @@ discard block |
||
| 44 | 45 | /** |
| 45 | 46 | * Saves user auth data into a cookie. |
| 46 | 47 | * @param THttpCookie the cookie to receive the user auth data. |
| 48 | + * @param \Prado\Web\THttpCookie $cookie |
|
| 47 | 49 | * @since 3.1.1 |
| 50 | + * @return void |
|
| 48 | 51 | */ |
| 49 | 52 | public function saveUserToCookie($cookie); |
| 50 | 53 | /** |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @param string user name, null if it is a guest. |
| 34 | 34 | * @return TUser the user instance, null if the specified username is not in the user database. |
| 35 | 35 | */ |
| 36 | - public function getUser($username = null); |
|
| 36 | + public function getUser($username=null); |
|
| 37 | 37 | /** |
| 38 | 38 | * Returns a user instance according to auth data stored in a cookie. |
| 39 | 39 | * @param THttpCookie the cookie storing user authentication information |
@@ -228,6 +228,7 @@ discard block |
||
| 228 | 228 | /** |
| 229 | 229 | * Sets the URL that the browser should be redirected to when login succeeds. |
| 230 | 230 | * @param string the URL to be redirected to. |
| 231 | + * @param string $value |
|
| 231 | 232 | */ |
| 232 | 233 | public function setReturnUrl($value) |
| 233 | 234 | { |
@@ -376,6 +377,7 @@ discard block |
||
| 376 | 377 | /** |
| 377 | 378 | * Updates the user data stored in session. |
| 378 | 379 | * @param IUser user object |
| 380 | + * @param TUser $user |
|
| 379 | 381 | * @throws new TConfigurationException if session module is not loaded. |
| 380 | 382 | */ |
| 381 | 383 | public function updateSessionUser($user) |
@@ -430,8 +430,7 @@ |
||
| 430 | 430 | $this->getResponse()->getCookies()->add($cookie); |
| 431 | 431 | } |
| 432 | 432 | return true; |
| 433 | - } |
|
| 434 | - else |
|
| 433 | + } else |
|
| 435 | 434 | return false; |
| 436 | 435 | } |
| 437 | 436 | |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * GET variable name for return url |
| 49 | 49 | */ |
| 50 | - const RETURN_URL_VAR = 'ReturnUrl'; |
|
| 50 | + const RETURN_URL_VAR='ReturnUrl'; |
|
| 51 | 51 | /** |
| 52 | 52 | * @var boolean if the module has been initialized |
| 53 | 53 | */ |
| 54 | - private $_initialized = false; |
|
| 54 | + private $_initialized=false; |
|
| 55 | 55 | /** |
| 56 | 56 | * @var IUserManager user manager instance |
| 57 | 57 | */ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * @var boolean whether authorization should be skipped |
| 65 | 65 | */ |
| 66 | - private $_skipAuthorization = false; |
|
| 66 | + private $_skipAuthorization=false; |
|
| 67 | 67 | /** |
| 68 | 68 | * @var string the session var name for storing return URL |
| 69 | 69 | */ |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * @var boolean whether to allow auto login (using cookie) |
| 73 | 73 | */ |
| 74 | - private $_allowAutoLogin = false; |
|
| 74 | + private $_allowAutoLogin=false; |
|
| 75 | 75 | /** |
| 76 | 76 | * @var string variable name used to store user session or cookie |
| 77 | 77 | */ |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * @var integer authentication expiration time in seconds. Defaults to zero (no expiration) |
| 81 | 81 | */ |
| 82 | - private $_authExpire = 0; |
|
| 82 | + private $_authExpire=0; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Initializes this module. |
@@ -89,23 +89,23 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function init($config) |
| 91 | 91 | { |
| 92 | - if($this->_userManager === null) |
|
| 92 | + if($this->_userManager===null) |
|
| 93 | 93 | throw new TConfigurationException('authmanager_usermanager_required'); |
| 94 | - if($this->_returnUrlVarName === null) |
|
| 95 | - $this->_returnUrlVarName = $this->getApplication()->getID() . ':' . self::RETURN_URL_VAR; |
|
| 96 | - $application = $this->getApplication(); |
|
| 94 | + if($this->_returnUrlVarName===null) |
|
| 95 | + $this->_returnUrlVarName=$this->getApplication()->getID().':'.self::RETURN_URL_VAR; |
|
| 96 | + $application=$this->getApplication(); |
|
| 97 | 97 | if(is_string($this->_userManager)) |
| 98 | 98 | { |
| 99 | - if(($users = $application->getModule($this->_userManager)) === null) |
|
| 99 | + if(($users=$application->getModule($this->_userManager))===null) |
|
| 100 | 100 | throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager); |
| 101 | 101 | if(!($users instanceof IUserManager)) |
| 102 | 102 | throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
| 103 | - $this->_userManager = $users; |
|
| 103 | + $this->_userManager=$users; |
|
| 104 | 104 | } |
| 105 | - $application->attachEventHandler('OnAuthentication', [$this,'doAuthentication']); |
|
| 106 | - $application->attachEventHandler('OnEndRequest', [$this,'leave']); |
|
| 107 | - $application->attachEventHandler('OnAuthorization', [$this,'doAuthorization']); |
|
| 108 | - $this->_initialized = true; |
|
| 105 | + $application->attachEventHandler('OnAuthentication', [$this, 'doAuthentication']); |
|
| 106 | + $application->attachEventHandler('OnEndRequest', [$this, 'leave']); |
|
| 107 | + $application->attachEventHandler('OnAuthorization', [$this, 'doAuthorization']); |
|
| 108 | + $this->_initialized=true; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | throw new TInvalidOperationException('authmanager_usermanager_unchangeable'); |
| 127 | 127 | if(!is_string($provider) && !($provider instanceof IUserManager)) |
| 128 | 128 | throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
| 129 | - $this->_userManager = $provider; |
|
| 129 | + $this->_userManager=$provider; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function setLoginPage($pagePath) |
| 147 | 147 | { |
| 148 | - $this->_loginPage = $pagePath; |
|
| 148 | + $this->_loginPage=$pagePath; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $this->onAuthenticate($param); |
| 161 | 161 | |
| 162 | - $service = $this->getService(); |
|
| 163 | - if(($service instanceof TPageService) && $service->getRequestedPagePath() === $this->getLoginPage()) |
|
| 164 | - $this->_skipAuthorization = true; |
|
| 162 | + $service=$this->getService(); |
|
| 163 | + if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage()) |
|
| 164 | + $this->_skipAuthorization=true; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function leave($sender, $param) |
| 190 | 190 | { |
| 191 | - $application = $this->getApplication(); |
|
| 192 | - if($application->getResponse()->getStatusCode() === 401) |
|
| 191 | + $application=$this->getApplication(); |
|
| 192 | + if($application->getResponse()->getStatusCode()===401) |
|
| 193 | 193 | { |
| 194 | - $service = $application->getService(); |
|
| 194 | + $service=$application->getService(); |
|
| 195 | 195 | if($service instanceof TPageService) |
| 196 | 196 | { |
| 197 | - $returnUrl = $application->getRequest()->getRequestUri(); |
|
| 197 | + $returnUrl=$application->getRequest()->getRequestUri(); |
|
| 198 | 198 | $this->setReturnUrl($returnUrl); |
| 199 | - $url = $service->constructUrl($this->getLoginPage()); |
|
| 199 | + $url=$service->constructUrl($this->getLoginPage()); |
|
| 200 | 200 | $application->getResponse()->redirect($url); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function setReturnUrlVarName($value) |
| 217 | 217 | { |
| 218 | - $this->_returnUrlVarName = $value; |
|
| 218 | + $this->_returnUrlVarName=$value; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function setAllowAutoLogin($value) |
| 252 | 252 | { |
| 253 | - $this->_allowAutoLogin = TPropertyValue::ensureBoolean($value); |
|
| 253 | + $this->_allowAutoLogin=TPropertyValue::ensureBoolean($value); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function setAuthExpire($value) |
| 270 | 270 | { |
| 271 | - $this->_authExpire = TPropertyValue::ensureInteger($value); |
|
| 271 | + $this->_authExpire=TPropertyValue::ensureInteger($value); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -281,31 +281,31 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function onAuthenticate($param) |
| 283 | 283 | { |
| 284 | - $application = $this->getApplication(); |
|
| 284 | + $application=$this->getApplication(); |
|
| 285 | 285 | |
| 286 | 286 | // restoring user info from session |
| 287 | - if(($session = $application->getSession()) === null) |
|
| 287 | + if(($session=$application->getSession())===null) |
|
| 288 | 288 | throw new TConfigurationException('authmanager_session_required'); |
| 289 | 289 | $session->open(); |
| 290 | - $sessionInfo = $session->itemAt($this->getUserKey()); |
|
| 291 | - $user = $this->_userManager->getUser(null)->loadFromString($sessionInfo); |
|
| 290 | + $sessionInfo=$session->itemAt($this->getUserKey()); |
|
| 291 | + $user=$this->_userManager->getUser(null)->loadFromString($sessionInfo); |
|
| 292 | 292 | |
| 293 | 293 | // check for authentication expiration |
| 294 | - $isAuthExpired = $this->_authExpire > 0 && !$user->getIsGuest() && |
|
| 295 | - ($expiretime = $session->itemAt('AuthExpireTime')) && $expiretime < time(); |
|
| 294 | + $isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() && |
|
| 295 | + ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time(); |
|
| 296 | 296 | |
| 297 | 297 | // try authenticating through cookie if possible |
| 298 | 298 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) |
| 299 | 299 | { |
| 300 | - $cookie = $this->getRequest()->getCookies()->itemAt($this->getUserKey()); |
|
| 300 | + $cookie=$this->getRequest()->getCookies()->itemAt($this->getUserKey()); |
|
| 301 | 301 | if($cookie instanceof THttpCookie) |
| 302 | 302 | { |
| 303 | - if(($user2 = $this->_userManager->getUserFromCookie($cookie)) !== null) |
|
| 303 | + if(($user2=$this->_userManager->getUserFromCookie($cookie))!==null) |
|
| 304 | 304 | { |
| 305 | - $user = $user2; |
|
| 305 | + $user=$user2; |
|
| 306 | 306 | $this->updateSessionUser($user); |
| 307 | 307 | // user is restored from cookie, auth may not expire |
| 308 | - $isAuthExpired = false; |
|
| 308 | + $isAuthExpired=false; |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | public function onAuthorize($param) |
| 346 | 346 | { |
| 347 | - $application = $this->getApplication(); |
|
| 347 | + $application=$this->getApplication(); |
|
| 348 | 348 | if($this->hasEventHandler('OnAuthorize')) |
| 349 | 349 | $this->raiseEvent('OnAuthorize', $this, $application); |
| 350 | 350 | if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress())) |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | public function getUserKey() |
| 362 | 362 | { |
| 363 | - if($this->_userKey === null) |
|
| 364 | - $this->_userKey = $this->generateUserKey(); |
|
| 363 | + if($this->_userKey===null) |
|
| 364 | + $this->_userKey=$this->generateUserKey(); |
|
| 365 | 365 | return $this->_userKey; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | protected function generateUserKey() |
| 373 | 373 | { |
| 374 | - return md5($this->getApplication()->getUniqueID() . 'prado:user'); |
|
| 374 | + return md5($this->getApplication()->getUniqueID().'prado:user'); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | { |
| 384 | 384 | if(!$user->getIsGuest()) |
| 385 | 385 | { |
| 386 | - if(($session = $this->getSession()) === null) |
|
| 386 | + if(($session=$this->getSession())===null) |
|
| 387 | 387 | throw new TConfigurationException('authmanager_session_required'); |
| 388 | 388 | else |
| 389 | 389 | $session->add($this->getUserKey(), $user->saveToString()); |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function switchUser($username) |
| 400 | 400 | { |
| 401 | - if(($user = $this->_userManager->getUser($username)) === null) |
|
| 401 | + if(($user=$this->_userManager->getUser($username))===null) |
|
| 402 | 402 | return false; |
| 403 | 403 | $this->updateSessionUser($user); |
| 404 | 404 | $this->getApplication()->setUser($user); |
@@ -414,18 +414,18 @@ discard block |
||
| 414 | 414 | * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1. |
| 415 | 415 | * @return boolean if login is successful |
| 416 | 416 | */ |
| 417 | - public function login($username, $password, $expire = 0) |
|
| 417 | + public function login($username, $password, $expire=0) |
|
| 418 | 418 | { |
| 419 | 419 | if($this->_userManager->validateUser($username, $password)) |
| 420 | 420 | { |
| 421 | - if(($user = $this->_userManager->getUser($username)) === null) |
|
| 421 | + if(($user=$this->_userManager->getUser($username))===null) |
|
| 422 | 422 | return false; |
| 423 | 423 | $this->updateSessionUser($user); |
| 424 | 424 | $this->getApplication()->setUser($user); |
| 425 | 425 | |
| 426 | 426 | if($expire > 0) |
| 427 | 427 | { |
| 428 | - $cookie = new THttpCookie($this->getUserKey(), ''); |
|
| 428 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
| 429 | 429 | $cookie->setExpire(time() + $expire); |
| 430 | 430 | $this->_userManager->saveUserToCookie($cookie); |
| 431 | 431 | $this->getResponse()->getCookies()->add($cookie); |
@@ -443,13 +443,13 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public function logout() |
| 445 | 445 | { |
| 446 | - if(($session = $this->getSession()) === null) |
|
| 446 | + if(($session=$this->getSession())===null) |
|
| 447 | 447 | throw new TConfigurationException('authmanager_session_required'); |
| 448 | 448 | $this->getApplication()->getUser()->setIsGuest(true); |
| 449 | 449 | $session->destroy(); |
| 450 | 450 | if($this->getAllowAutoLogin()) |
| 451 | 451 | { |
| 452 | - $cookie = new THttpCookie($this->getUserKey(), ''); |
|
| 452 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
| 453 | 453 | $this->getResponse()->getCookies()->add($cookie); |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -162,7 +162,8 @@ |
||
| 162 | 162 | /** |
| 163 | 163 | * Creates the DB connection. |
| 164 | 164 | * @param string the module ID for TDataSourceConfig |
| 165 | - * @return TDbConnection the created DB connection |
|
| 165 | + * @param string $connectionID |
|
| 166 | + * @return \Prado\Data\TDbConnection the created DB connection |
|
| 166 | 167 | * @throws TConfigurationException if module ID is invalid or empty |
| 167 | 168 | */ |
| 168 | 169 | protected function createDbConnection($connectionID) |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | class TDbUserManager extends \Prado\TModule implements IUserManager |
| 50 | 50 | { |
| 51 | - private $_connID = ''; |
|
| 51 | + private $_connID=''; |
|
| 52 | 52 | private $_conn; |
| 53 | - private $_guestName = 'Guest'; |
|
| 54 | - private $_userClass = ''; |
|
| 53 | + private $_guestName='Guest'; |
|
| 54 | + private $_userClass=''; |
|
| 55 | 55 | private $_userFactory; |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -61,9 +61,9 @@ 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 | - $this->_userFactory = Prado::createComponent($this->_userClass, $this); |
|
| 66 | + $this->_userFactory=Prado::createComponent($this->_userClass, $this); |
|
| 67 | 67 | if(!($this->_userFactory instanceof TDbUser)) |
| 68 | 68 | throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass); |
| 69 | 69 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function setUserClass($value) |
| 83 | 83 | { |
| 84 | - $this->_userClass = $value; |
|
| 84 | + $this->_userClass=$value; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function setGuestName($value) |
| 99 | 99 | { |
| 100 | - $this->_guestName = $value; |
|
| 100 | + $this->_guestName=$value; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | * @param string user name, null if it is a guest. |
| 117 | 117 | * @return TUser the user instance, null if the specified username is not in the user database. |
| 118 | 118 | */ |
| 119 | - public function getUser($username = null) |
|
| 119 | + public function getUser($username=null) |
|
| 120 | 120 | { |
| 121 | - if($username === null) |
|
| 121 | + if($username===null) |
|
| 122 | 122 | { |
| 123 | - $user = Prado::createComponent($this->_userClass, $this); |
|
| 123 | + $user=Prado::createComponent($this->_userClass, $this); |
|
| 124 | 124 | $user->setIsGuest(true); |
| 125 | 125 | return $user; |
| 126 | 126 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function setConnectionID($value) |
| 146 | 146 | { |
| 147 | - $this->_connID = $value; |
|
| 147 | + $this->_connID=$value; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function getDbConnection() |
| 154 | 154 | { |
| 155 | - if($this->_conn === null) |
|
| 155 | + if($this->_conn===null) |
|
| 156 | 156 | { |
| 157 | - $this->_conn = $this->createDbConnection($this->_connID); |
|
| 157 | + $this->_conn=$this->createDbConnection($this->_connID); |
|
| 158 | 158 | $this->_conn->setActive(true); |
| 159 | 159 | } |
| 160 | 160 | return $this->_conn; |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | protected function createDbConnection($connectionID) |
| 170 | 170 | { |
| 171 | - if($connectionID !== '') |
|
| 171 | + if($connectionID!=='') |
|
| 172 | 172 | { |
| 173 | - $conn = $this->getApplication()->getModule($connectionID); |
|
| 173 | + $conn=$this->getApplication()->getModule($connectionID); |
|
| 174 | 174 | if($conn instanceof TDataSourceConfig) |
| 175 | 175 | return $conn->getDbConnection(); |
| 176 | 176 | else |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function saveUserToCookie($cookie) |
| 200 | 200 | { |
| 201 | - $user = $this->getApplication()->getUser(); |
|
| 201 | + $user=$this->getApplication()->getUser(); |
|
| 202 | 202 | if($user instanceof TDbUser) |
| 203 | 203 | $user->saveUserToCookie($cookie); |
| 204 | 204 | } |
@@ -123,8 +123,7 @@ discard block |
||
| 123 | 123 | $user = Prado::createComponent($this->_userClass, $this); |
| 124 | 124 | $user->setIsGuest(true); |
| 125 | 125 | return $user; |
| 126 | - } |
|
| 127 | - else |
|
| 126 | + } else |
|
| 128 | 127 | return $this->_userFactory->createUser($username); |
| 129 | 128 | } |
| 130 | 129 | |
@@ -175,8 +174,7 @@ discard block |
||
| 175 | 174 | return $conn->getDbConnection(); |
| 176 | 175 | else |
| 177 | 176 | throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID); |
| 178 | - } |
|
| 179 | - else |
|
| 177 | + } else |
|
| 180 | 178 | throw new TConfigurationException('dbusermanager_connectionid_required'); |
| 181 | 179 | } |
| 182 | 180 | |
@@ -61,6 +61,7 @@ |
||
| 61 | 61 | /** |
| 62 | 62 | * Parses the application configuration file. |
| 63 | 63 | * @param string configuration file name |
| 64 | + * @param string $fname |
|
| 64 | 65 | * @throws TConfigurationException if there is any parsing error |
| 65 | 66 | */ |
| 66 | 67 | public function loadFromFile($fname) |
@@ -29,35 +29,35 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @var array list of application initial property values, indexed by property names |
| 31 | 31 | */ |
| 32 | - private $_properties = []; |
|
| 32 | + private $_properties=[]; |
|
| 33 | 33 | /** |
| 34 | 34 | * @var array list of namespaces to be used |
| 35 | 35 | */ |
| 36 | - private $_usings = []; |
|
| 36 | + private $_usings=[]; |
|
| 37 | 37 | /** |
| 38 | 38 | * @var array list of path aliases, indexed by alias names |
| 39 | 39 | */ |
| 40 | - private $_aliases = []; |
|
| 40 | + private $_aliases=[]; |
|
| 41 | 41 | /** |
| 42 | 42 | * @var array list of module configurations |
| 43 | 43 | */ |
| 44 | - private $_modules = []; |
|
| 44 | + private $_modules=[]; |
|
| 45 | 45 | /** |
| 46 | 46 | * @var array list of service configurations |
| 47 | 47 | */ |
| 48 | - private $_services = []; |
|
| 48 | + private $_services=[]; |
|
| 49 | 49 | /** |
| 50 | 50 | * @var array list of parameters |
| 51 | 51 | */ |
| 52 | - private $_parameters = []; |
|
| 52 | + private $_parameters=[]; |
|
| 53 | 53 | /** |
| 54 | 54 | * @var array list of included configurations |
| 55 | 55 | */ |
| 56 | - private $_includes = []; |
|
| 56 | + private $_includes=[]; |
|
| 57 | 57 | /** |
| 58 | 58 | * @var boolean whether this configuration contains actual stuff |
| 59 | 59 | */ |
| 60 | - private $_empty = true; |
|
| 60 | + private $_empty=true; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Parses the application configuration file. |
@@ -66,14 +66,14 @@ 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 | - $fcontent = include $fname; |
|
| 71 | + $fcontent=include $fname; |
|
| 72 | 72 | $this->loadFromPhp($fcontent, dirname($fname)); |
| 73 | 73 | } |
| 74 | 74 | else |
| 75 | 75 | { |
| 76 | - $dom = new TXmlDocument; |
|
| 76 | + $dom=new TXmlDocument; |
|
| 77 | 77 | $dom->loadFromFile($fname); |
| 78 | 78 | $this->loadFromXml($dom, dirname($fname)); |
| 79 | 79 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | foreach($config['application'] as $name => $value) |
| 101 | 101 | { |
| 102 | - $this->_properties[$name] = $value; |
|
| 102 | + $this->_properties[$name]=$value; |
|
| 103 | 103 | } |
| 104 | - $this->_empty = false; |
|
| 104 | + $this->_empty=false; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if(isset($config['paths']) && is_array($config['paths'])) |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | // application properties |
| 131 | 131 | foreach($dom->getAttributes() as $name => $value) |
| 132 | 132 | { |
| 133 | - $this->_properties[$name] = $value; |
|
| 134 | - $this->_empty = false; |
|
| 133 | + $this->_properties[$name]=$value; |
|
| 134 | + $this->_empty=false; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | foreach($dom->getElements() as $element) |
@@ -171,16 +171,16 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | foreach($pathsNode['aliases'] as $id => $path) |
| 173 | 173 | { |
| 174 | - $path = str_replace('\\', '/', $path); |
|
| 174 | + $path=str_replace('\\', '/', $path); |
|
| 175 | 175 | if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
| 176 | - $p = realpath($path); |
|
| 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 | 181 | if(isset($this->_aliases[$id])) |
| 182 | 182 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
| 183 | - $this->_aliases[$id] = $p; |
|
| 183 | + $this->_aliases[$id]=$p; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | foreach($pathsNode['using'] as $namespace) |
| 190 | 190 | { |
| 191 | - $this->_usings[] = $namespace; |
|
| 191 | + $this->_usings[]=$namespace; |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -206,31 +206,31 @@ discard block |
||
| 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 | - $path = str_replace('\\', '/', $path); |
|
| 211 | + $path=str_replace('\\', '/', $path); |
|
| 212 | 212 | if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
| 213 | - $p = realpath($path); |
|
| 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 | 218 | if(isset($this->_aliases[$id])) |
| 219 | 219 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
| 220 | - $this->_aliases[$id] = $p; |
|
| 220 | + $this->_aliases[$id]=$p; |
|
| 221 | 221 | } |
| 222 | 222 | else |
| 223 | 223 | throw new TConfigurationException('appconfig_alias_invalid'); |
| 224 | - $this->_empty = false; |
|
| 224 | + $this->_empty=false; |
|
| 225 | 225 | break; |
| 226 | 226 | } |
| 227 | 227 | case 'using': |
| 228 | 228 | { |
| 229 | - if(($namespace = $element->getAttribute('namespace')) !== null) |
|
| 230 | - $this->_usings[] = $namespace; |
|
| 229 | + if(($namespace=$element->getAttribute('namespace'))!==null) |
|
| 230 | + $this->_usings[]=$namespace; |
|
| 231 | 231 | else |
| 232 | 232 | throw new TConfigurationException('appconfig_using_invalid'); |
| 233 | - $this->_empty = false; |
|
| 233 | + $this->_empty=false; |
|
| 234 | 234 | break; |
| 235 | 235 | } |
| 236 | 236 | default: |
@@ -250,17 +250,17 @@ discard block |
||
| 250 | 250 | { |
| 251 | 251 | if(!isset($module['class'])) |
| 252 | 252 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
| 253 | - $type = $module['class']; |
|
| 253 | + $type=$module['class']; |
|
| 254 | 254 | unset($module['class']); |
| 255 | - $properties = []; |
|
| 255 | + $properties=[]; |
|
| 256 | 256 | if(isset($module['properties'])) |
| 257 | 257 | { |
| 258 | - $properties = $module['properties']; |
|
| 258 | + $properties=$module['properties']; |
|
| 259 | 259 | unset($module['properties']); |
| 260 | 260 | } |
| 261 | - $properties['id'] = $id; |
|
| 262 | - $this->_modules[$id] = [$type,$properties,$module]; |
|
| 263 | - $this->_empty = false; |
|
| 261 | + $properties['id']=$id; |
|
| 262 | + $this->_modules[$id]=[$type, $properties, $module]; |
|
| 263 | + $this->_empty=false; |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | foreach($modulesNode->getElements() as $element) |
| 275 | 275 | { |
| 276 | - if($element->getTagName() === 'module') |
|
| 276 | + if($element->getTagName()==='module') |
|
| 277 | 277 | { |
| 278 | - $properties = $element->getAttributes(); |
|
| 279 | - $id = $properties->itemAt('id'); |
|
| 280 | - $type = $properties->remove('class'); |
|
| 281 | - if($type === null) |
|
| 278 | + $properties=$element->getAttributes(); |
|
| 279 | + $id=$properties->itemAt('id'); |
|
| 280 | + $type=$properties->remove('class'); |
|
| 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]; |
|
| 288 | - $this->_empty = false; |
|
| 287 | + $this->_modules[$id]=[$type, $properties->toArray(), $element]; |
|
| 288 | + $this->_empty=false; |
|
| 289 | 289 | } |
| 290 | 290 | else |
| 291 | 291 | throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
@@ -303,12 +303,12 @@ discard block |
||
| 303 | 303 | { |
| 304 | 304 | if(!isset($service['class'])) |
| 305 | 305 | throw new TConfigurationException('appconfig_servicetype_required'); |
| 306 | - $type = $service['class']; |
|
| 307 | - $properties = isset($service['properties']) ? $service['properties'] : []; |
|
| 306 | + $type=$service['class']; |
|
| 307 | + $properties=isset($service['properties']) ? $service['properties'] : []; |
|
| 308 | 308 | unset($service['properties']); |
| 309 | - $properties['id'] = $id; |
|
| 310 | - $this->_services[$id] = [$type,$properties,$service]; |
|
| 311 | - $this->_empty = false; |
|
| 309 | + $properties['id']=$id; |
|
| 310 | + $this->_services[$id]=[$type, $properties, $service]; |
|
| 311 | + $this->_empty=false; |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | { |
| 322 | 322 | foreach($servicesNode->getElements() as $element) |
| 323 | 323 | { |
| 324 | - if($element->getTagName() === 'service') |
|
| 324 | + if($element->getTagName()==='service') |
|
| 325 | 325 | { |
| 326 | - $properties = $element->getAttributes(); |
|
| 327 | - if(($id = $properties->itemAt('id')) === null) |
|
| 326 | + $properties=$element->getAttributes(); |
|
| 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]; |
|
| 333 | - $this->_empty = false; |
|
| 332 | + $this->_services[$id]=[$type, $properties->toArray(), $element]; |
|
| 333 | + $this->_empty=false; |
|
| 334 | 334 | } |
| 335 | 335 | else |
| 336 | 336 | throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
@@ -350,16 +350,16 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | if(isset($parameter['class'])) |
| 352 | 352 | { |
| 353 | - $type = $parameter['class']; |
|
| 353 | + $type=$parameter['class']; |
|
| 354 | 354 | unset($parameter['class']); |
| 355 | - $properties = isset($service['properties']) ? $service['properties'] : []; |
|
| 356 | - $properties['id'] = $id; |
|
| 357 | - $this->_parameters[$id] = [$type,$properties]; |
|
| 355 | + $properties=isset($service['properties']) ? $service['properties'] : []; |
|
| 356 | + $properties['id']=$id; |
|
| 357 | + $this->_parameters[$id]=[$type, $properties]; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | else |
| 361 | 361 | { |
| 362 | - $this->_parameters[$id] = $parameter; |
|
| 362 | + $this->_parameters[$id]=$parameter; |
|
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | } |
@@ -373,21 +373,21 @@ discard block |
||
| 373 | 373 | { |
| 374 | 374 | foreach($parametersNode->getElements() as $element) |
| 375 | 375 | { |
| 376 | - if($element->getTagName() === 'parameter') |
|
| 376 | + if($element->getTagName()==='parameter') |
|
| 377 | 377 | { |
| 378 | - $properties = $element->getAttributes(); |
|
| 379 | - if(($id = $properties->remove('id')) === null) |
|
| 378 | + $properties=$element->getAttributes(); |
|
| 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) |
|
| 384 | - $this->_parameters[$id] = $element; |
|
| 383 | + if(($value=$properties->remove('value'))===null) |
|
| 384 | + $this->_parameters[$id]=$element; |
|
| 385 | 385 | else |
| 386 | - $this->_parameters[$id] = $value; |
|
| 386 | + $this->_parameters[$id]=$value; |
|
| 387 | 387 | } |
| 388 | 388 | else |
| 389 | - $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
| 390 | - $this->_empty = false; |
|
| 389 | + $this->_parameters[$id]=[$type, $properties->toArray()]; |
|
| 390 | + $this->_empty=false; |
|
| 391 | 391 | } |
| 392 | 392 | else |
| 393 | 393 | throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
@@ -403,15 +403,15 @@ discard block |
||
| 403 | 403 | { |
| 404 | 404 | foreach($includeNode as $include) |
| 405 | 405 | { |
| 406 | - $when = isset($include['when'])?true:false; |
|
| 406 | + $when=isset($include['when']) ?true:false; |
|
| 407 | 407 | if(!isset($include['file'])) |
| 408 | 408 | throw new TConfigurationException('appconfig_includefile_required'); |
| 409 | - $filePath = $include['file']; |
|
| 409 | + $filePath=$include['file']; |
|
| 410 | 410 | if(isset($this->_includes[$filePath])) |
| 411 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
| 411 | + $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
|
| 412 | 412 | else |
| 413 | - $$this->_includes[$filePath] = $when; |
|
| 414 | - $this->_empty = false; |
|
| 413 | + $$this->_includes[$filePath]=$when; |
|
| 414 | + $this->_empty=false; |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | protected function loadExternalXml($includeNode, $configPath) |
| 424 | 424 | { |
| 425 | - if(($when = $includeNode->getAttribute('when')) === null) |
|
| 426 | - $when = true; |
|
| 427 | - if(($filePath = $includeNode->getAttribute('file')) === null) |
|
| 425 | + if(($when=$includeNode->getAttribute('when'))===null) |
|
| 426 | + $when=true; |
|
| 427 | + if(($filePath=$includeNode->getAttribute('file'))===null) |
|
| 428 | 428 | throw new TConfigurationException('appconfig_includefile_required'); |
| 429 | 429 | if(isset($this->_includes[$filePath])) |
| 430 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
| 430 | + $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
|
| 431 | 431 | else |
| 432 | - $this->_includes[$filePath] = $when; |
|
| 433 | - $this->_empty = false; |
|
| 432 | + $this->_includes[$filePath]=$when; |
|
| 433 | + $this->_empty=false; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -70,8 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $fcontent = include $fname; |
| 72 | 72 | $this->loadFromPhp($fcontent, dirname($fname)); |
| 73 | - } |
|
| 74 | - else |
|
| 73 | + } else |
|
| 75 | 74 | { |
| 76 | 75 | $dom = new TXmlDocument; |
| 77 | 76 | $dom->loadFromFile($fname); |
@@ -218,8 +217,7 @@ discard block |
||
| 218 | 217 | if(isset($this->_aliases[$id])) |
| 219 | 218 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
| 220 | 219 | $this->_aliases[$id] = $p; |
| 221 | - } |
|
| 222 | - else |
|
| 220 | + } else |
|
| 223 | 221 | throw new TConfigurationException('appconfig_alias_invalid'); |
| 224 | 222 | $this->_empty = false; |
| 225 | 223 | break; |
@@ -286,8 +284,7 @@ discard block |
||
| 286 | 284 | else |
| 287 | 285 | $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
| 288 | 286 | $this->_empty = false; |
| 289 | - } |
|
| 290 | - else |
|
| 287 | + } else |
|
| 291 | 288 | throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
| 292 | 289 | } |
| 293 | 290 | } |
@@ -331,8 +328,7 @@ discard block |
||
| 331 | 328 | $element->setParent(null); |
| 332 | 329 | $this->_services[$id] = [$type,$properties->toArray(),$element]; |
| 333 | 330 | $this->_empty = false; |
| 334 | - } |
|
| 335 | - else |
|
| 331 | + } else |
|
| 336 | 332 | throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
| 337 | 333 | } |
| 338 | 334 | } |
@@ -356,8 +352,7 @@ discard block |
||
| 356 | 352 | $properties['id'] = $id; |
| 357 | 353 | $this->_parameters[$id] = [$type,$properties]; |
| 358 | 354 | } |
| 359 | - } |
|
| 360 | - else |
|
| 355 | + } else |
|
| 361 | 356 | { |
| 362 | 357 | $this->_parameters[$id] = $parameter; |
| 363 | 358 | } |
@@ -384,12 +379,10 @@ discard block |
||
| 384 | 379 | $this->_parameters[$id] = $element; |
| 385 | 380 | else |
| 386 | 381 | $this->_parameters[$id] = $value; |
| 387 | - } |
|
| 388 | - else |
|
| 382 | + } else |
|
| 389 | 383 | $this->_parameters[$id] = [$type,$properties->toArray()]; |
| 390 | 384 | $this->_empty = false; |
| 391 | - } |
|
| 392 | - else |
|
| 385 | + } else |
|
| 393 | 386 | throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
| 394 | 387 | } |
| 395 | 388 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * </code> |
| 423 | 423 | * to be executed when listen is called. All attached behaviors are notified through dyListen. |
| 424 | 424 | * |
| 425 | - * @return numeric the number of global events that were registered to the global event registry |
|
| 425 | + * @return null|integer the number of global events that were registered to the global event registry |
|
| 426 | 426 | */ |
| 427 | 427 | public function listen() { |
| 428 | 428 | if($this->_listeningenabled) |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * </code> |
| 457 | 457 | * to be executed when listen is called. All attached behaviors are notified through dyUnlisten. |
| 458 | 458 | * |
| 459 | - * @return numeric the number of global events that were unregistered from the global event registry |
|
| 459 | + * @return null|integer the number of global events that were unregistered from the global event registry |
|
| 460 | 460 | */ |
| 461 | 461 | public function unlisten() { |
| 462 | 462 | if(!$this->_listeningenabled) |
@@ -793,6 +793,7 @@ discard block |
||
| 793 | 793 | * A property is defined if there is a getter or setter method |
| 794 | 794 | * defined in the class. Note, property names are case-insensitive. |
| 795 | 795 | * @param string the property name |
| 796 | + * @param string $name |
|
| 796 | 797 | * @return boolean whether the property is defined |
| 797 | 798 | */ |
| 798 | 799 | public function hasProperty($name) |
@@ -301,23 +301,23 @@ discard block |
||
| 301 | 301 | /** |
| 302 | 302 | * @var array event handler lists |
| 303 | 303 | */ |
| 304 | - private $_e = []; |
|
| 304 | + private $_e=[]; |
|
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | 307 | * @var boolean if listening is enabled. Automatically turned on or off in |
| 308 | 308 | * constructor according to {@link getAutoGlobalListen}. Default false, off |
| 309 | 309 | */ |
| 310 | - private $_listeningenabled = false; |
|
| 310 | + private $_listeningenabled=false; |
|
| 311 | 311 | |
| 312 | 312 | /** |
| 313 | 313 | * @var array static registered global event handler lists |
| 314 | 314 | */ |
| 315 | - private static $_ue = []; |
|
| 315 | + private static $_ue=[]; |
|
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | 318 | * @var boolean if object behaviors are on or off. default true, on |
| 319 | 319 | */ |
| 320 | - private $_behaviorsenabled = true; |
|
| 320 | + private $_behaviorsenabled=true; |
|
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | 323 | * @var TPriorityMap list of object behaviors |
@@ -327,13 +327,13 @@ discard block |
||
| 327 | 327 | /** |
| 328 | 328 | * @var array static global class behaviors, these behaviors are added upon instantiation of a class |
| 329 | 329 | */ |
| 330 | - private static $_um = []; |
|
| 330 | + private static $_um=[]; |
|
| 331 | 331 | |
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | 334 | * @const string the name of the global {@link raiseEvent} listener |
| 335 | 335 | */ |
| 336 | - const GLOBAL_RAISE_EVENT_LISTENER = 'fxGlobalListener'; |
|
| 336 | + const GLOBAL_RAISE_EVENT_LISTENER='fxGlobalListener'; |
|
| 337 | 337 | |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | if($this->getAutoGlobalListen()) |
| 348 | 348 | $this->listen(); |
| 349 | 349 | |
| 350 | - $classes = array_reverse($this->getClassHierarchy(true)); |
|
| 350 | + $classes=array_reverse($this->getClassHierarchy(true)); |
|
| 351 | 351 | foreach($classes as $class) { |
| 352 | 352 | if(isset(self::$_um[$class])) |
| 353 | 353 | $this->attachBehaviors(self::$_um[$class]); |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * that start with 'fx' are filtered in. |
| 391 | 391 | */ |
| 392 | 392 | private function filter_prado_fx($name) { |
| 393 | - return strncasecmp($name, 'fx', 2) === 0; |
|
| 393 | + return strncasecmp($name, 'fx', 2)===0; |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
@@ -400,11 +400,11 @@ discard block |
||
| 400 | 400 | * @param boolean optional should the names be all lowercase true/false |
| 401 | 401 | * @return array array of strings being the class hierarchy of $this. |
| 402 | 402 | */ |
| 403 | - public function getClassHierarchy($lowercase = false) |
|
| 403 | + public function getClassHierarchy($lowercase=false) |
|
| 404 | 404 | { |
| 405 | - $class = get_class($this); |
|
| 406 | - $classes = [$class]; |
|
| 407 | - while($class = get_parent_class($class)){array_unshift($classes, $class);} |
|
| 405 | + $class=get_class($this); |
|
| 406 | + $classes=[$class]; |
|
| 407 | + while($class=get_parent_class($class)) {array_unshift($classes, $class); } |
|
| 408 | 408 | if($lowercase) |
| 409 | 409 | return array_map('strtolower', $classes); |
| 410 | 410 | return $classes; |
@@ -429,17 +429,17 @@ discard block |
||
| 429 | 429 | if($this->_listeningenabled) |
| 430 | 430 | return; |
| 431 | 431 | |
| 432 | - $fx = array_filter(get_class_methods($this), [$this,'filter_prado_fx']); |
|
| 432 | + $fx=array_filter(get_class_methods($this), [$this, 'filter_prado_fx']); |
|
| 433 | 433 | |
| 434 | 434 | foreach($fx as $func) |
| 435 | - $this->attachEventHandler($func, [$this,$func]); |
|
| 435 | + $this->attachEventHandler($func, [$this, $func]); |
|
| 436 | 436 | |
| 437 | 437 | if(is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
| 438 | - $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this,'__dycall']); |
|
| 438 | + $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this, '__dycall']); |
|
| 439 | 439 | array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - $this->_listeningenabled = true; |
|
| 442 | + $this->_listeningenabled=true; |
|
| 443 | 443 | |
| 444 | 444 | $this->dyListen($fx); |
| 445 | 445 | |
@@ -463,17 +463,17 @@ discard block |
||
| 463 | 463 | if(!$this->_listeningenabled) |
| 464 | 464 | return; |
| 465 | 465 | |
| 466 | - $fx = array_filter(get_class_methods($this), [$this,'filter_prado_fx']); |
|
| 466 | + $fx=array_filter(get_class_methods($this), [$this, 'filter_prado_fx']); |
|
| 467 | 467 | |
| 468 | 468 | foreach($fx as $func) |
| 469 | - $this->detachEventHandler($func, [$this,$func]); |
|
| 469 | + $this->detachEventHandler($func, [$this, $func]); |
|
| 470 | 470 | |
| 471 | 471 | if(is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
| 472 | - $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this,'__dycall']); |
|
| 472 | + $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this, '__dycall']); |
|
| 473 | 473 | array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $this->_listeningenabled = false; |
|
| 476 | + $this->_listeningenabled=false; |
|
| 477 | 477 | |
| 478 | 478 | $this->dyUnlisten($fx); |
| 479 | 479 | |
@@ -515,41 +515,41 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | public function __call($method, $args) |
| 517 | 517 | { |
| 518 | - $getset = substr($method, 0, 3); |
|
| 519 | - if(($getset == 'get') || ($getset == 'set')) |
|
| 518 | + $getset=substr($method, 0, 3); |
|
| 519 | + if(($getset=='get') || ($getset=='set')) |
|
| 520 | 520 | { |
| 521 | - $propname = substr($method, 3); |
|
| 522 | - $jsmethod = $getset . 'js' . $propname; |
|
| 521 | + $propname=substr($method, 3); |
|
| 522 | + $jsmethod=$getset.'js'.$propname; |
|
| 523 | 523 | if(method_exists($this, $jsmethod)) |
| 524 | 524 | { |
| 525 | 525 | if(count($args) > 0) |
| 526 | 526 | if($args[0] && !($args[0] instanceof TJavaScriptString)) |
| 527 | - $args[0] = new TJavaScriptString($args[0]); |
|
| 528 | - return call_user_func_array([$this,$jsmethod], $args); |
|
| 527 | + $args[0]=new TJavaScriptString($args[0]); |
|
| 528 | + return call_user_func_array([$this, $jsmethod], $args); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if (($getset == 'set') && method_exists($this, 'getjs' . $propname)) |
|
| 531 | + if(($getset=='set') && method_exists($this, 'getjs'.$propname)) |
|
| 532 | 532 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $method); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - if($this->_m !== null && $this->_behaviorsenabled) |
|
| 535 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
| 536 | 536 | { |
| 537 | - if(strncasecmp($method, 'dy', 2) === 0) |
|
| 537 | + if(strncasecmp($method, 'dy', 2)===0) |
|
| 538 | 538 | { |
| 539 | - $callchain = new TCallChain($method); |
|
| 539 | + $callchain=new TCallChain($method); |
|
| 540 | 540 | foreach($this->_m->toArray() as $behavior) |
| 541 | 541 | { |
| 542 | 542 | if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) |
| 543 | 543 | { |
| 544 | - $behavior_args = $args; |
|
| 544 | + $behavior_args=$args; |
|
| 545 | 545 | if($behavior instanceof IClassBehavior) |
| 546 | 546 | array_unshift($behavior_args, $this); |
| 547 | - $callchain->addCall([$behavior,$method], $behavior_args); |
|
| 547 | + $callchain->addCall([$behavior, $method], $behavior_args); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | } |
| 551 | 551 | if($callchain->getCount() > 0) |
| 552 | - return call_user_func_array([$callchain,'call'], $args); |
|
| 552 | + return call_user_func_array([$callchain, 'call'], $args); |
|
| 553 | 553 | } |
| 554 | 554 | else |
| 555 | 555 | { |
@@ -559,21 +559,21 @@ discard block |
||
| 559 | 559 | { |
| 560 | 560 | if($behavior instanceof IClassBehavior) |
| 561 | 561 | array_unshift($args, $this); |
| 562 | - return call_user_func_array([$behavior,$method], $args); |
|
| 562 | + return call_user_func_array([$behavior, $method], $args); |
|
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - if(strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) |
|
| 568 | + if(strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
| 569 | 569 | { |
| 570 | 570 | if($this instanceof IDynamicMethods) |
| 571 | 571 | return $this->__dycall($method, $args); |
| 572 | - return isset($args[0])?$args[0]:null; |
|
| 572 | + return isset($args[0]) ? $args[0] : null; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | // don't thrown an exception for __magicMethods() or any other weird methods natively implemented by php |
| 576 | - if (!method_exists($this, $method)) { |
|
| 576 | + if(!method_exists($this, $method)) { |
|
| 577 | 577 | throw new TApplicationException('component_method_undefined', get_class($this), $method); |
| 578 | 578 | } |
| 579 | 579 | } |
@@ -604,30 +604,30 @@ discard block |
||
| 604 | 604 | */ |
| 605 | 605 | public function __get($name) |
| 606 | 606 | { |
| 607 | - if(method_exists($this, $getter = 'get' . $name)) |
|
| 607 | + if(method_exists($this, $getter='get'.$name)) |
|
| 608 | 608 | { |
| 609 | 609 | // getting a property |
| 610 | 610 | return $this->$getter(); |
| 611 | 611 | } |
| 612 | - elseif(method_exists($this, $jsgetter = 'getjs' . $name)) |
|
| 612 | + elseif(method_exists($this, $jsgetter='getjs'.$name)) |
|
| 613 | 613 | { |
| 614 | 614 | // getting a javascript property |
| 615 | - return (string)$this->$jsgetter(); |
|
| 615 | + return (string) $this->$jsgetter(); |
|
| 616 | 616 | } |
| 617 | - elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) |
|
| 617 | + elseif(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 618 | 618 | { |
| 619 | 619 | // getting an event (handler list) |
| 620 | - $name = strtolower($name); |
|
| 620 | + $name=strtolower($name); |
|
| 621 | 621 | if(!isset($this->_e[$name])) |
| 622 | - $this->_e[$name] = new TPriorityList; |
|
| 622 | + $this->_e[$name]=new TPriorityList; |
|
| 623 | 623 | return $this->_e[$name]; |
| 624 | 624 | } |
| 625 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 625 | + elseif(strncasecmp($name, 'fx', 2)===0) |
|
| 626 | 626 | { |
| 627 | 627 | // getting a global event (handler list) |
| 628 | - $name = strtolower($name); |
|
| 628 | + $name=strtolower($name); |
|
| 629 | 629 | if(!isset(self::$_ue[$name])) |
| 630 | - self::$_ue[$name] = new TPriorityList; |
|
| 630 | + self::$_ue[$name]=new TPriorityList; |
|
| 631 | 631 | return self::$_ue[$name]; |
| 632 | 632 | } |
| 633 | 633 | elseif($this->_behaviorsenabled) |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | // getting a behavior property/event (handler list) |
| 636 | 636 | if(isset($this->_m[$name])) |
| 637 | 637 | return $this->_m[$name]; |
| 638 | - elseif($this->_m !== null) |
|
| 638 | + elseif($this->_m!==null) |
|
| 639 | 639 | { |
| 640 | 640 | foreach($this->_m->toArray() as $behavior) |
| 641 | 641 | { |
@@ -665,30 +665,30 @@ discard block |
||
| 665 | 665 | */ |
| 666 | 666 | public function __set($name, $value) |
| 667 | 667 | { |
| 668 | - if(method_exists($this, $setter = 'set' . $name)) |
|
| 668 | + if(method_exists($this, $setter='set'.$name)) |
|
| 669 | 669 | { |
| 670 | - if(strncasecmp($name, 'js', 2) === 0 && $value && !($value instanceof TJavaScriptLiteral)) |
|
| 671 | - $value = new TJavaScriptLiteral($value); |
|
| 670 | + if(strncasecmp($name, 'js', 2)===0 && $value && !($value instanceof TJavaScriptLiteral)) |
|
| 671 | + $value=new TJavaScriptLiteral($value); |
|
| 672 | 672 | return $this->$setter($value); |
| 673 | 673 | } |
| 674 | - elseif(method_exists($this, $jssetter = 'setjs' . $name)) |
|
| 674 | + elseif(method_exists($this, $jssetter='setjs'.$name)) |
|
| 675 | 675 | { |
| 676 | 676 | if($value && !($value instanceof TJavaScriptString)) |
| 677 | - $value = new TJavaScriptString($value); |
|
| 677 | + $value=new TJavaScriptString($value); |
|
| 678 | 678 | return $this->$jssetter($value); |
| 679 | 679 | } |
| 680 | - elseif((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0) |
|
| 680 | + elseif((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0) |
|
| 681 | 681 | { |
| 682 | 682 | return $this->attachEventHandler($name, $value); |
| 683 | 683 | } |
| 684 | - elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 684 | + elseif($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 685 | 685 | { |
| 686 | - $sets = 0; |
|
| 686 | + $sets=0; |
|
| 687 | 687 | foreach($this->_m->toArray() as $behavior) |
| 688 | 688 | { |
| 689 | 689 | if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
| 690 | 690 | (property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) { |
| 691 | - $behavior->$name = $value; |
|
| 691 | + $behavior->$name=$value; |
|
| 692 | 692 | $sets++; |
| 693 | 693 | } |
| 694 | 694 | } |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - if(method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) |
|
| 699 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
| 700 | 700 | { |
| 701 | 701 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
| 702 | 702 | } |
@@ -720,21 +720,21 @@ discard block |
||
| 720 | 720 | */ |
| 721 | 721 | public function __isset($name) |
| 722 | 722 | { |
| 723 | - if(method_exists($this, $getter = 'get' . $name)) |
|
| 724 | - return $this->$getter() !== null; |
|
| 725 | - elseif(method_exists($this, $jsgetter = 'getjs' . $name)) |
|
| 726 | - return $this->$jsgetter() !== null; |
|
| 727 | - elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) |
|
| 723 | + if(method_exists($this, $getter='get'.$name)) |
|
| 724 | + return $this->$getter()!==null; |
|
| 725 | + elseif(method_exists($this, $jsgetter='getjs'.$name)) |
|
| 726 | + return $this->$jsgetter()!==null; |
|
| 727 | + elseif(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 728 | 728 | { |
| 729 | - $name = strtolower($name); |
|
| 729 | + $name=strtolower($name); |
|
| 730 | 730 | return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
| 731 | 731 | } |
| 732 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 732 | + elseif(strncasecmp($name, 'fx', 2)===0) |
|
| 733 | 733 | { |
| 734 | - $name = strtolower($name); |
|
| 734 | + $name=strtolower($name); |
|
| 735 | 735 | return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
| 736 | 736 | } |
| 737 | - elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 737 | + elseif($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 738 | 738 | { |
| 739 | 739 | if(isset($this->_m[$name])) |
| 740 | 740 | return true; |
@@ -761,20 +761,20 @@ discard block |
||
| 761 | 761 | */ |
| 762 | 762 | public function __unset($name) |
| 763 | 763 | { |
| 764 | - if(method_exists($this, $setter = 'set' . $name)) |
|
| 764 | + if(method_exists($this, $setter='set'.$name)) |
|
| 765 | 765 | $this->$setter(null); |
| 766 | - elseif(method_exists($this, $jssetter = 'setjs' . $name)) |
|
| 766 | + elseif(method_exists($this, $jssetter='setjs'.$name)) |
|
| 767 | 767 | $this->$jssetter(null); |
| 768 | - elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) |
|
| 768 | + elseif(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 769 | 769 | $this->_e[strtolower($name)]->clear(); |
| 770 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 770 | + elseif(strncasecmp($name, 'fx', 2)===0) |
|
| 771 | 771 | $this->getEventHandlers($name)->remove([$this, $name]); |
| 772 | - elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 772 | + elseif($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 773 | 773 | { |
| 774 | 774 | if(isset($this->_m[$name])) |
| 775 | 775 | $this->detachBehavior($name); |
| 776 | 776 | else { |
| 777 | - $unset = 0; |
|
| 777 | + $unset=0; |
|
| 778 | 778 | foreach($this->_m->toArray() as $behavior) |
| 779 | 779 | { |
| 780 | 780 | if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
@@ -782,10 +782,10 @@ discard block |
||
| 782 | 782 | $unset++; |
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | - if(!$unset && method_exists($this, 'get' . $name)) |
|
| 785 | + if(!$unset && method_exists($this, 'get'.$name)) |
|
| 786 | 786 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
| 787 | 787 | } |
| 788 | - } elseif(method_exists($this, 'get' . $name)) |
|
| 788 | + } elseif(method_exists($this, 'get'.$name)) |
|
| 789 | 789 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
| 790 | 790 | } |
| 791 | 791 | |
@@ -812,9 +812,9 @@ discard block |
||
| 812 | 812 | */ |
| 813 | 813 | public function canGetProperty($name) |
| 814 | 814 | { |
| 815 | - if(method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) |
|
| 815 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
| 816 | 816 | return true; |
| 817 | - elseif($this->_m !== null && $this->_behaviorsenabled) |
|
| 817 | + elseif($this->_m!==null && $this->_behaviorsenabled) |
|
| 818 | 818 | { |
| 819 | 819 | foreach($this->_m->toArray() as $behavior) |
| 820 | 820 | { |
@@ -836,9 +836,9 @@ discard block |
||
| 836 | 836 | */ |
| 837 | 837 | public function canSetProperty($name) |
| 838 | 838 | { |
| 839 | - if(method_exists($this, 'set' . $name) || method_exists($this, 'setjs' . $name)) |
|
| 839 | + if(method_exists($this, 'set'.$name) || method_exists($this, 'setjs'.$name)) |
|
| 840 | 840 | return true; |
| 841 | - elseif($this->_m !== null && $this->_behaviorsenabled) |
|
| 841 | + elseif($this->_m!==null && $this->_behaviorsenabled) |
|
| 842 | 842 | { |
| 843 | 843 | foreach($this->_m->toArray() as $behavior) |
| 844 | 844 | { |
@@ -861,9 +861,9 @@ discard block |
||
| 861 | 861 | */ |
| 862 | 862 | public function getSubProperty($path) |
| 863 | 863 | { |
| 864 | - $object = $this; |
|
| 864 | + $object=$this; |
|
| 865 | 865 | foreach(explode('.', $path) as $property) |
| 866 | - $object = $object->$property; |
|
| 866 | + $object=$object->$property; |
|
| 867 | 867 | return $object; |
| 868 | 868 | } |
| 869 | 869 | |
@@ -879,15 +879,15 @@ discard block |
||
| 879 | 879 | */ |
| 880 | 880 | public function setSubProperty($path, $value) |
| 881 | 881 | { |
| 882 | - $object = $this; |
|
| 883 | - if(($pos = strrpos($path, '.')) === false) |
|
| 884 | - $property = $path; |
|
| 882 | + $object=$this; |
|
| 883 | + if(($pos=strrpos($path, '.'))===false) |
|
| 884 | + $property=$path; |
|
| 885 | 885 | else |
| 886 | 886 | { |
| 887 | - $object = $this->getSubProperty(substr($path, 0, $pos)); |
|
| 888 | - $property = substr($path, $pos + 1); |
|
| 887 | + $object=$this->getSubProperty(substr($path, 0, $pos)); |
|
| 888 | + $property=substr($path, $pos + 1); |
|
| 889 | 889 | } |
| 890 | - $object->$property = $value; |
|
| 890 | + $object->$property=$value; |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | /** |
@@ -904,10 +904,10 @@ discard block |
||
| 904 | 904 | */ |
| 905 | 905 | public function hasEvent($name) |
| 906 | 906 | { |
| 907 | - if((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0 || strncasecmp($name, 'dy', 2) === 0) |
|
| 907 | + if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0 || strncasecmp($name, 'dy', 2)===0) |
|
| 908 | 908 | return true; |
| 909 | 909 | |
| 910 | - elseif($this->_m !== null && $this->_behaviorsenabled) |
|
| 910 | + elseif($this->_m!==null && $this->_behaviorsenabled) |
|
| 911 | 911 | { |
| 912 | 912 | foreach($this->_m->toArray() as $behavior) |
| 913 | 913 | { |
@@ -927,14 +927,14 @@ discard block |
||
| 927 | 927 | */ |
| 928 | 928 | public function hasEventHandler($name) |
| 929 | 929 | { |
| 930 | - $name = strtolower($name); |
|
| 931 | - if(strncasecmp($name, 'fx', 2) === 0) |
|
| 930 | + $name=strtolower($name); |
|
| 931 | + if(strncasecmp($name, 'fx', 2)===0) |
|
| 932 | 932 | return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0; |
| 933 | 933 | else |
| 934 | 934 | { |
| 935 | 935 | if(isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) |
| 936 | 936 | return true; |
| 937 | - elseif($this->_m !== null && $this->_behaviorsenabled) { |
|
| 937 | + elseif($this->_m!==null && $this->_behaviorsenabled) { |
|
| 938 | 938 | foreach($this->_m->toArray() as $behavior) |
| 939 | 939 | { |
| 940 | 940 | if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) |
@@ -953,21 +953,21 @@ discard block |
||
| 953 | 953 | */ |
| 954 | 954 | public function getEventHandlers($name) |
| 955 | 955 | { |
| 956 | - if(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) |
|
| 956 | + if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 957 | 957 | { |
| 958 | - $name = strtolower($name); |
|
| 958 | + $name=strtolower($name); |
|
| 959 | 959 | if(!isset($this->_e[$name])) |
| 960 | - $this->_e[$name] = new TPriorityList; |
|
| 960 | + $this->_e[$name]=new TPriorityList; |
|
| 961 | 961 | return $this->_e[$name]; |
| 962 | 962 | } |
| 963 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 963 | + elseif(strncasecmp($name, 'fx', 2)===0) |
|
| 964 | 964 | { |
| 965 | - $name = strtolower($name); |
|
| 965 | + $name=strtolower($name); |
|
| 966 | 966 | if(!isset(self::$_ue[$name])) |
| 967 | - self::$_ue[$name] = new TPriorityList; |
|
| 967 | + self::$_ue[$name]=new TPriorityList; |
|
| 968 | 968 | return self::$_ue[$name]; |
| 969 | 969 | } |
| 970 | - elseif($this->_m !== null && $this->_behaviorsenabled) |
|
| 970 | + elseif($this->_m!==null && $this->_behaviorsenabled) |
|
| 971 | 971 | { |
| 972 | 972 | foreach($this->_m->toArray() as $behavior) |
| 973 | 973 | { |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | * default priority of 10.0 within {@link TPriorityList} |
| 1024 | 1024 | * @throws TInvalidOperationException if the event does not exist |
| 1025 | 1025 | */ |
| 1026 | - public function attachEventHandler($name, $handler, $priority = null) |
|
| 1026 | + public function attachEventHandler($name, $handler, $priority=null) |
|
| 1027 | 1027 | { |
| 1028 | 1028 | $this->getEventHandlers($name)->add($handler, $priority); |
| 1029 | 1029 | } |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | * to an item of any priority within {@link TPriorityList}; null means the default priority |
| 1039 | 1039 | * @return boolean if the removal is successful |
| 1040 | 1040 | */ |
| 1041 | - public function detachEventHandler($name, $handler, $priority = false) |
|
| 1041 | + public function detachEventHandler($name, $handler, $priority=false) |
|
| 1042 | 1042 | { |
| 1043 | 1043 | if($this->hasEventHandler($name)) |
| 1044 | 1044 | { |
@@ -1126,75 +1126,75 @@ discard block |
||
| 1126 | 1126 | * @throws TInvalidOperationException if the event is undefined |
| 1127 | 1127 | * @throws TInvalidDataValueException If an event handler is invalid |
| 1128 | 1128 | */ |
| 1129 | - public function raiseEvent($name, $sender, $param, $responsetype = null, $postfunction = null) |
|
| 1129 | + public function raiseEvent($name, $sender, $param, $responsetype=null, $postfunction=null) |
|
| 1130 | 1130 | { |
| 1131 | - $p = $param; |
|
| 1131 | + $p=$param; |
|
| 1132 | 1132 | if(is_callable($responsetype)) |
| 1133 | 1133 | { |
| 1134 | - $postfunction = $responsetype; |
|
| 1135 | - $responsetype = null; |
|
| 1134 | + $postfunction=$responsetype; |
|
| 1135 | + $responsetype=null; |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | - if($responsetype === null) |
|
| 1139 | - $responsetype = TEventResults::EVENT_RESULT_FILTER; |
|
| 1138 | + if($responsetype===null) |
|
| 1139 | + $responsetype=TEventResults::EVENT_RESULT_FILTER; |
|
| 1140 | 1140 | |
| 1141 | - $name = strtolower($name); |
|
| 1142 | - $responses = []; |
|
| 1141 | + $name=strtolower($name); |
|
| 1142 | + $responses=[]; |
|
| 1143 | 1143 | |
| 1144 | - $name = $this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
|
| 1144 | + $name=$this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
|
| 1145 | 1145 | |
| 1146 | 1146 | if($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
| 1147 | 1147 | { |
| 1148 | - $handlers = $this->getEventHandlers($name); |
|
| 1149 | - $handlerArray = $handlers->toArray(); |
|
| 1150 | - if(strncasecmp($name, 'fx', 2) === 0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
| 1148 | + $handlers=$this->getEventHandlers($name); |
|
| 1149 | + $handlerArray=$handlers->toArray(); |
|
| 1150 | + if(strncasecmp($name, 'fx', 2)===0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
| 1151 | 1151 | { |
| 1152 | - $globalhandlers = $this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
| 1153 | - $handlerArray = array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
|
| 1152 | + $globalhandlers=$this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
| 1153 | + $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
|
| 1154 | 1154 | } |
| 1155 | - $response = null; |
|
| 1155 | + $response=null; |
|
| 1156 | 1156 | foreach($handlerArray as $handler) |
| 1157 | 1157 | { |
| 1158 | - if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name) === false) |
|
| 1158 | + if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name)===false) |
|
| 1159 | 1159 | continue; |
| 1160 | 1160 | |
| 1161 | 1161 | if(is_string($handler)) |
| 1162 | 1162 | { |
| 1163 | - if(($pos = strrpos($handler, '.')) !== false) |
|
| 1163 | + if(($pos=strrpos($handler, '.'))!==false) |
|
| 1164 | 1164 | { |
| 1165 | - $object = $this->getSubProperty(substr($handler, 0, $pos)); |
|
| 1166 | - $method = substr($handler, $pos + 1); |
|
| 1167 | - if(method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) |
|
| 1165 | + $object=$this->getSubProperty(substr($handler, 0, $pos)); |
|
| 1166 | + $method=substr($handler, $pos + 1); |
|
| 1167 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
| 1168 | 1168 | { |
| 1169 | - if($method == '__dycall') |
|
| 1170 | - $response = $object->__dycall($name, [$sender,$param,$name]); |
|
| 1169 | + if($method=='__dycall') |
|
| 1170 | + $response=$object->__dycall($name, [$sender, $param, $name]); |
|
| 1171 | 1171 | else |
| 1172 | - $response = $object->$method($sender, $param, $name); |
|
| 1172 | + $response=$object->$method($sender, $param, $name); |
|
| 1173 | 1173 | } |
| 1174 | 1174 | else |
| 1175 | 1175 | throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler); |
| 1176 | 1176 | } |
| 1177 | 1177 | else |
| 1178 | - $response = call_user_func($handler, $sender, $param, $name); |
|
| 1178 | + $response=call_user_func($handler, $sender, $param, $name); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | elseif(is_callable($handler, true)) |
| 1181 | 1181 | { |
| 1182 | - list($object, $method) = $handler; |
|
| 1182 | + list($object, $method)=$handler; |
|
| 1183 | 1183 | if(is_string($object)) |
| 1184 | - $response = call_user_func($handler, $sender, $param, $name); |
|
| 1184 | + $response=call_user_func($handler, $sender, $param, $name); |
|
| 1185 | 1185 | else |
| 1186 | 1186 | { |
| 1187 | - if(($pos = strrpos($method, '.')) !== false) |
|
| 1187 | + if(($pos=strrpos($method, '.'))!==false) |
|
| 1188 | 1188 | { |
| 1189 | - $object = $this->getSubProperty(substr($method, 0, $pos)); |
|
| 1190 | - $method = substr($method, $pos + 1); |
|
| 1189 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
| 1190 | + $method=substr($method, $pos + 1); |
|
| 1191 | 1191 | } |
| 1192 | - if(method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) |
|
| 1192 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
| 1193 | 1193 | { |
| 1194 | - if($method == '__dycall') |
|
| 1195 | - $response = $object->__dycall($name, [$sender,$param,$name]); |
|
| 1194 | + if($method=='__dycall') |
|
| 1195 | + $response=$object->__dycall($name, [$sender, $param, $name]); |
|
| 1196 | 1196 | else |
| 1197 | - $response = $object->$method($sender, $param, $name); |
|
| 1197 | + $response=$object->$method($sender, $param, $name); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | else |
| 1200 | 1200 | throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]); |
@@ -1206,25 +1206,25 @@ discard block |
||
| 1206 | 1206 | $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
| 1207 | 1207 | |
| 1208 | 1208 | if($postfunction) |
| 1209 | - $response = call_user_func_array($postfunction, [$sender,$param,$this,$response]); |
|
| 1209 | + $response=call_user_func_array($postfunction, [$sender, $param, $this, $response]); |
|
| 1210 | 1210 | |
| 1211 | 1211 | if($responsetype & TEventResults::EVENT_RESULT_ALL) |
| 1212 | - $responses[] = ['sender' => $sender,'param' => $param,'response' => $response]; |
|
| 1212 | + $responses[]=['sender' => $sender, 'param' => $param, 'response' => $response]; |
|
| 1213 | 1213 | else |
| 1214 | - $responses[] = $response; |
|
| 1214 | + $responses[]=$response; |
|
| 1215 | 1215 | |
| 1216 | - if($response !== null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
| 1217 | - $param = $response; |
|
| 1216 | + if($response!==null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
| 1217 | + $param=$response; |
|
| 1218 | 1218 | |
| 1219 | 1219 | } |
| 1220 | 1220 | } |
| 1221 | - elseif(strncasecmp($name, 'on', 2) === 0 && !$this->hasEvent($name)) |
|
| 1221 | + elseif(strncasecmp($name, 'on', 2)===0 && !$this->hasEvent($name)) |
|
| 1222 | 1222 | throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
| 1223 | 1223 | |
| 1224 | 1224 | if($responsetype & TEventResults::EVENT_RESULT_FILTER) |
| 1225 | - $responses = array_filter($responses); |
|
| 1225 | + $responses=array_filter($responses); |
|
| 1226 | 1226 | |
| 1227 | - $responses = $this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction); |
|
| 1227 | + $responses=$this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction); |
|
| 1228 | 1228 | |
| 1229 | 1229 | return $responses; |
| 1230 | 1230 | } |
@@ -1248,10 +1248,10 @@ discard block |
||
| 1248 | 1248 | */ |
| 1249 | 1249 | public function evaluateExpression($expression) |
| 1250 | 1250 | { |
| 1251 | - $expression = $this->dyEvaluateExpressionFilter($expression); |
|
| 1251 | + $expression=$this->dyEvaluateExpressionFilter($expression); |
|
| 1252 | 1252 | try |
| 1253 | 1253 | { |
| 1254 | - if(eval("\$result=$expression;") === false) |
|
| 1254 | + if(eval("\$result=$expression;")===false) |
|
| 1255 | 1255 | throw new \Exception(''); |
| 1256 | 1256 | return $result; |
| 1257 | 1257 | } |
@@ -1280,13 +1280,13 @@ discard block |
||
| 1280 | 1280 | */ |
| 1281 | 1281 | public function evaluateStatements($statements) |
| 1282 | 1282 | { |
| 1283 | - $statements = $this->dyEvaluateStatementsFilter($statements); |
|
| 1283 | + $statements=$this->dyEvaluateStatementsFilter($statements); |
|
| 1284 | 1284 | try |
| 1285 | 1285 | { |
| 1286 | 1286 | ob_start(); |
| 1287 | - if(eval($statements) === false) |
|
| 1287 | + if(eval($statements)===false) |
|
| 1288 | 1288 | throw new \Exception(''); |
| 1289 | - $content = ob_get_contents(); |
|
| 1289 | + $content=ob_get_contents(); |
|
| 1290 | 1290 | ob_end_clean(); |
| 1291 | 1291 | return $content; |
| 1292 | 1292 | } |
@@ -1317,7 +1317,7 @@ discard block |
||
| 1317 | 1317 | */ |
| 1318 | 1318 | public function createdOnTemplate($parent) |
| 1319 | 1319 | { |
| 1320 | - $parent = $this->dyCreatedOnTemplate($parent); |
|
| 1320 | + $parent=$this->dyCreatedOnTemplate($parent); |
|
| 1321 | 1321 | $parent->addParsedObject($this); |
| 1322 | 1322 | } |
| 1323 | 1323 | |
@@ -1390,24 +1390,24 @@ discard block |
||
| 1390 | 1390 | * @throws TInvalidOperationException if the class behavior is already defined |
| 1391 | 1391 | * @since 3.2.3 |
| 1392 | 1392 | */ |
| 1393 | - public static function attachClassBehavior($name, $behavior, $class = null, $priority = null) { |
|
| 1393 | + public static function attachClassBehavior($name, $behavior, $class=null, $priority=null) { |
|
| 1394 | 1394 | if(!$class && function_exists('get_called_class')) |
| 1395 | - $class = get_called_class(); |
|
| 1395 | + $class=get_called_class(); |
|
| 1396 | 1396 | if(!$class) |
| 1397 | 1397 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
| 1398 | 1398 | |
| 1399 | 1399 | if(!is_string($name)) |
| 1400 | - $name = get_class($name); |
|
| 1401 | - $class = strtolower($class); |
|
| 1402 | - if($class === 'tcomponent') |
|
| 1400 | + $name=get_class($name); |
|
| 1401 | + $class=strtolower($class); |
|
| 1402 | + if($class==='tcomponent') |
|
| 1403 | 1403 | throw new TInvalidOperationException('component_no_tcomponent_class_behaviors'); |
| 1404 | 1404 | if(empty(self::$_um[$class])) |
| 1405 | - self::$_um[$class] = []; |
|
| 1405 | + self::$_um[$class]=[]; |
|
| 1406 | 1406 | if(isset(self::$_um[$class][$name])) |
| 1407 | 1407 | throw new TInvalidOperationException('component_class_behavior_defined', $class, $name); |
| 1408 | - $param = new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
|
| 1409 | - self::$_um[$class] = [$name => $param] + self::$_um[$class]; |
|
| 1410 | - $behaviorObject = is_string($behavior)?new $behavior:$behavior; |
|
| 1408 | + $param=new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
|
| 1409 | + self::$_um[$class]=[$name => $param] + self::$_um[$class]; |
|
| 1410 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
| 1411 | 1411 | return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param); |
| 1412 | 1412 | } |
| 1413 | 1413 | |
@@ -1424,21 +1424,21 @@ discard block |
||
| 1424 | 1424 | * not supplied as a parameter. |
| 1425 | 1425 | * @since 3.2.3 |
| 1426 | 1426 | */ |
| 1427 | - public static function detachClassBehavior($name, $class = null, $priority = false) { |
|
| 1427 | + public static function detachClassBehavior($name, $class=null, $priority=false) { |
|
| 1428 | 1428 | if(!$class && function_exists('get_called_class')) |
| 1429 | - $class = get_called_class(); |
|
| 1429 | + $class=get_called_class(); |
|
| 1430 | 1430 | if(!$class) |
| 1431 | 1431 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
| 1432 | 1432 | |
| 1433 | - $class = strtolower($class); |
|
| 1433 | + $class=strtolower($class); |
|
| 1434 | 1434 | if(!is_string($name)) |
| 1435 | - $name = get_class($name); |
|
| 1435 | + $name=get_class($name); |
|
| 1436 | 1436 | if(empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) |
| 1437 | 1437 | return false; |
| 1438 | - $param = self::$_um[$class][$name]; |
|
| 1439 | - $behavior = $param->getBehavior(); |
|
| 1438 | + $param=self::$_um[$class][$name]; |
|
| 1439 | + $behavior=$param->getBehavior(); |
|
| 1440 | 1440 | unset(self::$_um[$class][$name]); |
| 1441 | - $behaviorObject = is_string($behavior)?new $behavior:$behavior; |
|
| 1441 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
| 1442 | 1442 | return $behaviorObject->raiseEvent('fxDetachClassBehavior', null, $param); |
| 1443 | 1443 | } |
| 1444 | 1444 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | */ |
| 1452 | 1452 | public function asa($behaviorname) |
| 1453 | 1453 | { |
| 1454 | - return isset($this->_m[$behaviorname])?$this->_m[$behaviorname]:null; |
|
| 1454 | + return isset($this->_m[$behaviorname]) ? $this->_m[$behaviorname] : null; |
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | /** |
@@ -1477,15 +1477,15 @@ discard block |
||
| 1477 | 1477 | { |
| 1478 | 1478 | if($this instanceof $class) |
| 1479 | 1479 | return true; |
| 1480 | - if($this->_m !== null && $this->_behaviorsenabled) |
|
| 1481 | - foreach($this->_m->toArray() as $behavior){ |
|
| 1480 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
| 1481 | + foreach($this->_m->toArray() as $behavior) { |
|
| 1482 | 1482 | if(($behavior instanceof IBehavior) && !$behavior->getEnabled()) |
| 1483 | 1483 | continue; |
| 1484 | 1484 | |
| 1485 | - $check = null; |
|
| 1486 | - if(($behavior->isa('\Prado\Util\IInstanceCheck')) && $check = $behavior->isinstanceof($class, $this)) |
|
| 1485 | + $check=null; |
|
| 1486 | + if(($behavior->isa('\Prado\Util\IInstanceCheck')) && $check=$behavior->isinstanceof($class, $this)) |
|
| 1487 | 1487 | return true; |
| 1488 | - if($check === null && ($behavior->isa($class))) |
|
| 1488 | + if($check===null && ($behavior->isa($class))) |
|
| 1489 | 1489 | return true; |
| 1490 | 1490 | } |
| 1491 | 1491 | return false; |
@@ -1518,13 +1518,13 @@ discard block |
||
| 1518 | 1518 | */ |
| 1519 | 1519 | public function detachBehaviors($behaviors) |
| 1520 | 1520 | { |
| 1521 | - if($this->_m !== null) |
|
| 1521 | + if($this->_m!==null) |
|
| 1522 | 1522 | { |
| 1523 | 1523 | foreach($behaviors as $name => $behavior) |
| 1524 | 1524 | if($behavior instanceof TClassBehaviorEventParameter) |
| 1525 | 1525 | $this->detachBehavior($behavior->getName(), $behavior->getPriority()); |
| 1526 | 1526 | else |
| 1527 | - $this->detachBehavior(is_string($behavior)?$behavior:$name); |
|
| 1527 | + $this->detachBehavior(is_string($behavior) ? $behavior : $name); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | } |
| 1530 | 1530 | |
@@ -1534,11 +1534,11 @@ discard block |
||
| 1534 | 1534 | */ |
| 1535 | 1535 | public function clearBehaviors() |
| 1536 | 1536 | { |
| 1537 | - if($this->_m !== null) |
|
| 1537 | + if($this->_m!==null) |
|
| 1538 | 1538 | { |
| 1539 | 1539 | foreach($this->_m->toArray() as $name => $behavior) |
| 1540 | 1540 | $this->detachBehavior($name); |
| 1541 | - $this->_m = null; |
|
| 1541 | + $this->_m=null; |
|
| 1542 | 1542 | } |
| 1543 | 1543 | } |
| 1544 | 1544 | |
@@ -1562,16 +1562,16 @@ discard block |
||
| 1562 | 1562 | * @return IBehavior the behavior object |
| 1563 | 1563 | * @since 3.2.3 |
| 1564 | 1564 | */ |
| 1565 | - public function attachBehavior($name, $behavior, $priority = null) |
|
| 1565 | + public function attachBehavior($name, $behavior, $priority=null) |
|
| 1566 | 1566 | { |
| 1567 | 1567 | if(is_string($behavior)) |
| 1568 | - $behavior = Prado::createComponent($behavior); |
|
| 1568 | + $behavior=Prado::createComponent($behavior); |
|
| 1569 | 1569 | if(!($behavior instanceof IBaseBehavior)) |
| 1570 | 1570 | throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior)); |
| 1571 | 1571 | if($behavior instanceof IBehavior) |
| 1572 | 1572 | $behavior->setEnabled(true); |
| 1573 | - if($this->_m === null) |
|
| 1574 | - $this->_m = new TPriorityMap; |
|
| 1573 | + if($this->_m===null) |
|
| 1574 | + $this->_m=new TPriorityMap; |
|
| 1575 | 1575 | $behavior->attach($this); |
| 1576 | 1576 | $this->dyAttachBehavior($name, $behavior); |
| 1577 | 1577 | $this->_m->add($name, $behavior, $priority); |
@@ -1595,12 +1595,12 @@ discard block |
||
| 1595 | 1595 | * @return IBehavior the detached behavior. Null if the behavior does not exist. |
| 1596 | 1596 | * @since 3.2.3 |
| 1597 | 1597 | */ |
| 1598 | - public function detachBehavior($name, $priority = false) |
|
| 1598 | + public function detachBehavior($name, $priority=false) |
|
| 1599 | 1599 | { |
| 1600 | - if($this->_m != null && isset($this->_m[$name])) |
|
| 1600 | + if($this->_m!=null && isset($this->_m[$name])) |
|
| 1601 | 1601 | { |
| 1602 | 1602 | $this->_m[$name]->detach($this); |
| 1603 | - $behavior = $this->_m->itemAt($name); |
|
| 1603 | + $behavior=$this->_m->itemAt($name); |
|
| 1604 | 1604 | $this->_m->remove($name, $priority); |
| 1605 | 1605 | $this->dyDetachBehavior($name, $behavior); |
| 1606 | 1606 | return $behavior; |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | { |
| 1624 | 1624 | if(!$this->_behaviorsenabled) |
| 1625 | 1625 | { |
| 1626 | - $this->_behaviorsenabled = true; |
|
| 1626 | + $this->_behaviorsenabled=true; |
|
| 1627 | 1627 | $this->dyEnableBehaviors(); |
| 1628 | 1628 | } |
| 1629 | 1629 | } |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | if($this->_behaviorsenabled) |
| 1646 | 1646 | { |
| 1647 | 1647 | $this->dyDisableBehaviors(); |
| 1648 | - $this->_behaviorsenabled = false; |
|
| 1648 | + $this->_behaviorsenabled=false; |
|
| 1649 | 1649 | } |
| 1650 | 1650 | } |
| 1651 | 1651 | |
@@ -1678,7 +1678,7 @@ discard block |
||
| 1678 | 1678 | */ |
| 1679 | 1679 | public function enableBehavior($name) |
| 1680 | 1680 | { |
| 1681 | - if($this->_m != null && isset($this->_m[$name])){ |
|
| 1681 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
| 1682 | 1682 | if($this->_m[$name] instanceof IBehavior) { |
| 1683 | 1683 | $this->_m[$name]->setEnabled(true); |
| 1684 | 1684 | $this->dyEnableBehavior($name, $this->_m[$name]); |
@@ -1706,7 +1706,7 @@ discard block |
||
| 1706 | 1706 | */ |
| 1707 | 1707 | public function disableBehavior($name) |
| 1708 | 1708 | { |
| 1709 | - if($this->_m != null && isset($this->_m[$name])){ |
|
| 1709 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
| 1710 | 1710 | if($this->_m[$name] instanceof IBehavior) { |
| 1711 | 1711 | $this->_m[$name]->setEnabled(false); |
| 1712 | 1712 | $this->dyDisableBehavior($name, $this->_m[$name]); |
@@ -1724,9 +1724,9 @@ discard block |
||
| 1724 | 1724 | */ |
| 1725 | 1725 | public function __sleep() |
| 1726 | 1726 | { |
| 1727 | - $a = (array)$this; |
|
| 1728 | - $a = array_keys($a); |
|
| 1729 | - $exprops = []; |
|
| 1727 | + $a=(array) $this; |
|
| 1728 | + $a=array_keys($a); |
|
| 1729 | + $exprops=[]; |
|
| 1730 | 1730 | $this->_getZappableSleepProps($exprops); |
| 1731 | 1731 | return array_diff($a, $exprops); |
| 1732 | 1732 | } |
@@ -1739,13 +1739,13 @@ discard block |
||
| 1739 | 1739 | */ |
| 1740 | 1740 | protected function _getZappableSleepProps(&$exprops) |
| 1741 | 1741 | { |
| 1742 | - if($this->_listeningenabled === false) |
|
| 1743 | - $exprops[] = "\0Prado\TComponent\0_listeningenabled"; |
|
| 1744 | - if($this->_behaviorsenabled === true) |
|
| 1745 | - $exprops[] = "\0Prado\TComponent\0_behaviorsenabled"; |
|
| 1746 | - if ($this->_e === []) |
|
| 1747 | - $exprops[] = "\0Prado\TComponent\0_e"; |
|
| 1748 | - if ($this->_m === null) |
|
| 1749 | - $exprops[] = "\0Prado\TComponent\0_m"; |
|
| 1742 | + if($this->_listeningenabled===false) |
|
| 1743 | + $exprops[]="\0Prado\TComponent\0_listeningenabled"; |
|
| 1744 | + if($this->_behaviorsenabled===true) |
|
| 1745 | + $exprops[]="\0Prado\TComponent\0_behaviorsenabled"; |
|
| 1746 | + if($this->_e===[]) |
|
| 1747 | + $exprops[]="\0Prado\TComponent\0_e"; |
|
| 1748 | + if($this->_m===null) |
|
| 1749 | + $exprops[]="\0Prado\TComponent\0_m"; |
|
| 1750 | 1750 | } |
| 1751 | 1751 | } |
| 1752 | 1752 | \ No newline at end of file |
@@ -550,8 +550,7 @@ discard block |
||
| 550 | 550 | } |
| 551 | 551 | if($callchain->getCount() > 0) |
| 552 | 552 | return call_user_func_array([$callchain,'call'], $args); |
| 553 | - } |
|
| 554 | - else |
|
| 553 | + } else |
|
| 555 | 554 | { |
| 556 | 555 | foreach($this->_m->toArray() as $behavior) |
| 557 | 556 | { |
@@ -608,29 +607,25 @@ discard block |
||
| 608 | 607 | { |
| 609 | 608 | // getting a property |
| 610 | 609 | return $this->$getter(); |
| 611 | - } |
|
| 612 | - elseif(method_exists($this, $jsgetter = 'getjs' . $name)) |
|
| 610 | + } elseif(method_exists($this, $jsgetter = 'getjs' . $name)) |
|
| 613 | 611 | { |
| 614 | 612 | // getting a javascript property |
| 615 | 613 | return (string)$this->$jsgetter(); |
| 616 | - } |
|
| 617 | - elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) |
|
| 614 | + } elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) |
|
| 618 | 615 | { |
| 619 | 616 | // getting an event (handler list) |
| 620 | 617 | $name = strtolower($name); |
| 621 | 618 | if(!isset($this->_e[$name])) |
| 622 | 619 | $this->_e[$name] = new TPriorityList; |
| 623 | 620 | return $this->_e[$name]; |
| 624 | - } |
|
| 625 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 621 | + } elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 626 | 622 | { |
| 627 | 623 | // getting a global event (handler list) |
| 628 | 624 | $name = strtolower($name); |
| 629 | 625 | if(!isset(self::$_ue[$name])) |
| 630 | 626 | self::$_ue[$name] = new TPriorityList; |
| 631 | 627 | return self::$_ue[$name]; |
| 632 | - } |
|
| 633 | - elseif($this->_behaviorsenabled) |
|
| 628 | + } elseif($this->_behaviorsenabled) |
|
| 634 | 629 | { |
| 635 | 630 | // getting a behavior property/event (handler list) |
| 636 | 631 | if(isset($this->_m[$name])) |
@@ -670,18 +665,15 @@ discard block |
||
| 670 | 665 | if(strncasecmp($name, 'js', 2) === 0 && $value && !($value instanceof TJavaScriptLiteral)) |
| 671 | 666 | $value = new TJavaScriptLiteral($value); |
| 672 | 667 | return $this->$setter($value); |
| 673 | - } |
|
| 674 | - elseif(method_exists($this, $jssetter = 'setjs' . $name)) |
|
| 668 | + } elseif(method_exists($this, $jssetter = 'setjs' . $name)) |
|
| 675 | 669 | { |
| 676 | 670 | if($value && !($value instanceof TJavaScriptString)) |
| 677 | 671 | $value = new TJavaScriptString($value); |
| 678 | 672 | return $this->$jssetter($value); |
| 679 | - } |
|
| 680 | - elseif((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0) |
|
| 673 | + } elseif((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0) |
|
| 681 | 674 | { |
| 682 | 675 | return $this->attachEventHandler($name, $value); |
| 683 | - } |
|
| 684 | - elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 676 | + } elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 685 | 677 | { |
| 686 | 678 | $sets = 0; |
| 687 | 679 | foreach($this->_m->toArray() as $behavior) |
@@ -699,8 +691,7 @@ discard block |
||
| 699 | 691 | if(method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) |
| 700 | 692 | { |
| 701 | 693 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
| 702 | - } |
|
| 703 | - else |
|
| 694 | + } else |
|
| 704 | 695 | { |
| 705 | 696 | throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
| 706 | 697 | } |
@@ -728,13 +719,11 @@ discard block |
||
| 728 | 719 | { |
| 729 | 720 | $name = strtolower($name); |
| 730 | 721 | return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
| 731 | - } |
|
| 732 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 722 | + } elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 733 | 723 | { |
| 734 | 724 | $name = strtolower($name); |
| 735 | 725 | return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
| 736 | - } |
|
| 737 | - elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 726 | + } elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 738 | 727 | { |
| 739 | 728 | if(isset($this->_m[$name])) |
| 740 | 729 | return true; |
@@ -744,8 +733,7 @@ discard block |
||
| 744 | 733 | return isset($behavior->$name); |
| 745 | 734 | } |
| 746 | 735 | |
| 747 | - } |
|
| 748 | - else |
|
| 736 | + } else |
|
| 749 | 737 | return false; |
| 750 | 738 | } |
| 751 | 739 | |
@@ -959,15 +947,13 @@ discard block |
||
| 959 | 947 | if(!isset($this->_e[$name])) |
| 960 | 948 | $this->_e[$name] = new TPriorityList; |
| 961 | 949 | return $this->_e[$name]; |
| 962 | - } |
|
| 963 | - elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 950 | + } elseif(strncasecmp($name, 'fx', 2) === 0) |
|
| 964 | 951 | { |
| 965 | 952 | $name = strtolower($name); |
| 966 | 953 | if(!isset(self::$_ue[$name])) |
| 967 | 954 | self::$_ue[$name] = new TPriorityList; |
| 968 | 955 | return self::$_ue[$name]; |
| 969 | - } |
|
| 970 | - elseif($this->_m !== null && $this->_behaviorsenabled) |
|
| 956 | + } elseif($this->_m !== null && $this->_behaviorsenabled) |
|
| 971 | 957 | { |
| 972 | 958 | foreach($this->_m->toArray() as $behavior) |
| 973 | 959 | { |
@@ -1046,8 +1032,7 @@ discard block |
||
| 1046 | 1032 | { |
| 1047 | 1033 | $this->getEventHandlers($name)->remove($handler, $priority); |
| 1048 | 1034 | return true; |
| 1049 | - } |
|
| 1050 | - catch(\Exception $e) |
|
| 1035 | + } catch(\Exception $e) |
|
| 1051 | 1036 | { |
| 1052 | 1037 | } |
| 1053 | 1038 | } |
@@ -1170,14 +1155,11 @@ discard block |
||
| 1170 | 1155 | $response = $object->__dycall($name, [$sender,$param,$name]); |
| 1171 | 1156 | else |
| 1172 | 1157 | $response = $object->$method($sender, $param, $name); |
| 1173 | - } |
|
| 1174 | - else |
|
| 1158 | + } else |
|
| 1175 | 1159 | throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler); |
| 1176 | - } |
|
| 1177 | - else |
|
| 1160 | + } else |
|
| 1178 | 1161 | $response = call_user_func($handler, $sender, $param, $name); |
| 1179 | - } |
|
| 1180 | - elseif(is_callable($handler, true)) |
|
| 1162 | + } elseif(is_callable($handler, true)) |
|
| 1181 | 1163 | { |
| 1182 | 1164 | list($object, $method) = $handler; |
| 1183 | 1165 | if(is_string($object)) |
@@ -1195,12 +1177,10 @@ discard block |
||
| 1195 | 1177 | $response = $object->__dycall($name, [$sender,$param,$name]); |
| 1196 | 1178 | else |
| 1197 | 1179 | $response = $object->$method($sender, $param, $name); |
| 1198 | - } |
|
| 1199 | - else |
|
| 1180 | + } else |
|
| 1200 | 1181 | throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]); |
| 1201 | 1182 | } |
| 1202 | - } |
|
| 1203 | - else |
|
| 1183 | + } else |
|
| 1204 | 1184 | throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, gettype($handler)); |
| 1205 | 1185 | |
| 1206 | 1186 | $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
@@ -1217,8 +1197,7 @@ discard block |
||
| 1217 | 1197 | $param = $response; |
| 1218 | 1198 | |
| 1219 | 1199 | } |
| 1220 | - } |
|
| 1221 | - elseif(strncasecmp($name, 'on', 2) === 0 && !$this->hasEvent($name)) |
|
| 1200 | + } elseif(strncasecmp($name, 'on', 2) === 0 && !$this->hasEvent($name)) |
|
| 1222 | 1201 | throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
| 1223 | 1202 | |
| 1224 | 1203 | if($responsetype & TEventResults::EVENT_RESULT_FILTER) |
@@ -1254,8 +1233,7 @@ discard block |
||
| 1254 | 1233 | if(eval("\$result=$expression;") === false) |
| 1255 | 1234 | throw new \Exception(''); |
| 1256 | 1235 | return $result; |
| 1257 | - } |
|
| 1258 | - catch(\Exception $e) |
|
| 1236 | + } catch(\Exception $e) |
|
| 1259 | 1237 | { |
| 1260 | 1238 | throw new TInvalidOperationException('component_expression_invalid', get_class($this), $expression, $e->getMessage()); |
| 1261 | 1239 | } |
@@ -1289,8 +1267,7 @@ discard block |
||
| 1289 | 1267 | $content = ob_get_contents(); |
| 1290 | 1268 | ob_end_clean(); |
| 1291 | 1269 | return $content; |
| 1292 | - } |
|
| 1293 | - catch(\Exception $e) |
|
| 1270 | + } catch(\Exception $e) |
|
| 1294 | 1271 | { |
| 1295 | 1272 | throw new TInvalidOperationException('component_statements_invalid', get_class($this), $statements, $e->getMessage()); |
| 1296 | 1273 | } |
@@ -27,11 +27,14 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Attaches the behavior object to the component. |
| 29 | 29 | * @param CComponent the component that this behavior is to be attached to. |
| 30 | + * @param \Prado\TComponent $component |
|
| 31 | + * @return void |
|
| 30 | 32 | */ |
| 31 | 33 | public function attach($component); |
| 32 | 34 | /** |
| 33 | 35 | * Detaches the behavior object from the component. |
| 34 | 36 | * @param CComponent the component that this behavior is to be detached from. |
| 37 | + * @return void |
|
| 35 | 38 | */ |
| 36 | 39 | public function detach($component); |
| 37 | 40 | } |
| 38 | 41 | \ No newline at end of file |
@@ -34,6 +34,8 @@ |
||
| 34 | 34 | public function getEnabled(); |
| 35 | 35 | /** |
| 36 | 36 | * @param boolean whether this behavior is enabled |
| 37 | + * @param boolean $value |
|
| 38 | + * @return void |
|
| 37 | 39 | */ |
| 38 | 40 | public function setEnabled($value); |
| 39 | 41 | } |
| 40 | 42 | \ No newline at end of file |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * @return rpc server instance |
|
| 80 | + * @return TRpcServer server instance |
|
| 81 | 81 | */ |
| 82 | 82 | public function getRpcServer() |
| 83 | 83 | { |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | */ |
| 62 | 62 | public function __construct(TRpcServer $rpcServer) |
| 63 | 63 | { |
| 64 | - $this->rpcServer = $rpcServer; |
|
| 64 | + $this->rpcServer=$rpcServer; |
|
| 65 | 65 | |
| 66 | 66 | foreach($this->registerMethods() as $_methodName => $_methodDetails) |
| 67 | 67 | $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |