@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @param string the request IP address |
30 | 30 | * @return boolean whether the user is allowed |
31 | 31 | */ |
32 | - public function isUserAllowed($user,$verb,$ip) |
|
32 | + public function isUserAllowed($user, $verb, $ip) |
|
33 | 33 | { |
34 | 34 | if($user instanceof IUser) |
35 | 35 | { |
36 | 36 | $verb=strtolower(trim($verb)); |
37 | 37 | foreach($this as $rule) |
38 | 38 | { |
39 | - if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0) |
|
40 | - return ($decision>0); |
|
39 | + if(($decision=$rule->isUserAllowed($user, $verb, $ip))!==0) |
|
40 | + return ($decision > 0); |
|
41 | 41 | } |
42 | 42 | return true; |
43 | 43 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param mixed new item |
54 | 54 | * @throws TInvalidDataTypeException if the item to be inserted is not a TAuthorizationRule object. |
55 | 55 | */ |
56 | - public function insertAt($index,$item) |
|
56 | + public function insertAt($index, $item) |
|
57 | 57 | { |
58 | 58 | if($item instanceof TAuthorizationRule) |
59 | - parent::insertAt($index,$item); |
|
59 | + parent::insertAt($index, $item); |
|
60 | 60 | else |
61 | 61 | throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required'); |
62 | 62 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
116 | 116 | { |
117 | - $userFile = include $this->_userFile; |
|
117 | + $userFile=include $this->_userFile; |
|
118 | 118 | $this->loadUserDataFromPhp($userFile); |
119 | 119 | } |
120 | 120 | else |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | { |
150 | 150 | foreach($config['users'] as $user) |
151 | 151 | { |
152 | - $name = trim(strtolower(isset($user['name'])?$user['name']:'')); |
|
153 | - $password = isset($user['password'])?$user['password']:''; |
|
154 | - $this->_users[$name] = $password; |
|
155 | - $roles = isset($user['roles'])?$user['roles']:''; |
|
152 | + $name=trim(strtolower(isset($user['name']) ? $user['name'] : '')); |
|
153 | + $password=isset($user['password']) ? $user['password'] : ''; |
|
154 | + $this->_users[$name]=$password; |
|
155 | + $roles=isset($user['roles']) ? $user['roles'] : ''; |
|
156 | 156 | if($roles!=='') |
157 | 157 | { |
158 | - foreach(explode(',',$roles) as $role) |
|
158 | + foreach(explode(',', $roles) as $role) |
|
159 | 159 | { |
160 | 160 | if(($role=trim($role))!=='') |
161 | 161 | $this->_roles[$name][]=$role; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | { |
168 | 168 | foreach($config['roles'] as $role) |
169 | 169 | { |
170 | - $name = isset($role['name'])?$role['name']:''; |
|
171 | - $users = isset($role['users'])?$role['users']:''; |
|
172 | - foreach(explode(',',$users) as $user) |
|
170 | + $name=isset($role['name']) ? $role['name'] : ''; |
|
171 | + $users=isset($role['users']) ? $role['users'] : ''; |
|
172 | + foreach(explode(',', $users) as $user) |
|
173 | 173 | { |
174 | 174 | if(($user=trim($user))!=='') |
175 | 175 | $this->_roles[strtolower($user)][]=$name; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $this->_users[$name]=$node->getAttribute('password'); |
191 | 191 | if(($roles=trim($node->getAttribute('roles')))!=='') |
192 | 192 | { |
193 | - foreach(explode(',',$roles) as $role) |
|
193 | + foreach(explode(',', $roles) as $role) |
|
194 | 194 | { |
195 | 195 | if(($role=trim($role))!=='') |
196 | 196 | $this->_roles[$name][]=$role; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | foreach($xmlNode->getElementsByTagName('role') as $node) |
201 | 201 | { |
202 | - foreach(explode(',',$node->getAttribute('users')) as $user) |
|
202 | + foreach(explode(',', $node->getAttribute('users')) as $user) |
|
203 | 203 | { |
204 | 204 | if(($user=trim($user))!=='') |
205 | 205 | $this->_roles[strtolower($user)][]=$node->getAttribute('name'); |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | { |
250 | 250 | if($this->_initialized) |
251 | 251 | throw new TInvalidOperationException('usermanager_userfile_unchangeable'); |
252 | - else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile)) |
|
253 | - throw new TConfigurationException('usermanager_userfile_invalid',$value); |
|
252 | + else if(($this->_userFile=Prado::getPathOfNamespace($value, self::USER_FILE_EXT))===null || !is_file($this->_userFile)) |
|
253 | + throw new TConfigurationException('usermanager_userfile_invalid', $value); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function setPasswordMode($value) |
284 | 284 | { |
285 | - $this->_passwordMode=TPropertyValue::ensureEnum($value,'Prado\\Security\\TUserManagerPasswordMode'); |
|
285 | + $this->_passwordMode=TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param string password |
292 | 292 | * @return boolean true if validation is successful, false otherwise. |
293 | 293 | */ |
294 | - public function validateUser($username,$password) |
|
294 | + public function validateUser($username, $password) |
|
295 | 295 | { |
296 | 296 | if($this->_passwordMode===TUserManagerPasswordMode::MD5) |
297 | 297 | $password=md5($password); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $data=unserialize($data); |
345 | 345 | if(is_array($data) && count($data)===2) |
346 | 346 | { |
347 | - list($username,$token)=$data; |
|
347 | + list($username, $token)=$data; |
|
348 | 348 | if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username])) |
349 | 349 | return $this->getUser($username); |
350 | 350 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $username=strtolower($user->getName()); |
364 | 364 | if(isset($this->_users[$username])) |
365 | 365 | { |
366 | - $data=array($username,md5($username.$this->_users[$username])); |
|
366 | + $data=array($username, md5($username.$this->_users[$username])); |
|
367 | 367 | $cookie->setValue(serialize($data)); |
368 | 368 | } |
369 | 369 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * @param string verb, can be empty, 'get', or 'post' |
75 | 75 | * @param string IP rules (separated by comma, can contain wild card *) |
76 | 76 | */ |
77 | - public function __construct($action,$users,$roles,$verb='',$ipRules='') |
|
77 | + public function __construct($action, $users, $roles, $verb='', $ipRules='') |
|
78 | 78 | { |
79 | 79 | $action=strtolower(trim($action)); |
80 | 80 | if($action==='allow' || $action==='deny') |
81 | 81 | $this->_action=$action; |
82 | 82 | else |
83 | - throw new TInvalidDataValueException('authorizationrule_action_invalid',$action); |
|
83 | + throw new TInvalidDataValueException('authorizationrule_action_invalid', $action); |
|
84 | 84 | $this->_users=array(); |
85 | 85 | $this->_roles=array(); |
86 | 86 | $this->_ipRules=array(); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | if(trim($users)==='') |
92 | 92 | $users='*'; |
93 | - foreach(explode(',',$users) as $user) |
|
93 | + foreach(explode(',', $users) as $user) |
|
94 | 94 | { |
95 | 95 | if(($user=trim(strtolower($user)))!=='') |
96 | 96 | { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | if(trim($roles)==='') |
112 | 112 | $roles='*'; |
113 | - foreach(explode(',',$roles) as $role) |
|
113 | + foreach(explode(',', $roles) as $role) |
|
114 | 114 | { |
115 | 115 | if(($role=trim(strtolower($role)))!=='') |
116 | 116 | $this->_roles[]=$role; |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | if($verb==='*' || $verb==='get' || $verb==='post') |
122 | 122 | $this->_verb=$verb; |
123 | 123 | else |
124 | - throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb); |
|
124 | + throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb); |
|
125 | 125 | |
126 | 126 | if(trim($ipRules)==='') |
127 | 127 | $ipRules='*'; |
128 | - foreach(explode(',',$ipRules) as $ipRule) |
|
128 | + foreach(explode(',', $ipRules) as $ipRule) |
|
129 | 129 | { |
130 | 130 | if(($ipRule=trim($ipRule))!=='') |
131 | 131 | $this->_ipRules[]=$ipRule; |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | * @param string the request IP address |
204 | 204 | * @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user |
205 | 205 | */ |
206 | - public function isUserAllowed(IUser $user,$verb,$ip) |
|
206 | + public function isUserAllowed(IUser $user, $verb, $ip) |
|
207 | 207 | { |
208 | 208 | if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) |
209 | - return ($this->_action==='allow')?1:-1; |
|
209 | + return ($this->_action==='allow') ? 1 : -1; |
|
210 | 210 | else |
211 | 211 | return 0; |
212 | 212 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | return 1; |
218 | 218 | foreach($this->_ipRules as $rule) |
219 | 219 | { |
220 | - if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) |
|
220 | + if($rule==='*' || $rule===$ip || (($pos=strpos($rule, '*'))!==false && strncmp($ip, $rule, $pos)===0)) |
|
221 | 221 | return 1; |
222 | 222 | } |
223 | 223 | return 0; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | private function isUserMatched($user) |
227 | 227 | { |
228 | - return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users)); |
|
228 | + return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()), $this->_users)); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | private function isRoleMatched($user) |
@@ -240,6 +240,6 @@ discard block |
||
240 | 240 | |
241 | 241 | private function isVerbMatched($verb) |
242 | 242 | { |
243 | - return ($this->_verb==='*' || strcasecmp($verb,$this->_verb)===0); |
|
243 | + return ($this->_verb==='*' || strcasecmp($verb, $this->_verb)===0); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | \ No newline at end of file |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | { |
63 | 63 | if($this->_userClass==='') |
64 | 64 | throw new TConfigurationException('dbusermanager_userclass_required'); |
65 | - $this->_userFactory=Prado::createComponent($this->_userClass,$this); |
|
65 | + $this->_userFactory=Prado::createComponent($this->_userClass, $this); |
|
66 | 66 | if(!($this->_userFactory instanceof TDbUser)) |
67 | - throw new TInvalidDataTypeException('dbusermanager_userclass_invalid',$this->_userClass); |
|
67 | + throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string password |
106 | 106 | * @return boolean true if validation is successful, false otherwise. |
107 | 107 | */ |
108 | - public function validateUser($username,$password) |
|
108 | + public function validateUser($username, $password) |
|
109 | 109 | { |
110 | - return $this->_userFactory->validateUser($username,$password); |
|
110 | + return $this->_userFactory->validateUser($username, $password); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | if($username===null) |
121 | 121 | { |
122 | - $user=Prado::createComponent($this->_userClass,$this); |
|
122 | + $user=Prado::createComponent($this->_userClass, $this); |
|
123 | 123 | $user->setIsGuest(true); |
124 | 124 | return $user; |
125 | 125 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | if($conn instanceof TDataSourceConfig) |
174 | 174 | return $conn->getDbConnection(); |
175 | 175 | else |
176 | - throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID); |
|
176 | + throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID); |
|
177 | 177 | } |
178 | 178 | else |
179 | 179 | throw new TConfigurationException('dbusermanager_connectionid_required'); |
@@ -42,6 +42,6 @@ |
||
42 | 42 | */ |
43 | 43 | public function setIsValid($value) |
44 | 44 | { |
45 | - $this->_isValid = TPropertyValue::ensureBoolean($value); |
|
45 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function getRecordTableName(TActiveRecord $record) |
72 | 72 | { |
73 | - $class = new ReflectionClass($record); |
|
73 | + $class=new ReflectionClass($record); |
|
74 | 74 | if($class->hasConstant(self::TABLE_CONST)) |
75 | 75 | { |
76 | - $value = $class->getConstant(self::TABLE_CONST); |
|
76 | + $value=$class->getConstant(self::TABLE_CONST); |
|
77 | 77 | if(empty($value)) |
78 | 78 | throw new TActiveRecordException('ar_invalid_tablename_property', |
79 | - get_class($record),self::TABLE_CONST); |
|
79 | + get_class($record), self::TABLE_CONST); |
|
80 | 80 | return $value; |
81 | 81 | } |
82 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
82 | + elseif($class->hasMethod(self::TABLE_METHOD)) |
|
83 | 83 | { |
84 | - $value = $record->{self::TABLE_METHOD}(); |
|
84 | + $value=$record->{self::TABLE_METHOD}(); |
|
85 | 85 | if(empty($value)) |
86 | 86 | throw new TActiveRecordException('ar_invalid_tablename_method', |
87 | - get_class($record),self::TABLE_METHOD); |
|
87 | + get_class($record), self::TABLE_METHOD); |
|
88 | 88 | return $value; |
89 | 89 | } |
90 | 90 | else |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getRecordTableInfo(TActiveRecord $record) |
100 | 100 | { |
101 | - $tableName = $this->getRecordTableName($record); |
|
101 | + $tableName=$this->getRecordTableName($record); |
|
102 | 102 | return $this->getTableInfo($record->getDbConnection(), $tableName); |
103 | 103 | } |
104 | 104 | |
@@ -110,27 +110,27 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getTableInfo(TDbConnection $connection, $tableName) |
112 | 112 | { |
113 | - $connStr = $connection->getConnectionString(); |
|
114 | - $key = $connStr.$tableName; |
|
113 | + $connStr=$connection->getConnectionString(); |
|
114 | + $key=$connStr.$tableName; |
|
115 | 115 | if(!isset($this->_tables[$key])) |
116 | 116 | { |
117 | 117 | //call this first to ensure that unserializing the cache |
118 | 118 | //will find the correct driver dependent classes. |
119 | 119 | if(!isset($this->_meta[$connStr])) |
120 | 120 | { |
121 | - $this->_meta[$connStr] = TDbMetaData::getInstance($connection); |
|
121 | + $this->_meta[$connStr]=TDbMetaData::getInstance($connection); |
|
122 | 122 | } |
123 | 123 | |
124 | - $tableInfo = null; |
|
124 | + $tableInfo=null; |
|
125 | 125 | if(($cache=$this->getManager()->getCache())!==null) |
126 | - $tableInfo = $cache->get($key); |
|
126 | + $tableInfo=$cache->get($key); |
|
127 | 127 | if(empty($tableInfo)) |
128 | 128 | { |
129 | - $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); |
|
129 | + $tableInfo=$this->_meta[$connStr]->getTableInfo($tableName); |
|
130 | 130 | if($cache!==null) |
131 | 131 | $cache->set($key, $tableInfo); |
132 | 132 | } |
133 | - $this->_tables[$key] = $tableInfo; |
|
133 | + $this->_tables[$key]=$tableInfo; |
|
134 | 134 | } |
135 | 135 | return $this->_tables[$key]; |
136 | 136 | } |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function getCommand(TActiveRecord $record) |
143 | 143 | { |
144 | - $conn = $record->getDbConnection(); |
|
145 | - $connStr = $conn->getConnectionString(); |
|
146 | - $tableInfo = $this->getRecordTableInfo($record); |
|
144 | + $conn=$record->getDbConnection(); |
|
145 | + $connStr=$conn->getConnectionString(); |
|
146 | + $tableInfo=$this->getRecordTableInfo($record); |
|
147 | 147 | if(!isset($this->_commandBuilders[$connStr])) |
148 | 148 | { |
149 | - $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); |
|
150 | - $command = new TDataGatewayCommand($builder); |
|
151 | - $command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
152 | - $command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
153 | - $this->_commandBuilders[$connStr] = $command; |
|
149 | + $builder=$tableInfo->createCommandBuilder($record->getDbConnection()); |
|
150 | + $command=new TDataGatewayCommand($builder); |
|
151 | + $command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
152 | + $command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
153 | + $this->_commandBuilders[$connStr]=$command; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @param array primary name value pairs |
201 | 201 | * @return array record data |
202 | 202 | */ |
203 | - public function findRecordByPK(TActiveRecord $record,$keys) |
|
203 | + public function findRecordByPK(TActiveRecord $record, $keys) |
|
204 | 204 | { |
205 | - $command = $this->getCommand($record); |
|
205 | + $command=$this->getCommand($record); |
|
206 | 206 | return $command->findByPk($keys); |
207 | 207 | } |
208 | 208 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false) |
230 | 230 | { |
231 | - $command = $this->getCommand($record); |
|
231 | + $command=$this->getCommand($record); |
|
232 | 232 | return $iterator ? $command->findAll($criteria) : $command->find($criteria); |
233 | 233 | } |
234 | 234 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values) |
258 | 258 | { |
259 | - return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values); |
|
259 | + return $this->getCommand($record)->findAllByIndex($criteria, $fields, $values); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function insert(TActiveRecord $record) |
279 | 279 | { |
280 | 280 | //$this->updateAssociatedRecords($record,true); |
281 | - $result = $this->getCommand($record)->insert($this->getInsertValues($record)); |
|
281 | + $result=$this->getCommand($record)->insert($this->getInsertValues($record)); |
|
282 | 282 | if($result) |
283 | 283 | $this->updatePostInsert($record); |
284 | 284 | //$this->updateAssociatedRecords($record); |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | */ |
292 | 292 | protected function updatePostInsert($record) |
293 | 293 | { |
294 | - $command = $this->getCommand($record); |
|
295 | - $tableInfo = $command->getTableInfo(); |
|
294 | + $command=$this->getCommand($record); |
|
295 | + $tableInfo=$command->getTableInfo(); |
|
296 | 296 | foreach($tableInfo->getColumns() as $name => $column) |
297 | 297 | { |
298 | 298 | if($column->hasSequence()) |
299 | - $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName())); |
|
299 | + $record->setColumnValue($name, $command->getLastInsertID($column->getSequenceName())); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -307,20 +307,20 @@ discard block |
||
307 | 307 | protected function getInsertValues(TActiveRecord $record) |
308 | 308 | { |
309 | 309 | $values=array(); |
310 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
310 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
311 | 311 | foreach($tableInfo->getColumns() as $name=>$column) |
312 | 312 | { |
313 | 313 | if($column->getIsExcluded()) |
314 | 314 | continue; |
315 | - $value = $record->getColumnValue($name); |
|
316 | - if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
315 | + $value=$record->getColumnValue($name); |
|
316 | + if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
317 | 317 | { |
318 | 318 | throw new TActiveRecordException( |
319 | 319 | 'ar_value_must_not_be_null', get_class($record), |
320 | 320 | $tableInfo->getTableFullName(), $name); |
321 | 321 | } |
322 | 322 | if($value!==null) |
323 | - $values[$name] = $value; |
|
323 | + $values[$name]=$value; |
|
324 | 324 | } |
325 | 325 | return $values; |
326 | 326 | } |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | public function update(TActiveRecord $record) |
334 | 334 | { |
335 | 335 | //$this->updateAssociatedRecords($record,true); |
336 | - list($data, $keys) = $this->getUpdateValues($record); |
|
337 | - $result = $this->getCommand($record)->updateByPk($data, $keys); |
|
336 | + list($data, $keys)=$this->getUpdateValues($record); |
|
337 | + $result=$this->getCommand($record)->updateByPk($data, $keys); |
|
338 | 338 | //$this->updateAssociatedRecords($record); |
339 | 339 | return $result; |
340 | 340 | } |
@@ -342,30 +342,30 @@ discard block |
||
342 | 342 | protected function getUpdateValues(TActiveRecord $record) |
343 | 343 | { |
344 | 344 | $values=array(); |
345 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
345 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
346 | 346 | $primary=array(); |
347 | 347 | foreach($tableInfo->getColumns() as $name=>$column) |
348 | 348 | { |
349 | 349 | if($column->getIsExcluded()) |
350 | 350 | continue; |
351 | - $value = $record->getColumnValue($name); |
|
352 | - if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
351 | + $value=$record->getColumnValue($name); |
|
352 | + if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
353 | 353 | { |
354 | 354 | throw new TActiveRecordException( |
355 | 355 | 'ar_value_must_not_be_null', get_class($record), |
356 | 356 | $tableInfo->getTableFullName(), $name); |
357 | 357 | } |
358 | 358 | if($column->getIsPrimaryKey()) |
359 | - $primary[$name] = $value; |
|
359 | + $primary[$name]=$value; |
|
360 | 360 | else |
361 | - $values[$name] = $value; |
|
361 | + $values[$name]=$value; |
|
362 | 362 | } |
363 | - return array($values,$primary); |
|
363 | + return array($values, $primary); |
|
364 | 364 | } |
365 | 365 | |
366 | - protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false) |
|
366 | + protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo=false) |
|
367 | 367 | { |
368 | - $context = new TActiveRecordRelationContext($record); |
|
368 | + $context=new TActiveRecordRelationContext($record); |
|
369 | 369 | return $context->updateAssociatedRecords($updateBelongsTo); |
370 | 370 | } |
371 | 371 | |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | protected function getPrimaryKeyValues(TActiveRecord $record) |
383 | 383 | { |
384 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
384 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
385 | 385 | $primary=array(); |
386 | 386 | foreach($tableInfo->getColumns() as $name=>$column) |
387 | 387 | { |
388 | 388 | if($column->getIsPrimaryKey()) |
389 | - $primary[$name] = $record->getColumnValue($name); |
|
389 | + $primary[$name]=$record->getColumnValue($name); |
|
390 | 390 | } |
391 | 391 | return $primary; |
392 | 392 | } |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | * @param TActiveRecord active record |
420 | 420 | * @param TActiveRecordCriteria data for the command. |
421 | 421 | */ |
422 | - protected function raiseCommandEvent($event,$command,$record,$criteria) |
|
422 | + protected function raiseCommandEvent($event, $command, $record, $criteria) |
|
423 | 423 | { |
424 | 424 | if(!($criteria instanceof TSqlCriteria)) |
425 | - $criteria = new TActiveRecordCriteria(null,$criteria); |
|
426 | - $param = new TActiveRecordEventParameter($command,$record,$criteria); |
|
427 | - $manager = $record->getRecordManager(); |
|
425 | + $criteria=new TActiveRecordCriteria(null, $criteria); |
|
426 | + $param=new TActiveRecordEventParameter($command, $record, $criteria); |
|
427 | + $manager=$record->getRecordManager(); |
|
428 | 428 | $manager->{$event}($param); |
429 | 429 | $record->{$event}($param); |
430 | 430 | } |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class TActiveRecordManager extends \Prado\TComponent |
38 | 38 | { |
39 | - const DEFAULT_GATEWAY_CLASS = 'System.Data.ActiveRecord.TActiveRecordGateway'; |
|
39 | + const DEFAULT_GATEWAY_CLASS='System.Data.ActiveRecord.TActiveRecordGateway'; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Defaults to {@link TActiveRecordManager::DEFAULT_GATEWAY_CLASS DEFAULT_GATEWAY_CLASS} |
43 | 43 | * @var string |
44 | 44 | */ |
45 | - private $_gatewayClass = self::DEFAULT_GATEWAY_CLASS; |
|
45 | + private $_gatewayClass=self::DEFAULT_GATEWAY_CLASS; |
|
46 | 46 | |
47 | 47 | private $_gateway; |
48 | 48 | private $_meta=array(); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @var TActiveRecordInvalidFinderResult |
57 | 57 | * @since 3.1.5 |
58 | 58 | */ |
59 | - private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null; |
|
59 | + private $_invalidFinderResult=TActiveRecordInvalidFinderResult::Null; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return ICache application cache. |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if($self!==null) |
100 | 100 | $instance=$self; |
101 | 101 | else if($instance===null) |
102 | - $instance = new self; |
|
102 | + $instance=new self; |
|
103 | 103 | return $instance; |
104 | 104 | } |
105 | 105 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getRecordGateway() |
110 | 110 | { |
111 | - if($this->_gateway === null) { |
|
112 | - $this->_gateway = $this->createRecordGateway(); |
|
111 | + if($this->_gateway===null) { |
|
112 | + $this->_gateway=$this->createRecordGateway(); |
|
113 | 113 | } |
114 | 114 | return $this->_gateway; |
115 | 115 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function setGatewayClass($value) |
130 | 130 | { |
131 | - $this->_gateway = null; |
|
132 | - $this->_gatewayClass = (string)$value; |
|
131 | + $this->_gateway=null; |
|
132 | + $this->_gatewayClass=(string) $value; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -158,6 +158,6 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function setInvalidFinderResult($value) |
160 | 160 | { |
161 | - $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'Prado\\Data\\ActiveRecord\\TActiveRecordInvalidFinderResult'); |
|
161 | + $this->_invalidFinderResult=TPropertyValue::ensureEnum($value, 'Prado\\Data\\ActiveRecord\\TActiveRecordInvalidFinderResult'); |
|
162 | 162 | } |
163 | 163 | } |
@@ -74,25 +74,25 @@ discard block |
||
74 | 74 | */ |
75 | 75 | class TActiveRecordConfig extends TDataSourceConfig |
76 | 76 | { |
77 | - const DEFAULT_MANAGER_CLASS = 'System.Data.ActiveRecord.TActiveRecordManager'; |
|
78 | - const DEFAULT_GATEWAY_CLASS = 'System.Data.ActiveRecord.TActiveRecordGateway'; |
|
77 | + const DEFAULT_MANAGER_CLASS='System.Data.ActiveRecord.TActiveRecordManager'; |
|
78 | + const DEFAULT_GATEWAY_CLASS='System.Data.ActiveRecord.TActiveRecordGateway'; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Defaults to {@link TActiveRecordConfig::DEFAULT_GATEWAY_CLASS DEFAULT_MANAGER_CLASS} |
82 | 82 | * @var string |
83 | 83 | */ |
84 | - private $_managerClass = self::DEFAULT_MANAGER_CLASS; |
|
84 | + private $_managerClass=self::DEFAULT_MANAGER_CLASS; |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Defaults to {@link TActiveRecordConfig::DEFAULT_GATEWAY_CLASS DEFAULT_GATEWAY_CLASS} |
88 | 88 | * @var string |
89 | 89 | */ |
90 | - private $_gatewayClass = self::DEFAULT_GATEWAY_CLASS; |
|
90 | + private $_gatewayClass=self::DEFAULT_GATEWAY_CLASS; |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @var TActiveRecordManager |
94 | 94 | */ |
95 | - private $_manager = null; |
|
95 | + private $_manager=null; |
|
96 | 96 | |
97 | 97 | private $_enableCache=false; |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @var TActiveRecordInvalidFinderResult |
103 | 103 | * @since 3.1.5 |
104 | 104 | */ |
105 | - private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null; |
|
105 | + private $_invalidFinderResult=TActiveRecordInvalidFinderResult::Null; |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Initialize the active record manager. |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function init($xml) |
112 | 112 | { |
113 | 113 | parent::init($xml); |
114 | - $manager = $this -> getManager(); |
|
114 | + $manager=$this -> getManager(); |
|
115 | 115 | if($this->getEnableCache()) |
116 | 116 | $manager->setCache($this->getApplication()->getCache()); |
117 | 117 | $manager->setDbConnection($this->getDbConnection()); |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @return TActiveRecordManager |
124 | 124 | */ |
125 | 125 | public function getManager() { |
126 | - if($this->_manager === null) |
|
127 | - $this->_manager = Prado::createComponent($this -> getManagerClass()); |
|
126 | + if($this->_manager===null) |
|
127 | + $this->_manager=Prado::createComponent($this -> getManagerClass()); |
|
128 | 128 | return TActiveRecordManager::getInstance($this->_manager); |
129 | 129 | } |
130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function setManagerClass($value) |
136 | 136 | { |
137 | - $this->_managerClass = TPropertyValue::ensureString($value); |
|
137 | + $this->_managerClass=TPropertyValue::ensureString($value); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function setGatewayClass($value) |
153 | 153 | { |
154 | - $this->_gatewayClass = TPropertyValue::ensureString($value); |
|
154 | + $this->_gatewayClass=TPropertyValue::ensureString($value); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function setEnableCache($value) |
170 | 170 | { |
171 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
171 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -198,6 +198,6 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function setInvalidFinderResult($value) |
200 | 200 | { |
201 | - $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'Prado\\Data\\ActiveRecord\\TActiveRecordInvalidFinderResult'); |
|
201 | + $this->_invalidFinderResult=TPropertyValue::ensureEnum($value, 'Prado\\Data\\ActiveRecord\\TActiveRecordInvalidFinderResult'); |
|
202 | 202 | } |
203 | 203 | } |
@@ -29,6 +29,6 @@ |
||
29 | 29 | */ |
30 | 30 | class TActiveRecordInvalidFinderResult extends \Prado\TEnumerable |
31 | 31 | { |
32 | - const Null = 'Null'; |
|
33 | - const Exception = 'Exception'; |
|
32 | + const Null='Null'; |
|
33 | + const Exception='Exception'; |
|
34 | 34 | } |
35 | 35 | \ No newline at end of file |