Completed
Push — prado-3.3 ( f4da81...5dd4b5 )
by Fabio
09:03
created
framework/Data/ActiveRecord/TActiveRecordGateway.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -59,21 +59,21 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	protected function getRecordTableName(TActiveRecord $record)
61 61
 	{
62
-		$class = new ReflectionClass($record);
62
+		$class=new ReflectionClass($record);
63 63
 		if($class->hasConstant(self::TABLE_CONST))
64 64
 		{
65
-			$value = $class->getConstant(self::TABLE_CONST);
65
+			$value=$class->getConstant(self::TABLE_CONST);
66 66
 			if(empty($value))
67 67
 				throw new TActiveRecordException('ar_invalid_tablename_property',
68
-					get_class($record),self::TABLE_CONST);
68
+					get_class($record), self::TABLE_CONST);
69 69
 			return $value;
70 70
 		}
71
-		elseif ($class->hasMethod(self::TABLE_METHOD))
71
+		elseif($class->hasMethod(self::TABLE_METHOD))
72 72
 		{
73
-			$value = $record->{self::TABLE_METHOD}();
73
+			$value=$record->{self::TABLE_METHOD}();
74 74
 			if(empty($value))
75 75
 				throw new TActiveRecordException('ar_invalid_tablename_method',
76
-					get_class($record),self::TABLE_METHOD);
76
+					get_class($record), self::TABLE_METHOD);
77 77
 			return $value;
78 78
 		}
79 79
 		else
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function getRecordTableInfo(TActiveRecord $record)
89 89
 	{
90
-		$tableName = $this->getRecordTableName($record);
90
+		$tableName=$this->getRecordTableName($record);
91 91
 		return $this->getTableInfo($record->getDbConnection(), $tableName);
92 92
 	}
93 93
 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function getTableInfo(TDbConnection $connection, $tableName)
101 101
 	{
102
-		$connStr = $connection->getConnectionString();
103
-		$key = $connStr.$tableName;
102
+		$connStr=$connection->getConnectionString();
103
+		$key=$connStr.$tableName;
104 104
 		if(!isset($this->_tables[$key]))
105 105
 		{
106 106
 			//call this first to ensure that unserializing the cache
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 			if(!isset($this->_meta[$connStr]))
109 109
 			{
110 110
 				Prado::using('System.Data.Common.TDbMetaData');
111
-				$this->_meta[$connStr] = TDbMetaData::getInstance($connection);
111
+				$this->_meta[$connStr]=TDbMetaData::getInstance($connection);
112 112
 			}
113 113
 
114
-			$tableInfo = null;
114
+			$tableInfo=null;
115 115
 			if(($cache=$this->getManager()->getCache())!==null)
116
-				$tableInfo = $cache->get($key);
116
+				$tableInfo=$cache->get($key);
117 117
 			if(empty($tableInfo))
118 118
 			{
119
-				$tableInfo = $this->_meta[$connStr]->getTableInfo($tableName);
119
+				$tableInfo=$this->_meta[$connStr]->getTableInfo($tableName);
120 120
 				if($cache!==null)
121 121
 					$cache->set($key, $tableInfo);
122 122
 			}
123
-			$this->_tables[$key] = $tableInfo;
123
+			$this->_tables[$key]=$tableInfo;
124 124
 		}
125 125
 		return $this->_tables[$key];
126 126
 	}
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function getCommand(TActiveRecord $record)
133 133
 	{
134
-		$conn = $record->getDbConnection();
135
-		$connStr = $conn->getConnectionString();
136
-		$tableInfo = $this->getRecordTableInfo($record);
134
+		$conn=$record->getDbConnection();
135
+		$connStr=$conn->getConnectionString();
136
+		$tableInfo=$this->getRecordTableInfo($record);
137 137
 		if(!isset($this->_commandBuilders[$connStr]))
138 138
 		{
139
-			$builder = $tableInfo->createCommandBuilder($record->getDbConnection());
139
+			$builder=$tableInfo->createCommandBuilder($record->getDbConnection());
140 140
 			Prado::using('System.Data.DataGateway.TDataGatewayCommand');
141
-			$command = new TDataGatewayCommand($builder);
142
-			$command->OnCreateCommand[] = array($this, 'onCreateCommand');
143
-			$command->OnExecuteCommand[] = array($this, 'onExecuteCommand');
144
-			$this->_commandBuilders[$connStr] = $command;
141
+			$command=new TDataGatewayCommand($builder);
142
+			$command->OnCreateCommand[]=array($this, 'onCreateCommand');
143
+			$command->OnExecuteCommand[]=array($this, 'onExecuteCommand');
144
+			$this->_commandBuilders[$connStr]=$command;
145 145
 
146 146
 		}
147 147
 		$this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo);
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 	 * @param array primary name value pairs
192 192
 	 * @return array record data
193 193
 	 */
194
-	public function findRecordByPK(TActiveRecord $record,$keys)
194
+	public function findRecordByPK(TActiveRecord $record, $keys)
195 195
 	{
196
-		$command = $this->getCommand($record);
196
+		$command=$this->getCommand($record);
197 197
 		return $command->findByPk($keys);
198 198
 	}
199 199
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false)
221 221
 	{
222
-		$command = $this->getCommand($record);
222
+		$command=$this->getCommand($record);
223 223
 		return $iterator ? $command->findAll($criteria) : $command->find($criteria);
224 224
 	}
225 225
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 	public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values)
249 249
 	{
250
-		return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values);
250
+		return $this->getCommand($record)->findAllByIndex($criteria, $fields, $values);
251 251
 	}
252 252
 
253 253
 	/**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	public function insert(TActiveRecord $record)
270 270
 	{
271 271
 		//$this->updateAssociatedRecords($record,true);
272
-		$result = $this->getCommand($record)->insert($this->getInsertValues($record));
272
+		$result=$this->getCommand($record)->insert($this->getInsertValues($record));
273 273
 		if($result)
274 274
 			$this->updatePostInsert($record);
275 275
 		//$this->updateAssociatedRecords($record);
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	protected function updatePostInsert($record)
284 284
 	{
285
-		$command = $this->getCommand($record);
286
-		$tableInfo = $command->getTableInfo();
285
+		$command=$this->getCommand($record);
286
+		$tableInfo=$command->getTableInfo();
287 287
 		foreach($tableInfo->getColumns() as $name => $column)
288 288
 		{
289 289
 			if($column->hasSequence())
290
-				$record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName()));
290
+				$record->setColumnValue($name, $command->getLastInsertID($column->getSequenceName()));
291 291
 		}
292 292
 	}
293 293
 
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 	protected function getInsertValues(TActiveRecord $record)
299 299
 	{
300 300
 		$values=array();
301
-		$tableInfo = $this->getCommand($record)->getTableInfo();
301
+		$tableInfo=$this->getCommand($record)->getTableInfo();
302 302
 		foreach($tableInfo->getColumns() as $name=>$column)
303 303
 		{
304 304
 			if($column->getIsExcluded())
305 305
 				continue;
306
-			$value = $record->getColumnValue($name);
307
-			if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE))
306
+			$value=$record->getColumnValue($name);
307
+			if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE))
308 308
 			{
309 309
 				throw new TActiveRecordException(
310 310
 					'ar_value_must_not_be_null', get_class($record),
311 311
 					$tableInfo->getTableFullName(), $name);
312 312
 			}
313 313
 			if($value!==null)
314
-				$values[$name] = $value;
314
+				$values[$name]=$value;
315 315
 		}
316 316
 		return $values;
317 317
 	}
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	public function update(TActiveRecord $record)
325 325
 	{
326 326
 		//$this->updateAssociatedRecords($record,true);
327
-		list($data, $keys) = $this->getUpdateValues($record);
328
-		$result = $this->getCommand($record)->updateByPk($data, $keys);
327
+		list($data, $keys)=$this->getUpdateValues($record);
328
+		$result=$this->getCommand($record)->updateByPk($data, $keys);
329 329
 		//$this->updateAssociatedRecords($record);
330 330
 		return $result;
331 331
 	}
@@ -333,30 +333,30 @@  discard block
 block discarded – undo
333 333
 	protected function getUpdateValues(TActiveRecord $record)
334 334
 	{
335 335
 		$values=array();
336
-		$tableInfo = $this->getCommand($record)->getTableInfo();
336
+		$tableInfo=$this->getCommand($record)->getTableInfo();
337 337
 		$primary=array();
338 338
 		foreach($tableInfo->getColumns() as $name=>$column)
339 339
 		{
340 340
 			if($column->getIsExcluded())
341 341
 				continue;
342
-			$value = $record->getColumnValue($name);
343
-			if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE))
342
+			$value=$record->getColumnValue($name);
343
+			if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE))
344 344
 			{
345 345
 				throw new TActiveRecordException(
346 346
 					'ar_value_must_not_be_null', get_class($record),
347 347
 					$tableInfo->getTableFullName(), $name);
348 348
 			}
349 349
 			if($column->getIsPrimaryKey())
350
-				$primary[$name] = $value;
350
+				$primary[$name]=$value;
351 351
 			else
352
-				$values[$name] = $value;
352
+				$values[$name]=$value;
353 353
 		}
354
-		return array($values,$primary);
354
+		return array($values, $primary);
355 355
 	}
356 356
 
357
-	protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false)
357
+	protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo=false)
358 358
 	{
359
-		$context = new TActiveRecordRelationContext($record);
359
+		$context=new TActiveRecordRelationContext($record);
360 360
 		return $context->updateAssociatedRecords($updateBelongsTo);
361 361
 	}
362 362
 
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 
373 373
 	protected function getPrimaryKeyValues(TActiveRecord $record)
374 374
 	{
375
-		$tableInfo = $this->getCommand($record)->getTableInfo();
375
+		$tableInfo=$this->getCommand($record)->getTableInfo();
376 376
 		$primary=array();
377 377
 		foreach($tableInfo->getColumns() as $name=>$column)
378 378
 		{
379 379
 			if($column->getIsPrimaryKey())
380
-				$primary[$name] = $record->getColumnValue($name);
380
+				$primary[$name]=$record->getColumnValue($name);
381 381
 		}
382 382
 		return $primary;
383 383
 	}
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 	 * @param TActiveRecord active record
411 411
 	 * @param TActiveRecordCriteria data for the command.
412 412
 	 */
413
-	protected function raiseCommandEvent($event,$command,$record,$criteria)
413
+	protected function raiseCommandEvent($event, $command, $record, $criteria)
414 414
 	{
415 415
 		if(!($criteria instanceof TSqlCriteria))
416
-			$criteria = new TActiveRecordCriteria(null,$criteria);
417
-		$param = new TActiveRecordEventParameter($command,$record,$criteria);
418
-		$manager = $record->getRecordManager();
416
+			$criteria=new TActiveRecordCriteria(null, $criteria);
417
+		$param=new TActiveRecordEventParameter($command, $record, $criteria);
418
+		$manager=$record->getRecordManager();
419 419
 		$manager->{$event}($param);
420 420
 		$record->{$event}($param);
421 421
 	}
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/TActiveRecordManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class TActiveRecordManager extends TComponent
37 37
 {
38
-	const DEFAULT_GATEWAY_CLASS = 'System.Data.ActiveRecord.TActiveRecordGateway';
38
+	const DEFAULT_GATEWAY_CLASS='System.Data.ActiveRecord.TActiveRecordGateway';
39 39
 
40 40
 	/**
41 41
 	 * Defaults to {@link TActiveRecordManager::DEFAULT_GATEWAY_CLASS DEFAULT_GATEWAY_CLASS}
42 42
 	 * @var string
43 43
 	 */
44
-	private $_gatewayClass = self::DEFAULT_GATEWAY_CLASS;
44
+	private $_gatewayClass=self::DEFAULT_GATEWAY_CLASS;
45 45
 
46 46
 	private $_gateway;
47 47
 	private $_meta=array();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @var TActiveRecordInvalidFinderResult
56 56
 	 * @since 3.1.5
57 57
 	 */
58
-	private $_invalidFinderResult = TActiveRecordInvalidFinderResult::Null;
58
+	private $_invalidFinderResult=TActiveRecordInvalidFinderResult::Null;
59 59
 
60 60
 	/**
61 61
 	 * @return ICache application cache.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		if($self!==null)
99 99
 			$instance=$self;
100 100
 		else if($instance===null)
101
-			$instance = new self;
101
+			$instance=new self;
102 102
 		return $instance;
103 103
 	}
104 104
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getRecordGateway()
109 109
 	{
110
-		if($this->_gateway === null) {
111
-			$this->_gateway = $this->createRecordGateway();
110
+		if($this->_gateway===null) {
111
+			$this->_gateway=$this->createRecordGateway();
112 112
 		}
113 113
 		return $this->_gateway;
114 114
 	}
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function setGatewayClass($value)
129 129
 	{
130
-		$this->_gateway = null;
131
-		$this->_gatewayClass = (string)$value;
130
+		$this->_gateway=null;
131
+		$this->_gatewayClass=(string) $value;
132 132
 	}
133 133
 
134 134
 	/**
@@ -157,6 +157,6 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function setInvalidFinderResult($value)
159 159
 	{
160
-		$this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult');
160
+		$this->_invalidFinderResult=TPropertyValue::ensureEnum($value, 'TActiveRecordInvalidFinderResult');
161 161
 	}
162 162
 }
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	protected function collectForeignObjects(&$results)
79 79
 	{
80
-		$fkeys = $this->getRelationForeignKeys();
80
+		$fkeys=$this->getRelationForeignKeys();
81 81
 
82
-		$properties = array_keys($fkeys);
83
-		$fields = array_values($fkeys);
84
-		$indexValues = $this->getIndexValues($properties, $results);
85
-		$fkObjects = $this->findForeignObjects($fields, $indexValues);
86
-		$this->populateResult($results,$properties,$fkObjects,$fields);
82
+		$properties=array_keys($fkeys);
83
+		$fields=array_values($fkeys);
84
+		$indexValues=$this->getIndexValues($properties, $results);
85
+		$fkObjects=$this->findForeignObjects($fields, $indexValues);
86
+		$this->populateResult($results, $properties, $fkObjects, $fields);
87 87
 	}
88 88
 
89 89
 	/**
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function getRelationForeignKeys()
94 94
 	{
95
-		$fkObject = $this->getContext()->getForeignRecordFinder();
96
-		return $this->findForeignKeys($this->getSourceRecord(),$fkObject);
95
+		$fkObject=$this->getContext()->getForeignRecordFinder();
96
+		return $this->findForeignKeys($this->getSourceRecord(), $fkObject);
97 97
 	}
98 98
 
99 99
 	/**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	protected function setObjectProperty($source, $properties, &$collections)
105 105
 	{
106
-		$hash = $this->getObjectHash($source, $properties);
107
-		$prop = $this->getContext()->getProperty();
106
+		$hash=$this->getObjectHash($source, $properties);
107
+		$prop=$this->getContext()->getProperty();
108 108
 		if(isset($collections[$hash]) && count($collections[$hash]) > 0)
109 109
 		{
110 110
 			if(count($collections[$hash]) > 1)
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function updateAssociatedRecords()
123 123
 	{
124
-		$obj = $this->getContext()->getSourceRecord();
125
-		$fkObject = $obj->getColumnValue($this->getContext()->getProperty());
124
+		$obj=$this->getContext()->getSourceRecord();
125
+		$fkObject=$obj->getColumnValue($this->getContext()->getProperty());
126 126
 		if($fkObject!==null)
127 127
 		{
128 128
 			$fkObject->save();
129
-			$source = $this->getSourceRecord();
130
-			$fkeys = $this->findForeignKeys($source, $fkObject);
129
+			$source=$this->getSourceRecord();
130
+			$fkeys=$this->findForeignKeys($source, $fkObject);
131 131
 			foreach($fkeys as $srcKey => $fKey)
132 132
 				$source->setColumnValue($srcKey, $fkObject->getColumnValue($fKey));
133 133
 			return true;
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 	public function getPropertyValue()
50 50
 	{
51
-		$obj = $this->getSourceRecord();
51
+		$obj=$this->getSourceRecord();
52 52
 		return $obj->getColumnValue($this->getProperty());
53 53
 	}
54 54
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function getCondition()
113 113
 	{
114
-		return isset($this->_relation[3])?$this->_relation[3]:null;
114
+		return isset($this->_relation[3]) ? $this->_relation[3] : null;
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function getParameters()
122 122
 	{
123
-		return isset($this->_relation[4])?$this->_relation[4]:array();
123
+		return isset($this->_relation[4]) ? $this->_relation[4] : array();
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function hasFkField()
131 131
 	{
132
-		$notManyToMany = $this->getRelationType() !== TActiveRecord::MANY_TO_MANY;
132
+		$notManyToMany=$this->getRelationType()!==TActiveRecord::MANY_TO_MANY;
133 133
 		return $notManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]);
134 134
 	}
135 135
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function hasAssociationTable()
148 148
 	{
149
-		$isManyToMany = $this->getRelationType() === TActiveRecord::MANY_TO_MANY;
149
+		$isManyToMany=$this->getRelationType()===TActiveRecord::MANY_TO_MANY;
150 150
 		return $isManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]);
151 151
 	}
152 152
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				$this->_property, get_class($this->_record), 'RELATIONS');
175 175
 		}
176 176
 		if($criteria===null)
177
-			$criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
177
+			$criteria=new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
178 178
 		switch($this->getRelationType())
179 179
 		{
180 180
 			case TActiveRecord::HAS_MANY:
@@ -202,15 +202,15 @@  discard block
 block discarded – undo
202 202
 		$success=true;
203 203
 		foreach($this->_record->getRecordRelations() as $data)
204 204
 		{
205
-			list($property, $relation) = $data;
206
-			$belongsTo = $relation[0]==TActiveRecord::BELONGS_TO;
205
+			list($property, $relation)=$data;
206
+			$belongsTo=$relation[0]==TActiveRecord::BELONGS_TO;
207 207
 			if(($updateBelongsTo && $belongsTo) || (!$updateBelongsTo && !$belongsTo))
208 208
 			{
209
-				$obj = $this->getSourceRecord();
209
+				$obj=$this->getSourceRecord();
210 210
 				if(!$this->isEmptyFkObject($obj->getColumnValue($property)))
211 211
 				{
212
-					$context = new TActiveRecordRelationContext($this->getSourceRecord(),$property,$relation);
213
-					$success = $context->getRelationHandler()->updateAssociatedRecords() && $success;
212
+					$context=new TActiveRecordRelationContext($this->getSourceRecord(), $property, $relation);
213
+					$success=$context->getRelationHandler()->updateAssociatedRecords() && $success;
214 214
 				}
215 215
 			}
216 216
 		}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	protected function isEmptyFkObject($obj)
221 221
 	{
222 222
 		if(is_object($obj))
223
-			return $obj instanceof TList ? $obj->count() === 0 : false;
223
+			return $obj instanceof TList ? $obj->count()===0 : false;
224 224
 		else if(is_array($obj))
225 225
 			return count($obj)===0;
226 226
 		else
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	protected function collectForeignObjects(&$results)
77 77
 	{
78
-		$fkeys = $this->getRelationForeignKeys();
78
+		$fkeys=$this->getRelationForeignKeys();
79 79
 
80
-		$properties = array_values($fkeys);
81
-		$fields = array_keys($fkeys);
80
+		$properties=array_values($fkeys);
81
+		$fields=array_keys($fkeys);
82 82
 
83
-		$indexValues = $this->getIndexValues($properties, $results);
84
-		$fkObjects = $this->findForeignObjects($fields,$indexValues);
85
-		$this->populateResult($results,$properties,$fkObjects,$fields);
83
+		$indexValues=$this->getIndexValues($properties, $results);
84
+		$fkObjects=$this->findForeignObjects($fields, $indexValues);
85
+		$this->populateResult($results, $properties, $fkObjects, $fields);
86 86
 	}
87 87
 
88 88
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function getRelationForeignKeys()
93 93
 	{
94
-		$fkObject = $this->getContext()->getForeignRecordFinder();
94
+		$fkObject=$this->getContext()->getForeignRecordFinder();
95 95
 		return $this->findForeignKeys($fkObject, $this->getSourceRecord());
96 96
 	}
97 97
 
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function updateAssociatedRecords()
103 103
 	{
104
-		$obj = $this->getContext()->getSourceRecord();
105
-		$fkObjects = &$obj->{$this->getContext()->getProperty()};
104
+		$obj=$this->getContext()->getSourceRecord();
105
+		$fkObjects=&$obj->{$this->getContext()->getProperty()};
106 106
 		$success=true;
107
-		if(($total = count($fkObjects))> 0)
107
+		if(($total=count($fkObjects)) > 0)
108 108
 		{
109
-			$source = $this->getSourceRecord();
110
-			$fkeys = $this->findForeignKeys($fkObjects[0], $source);
111
-			for($i=0;$i<$total;$i++)
109
+			$source=$this->getSourceRecord();
110
+			$fkeys=$this->findForeignKeys($fkObjects[0], $source);
111
+			for($i=0; $i < $total; $i++)
112 112
 			{
113 113
 				foreach($fkeys as $fKey => $srcKey)
114 114
 					$fkObjects[$i]->setColumnValue($fKey, $source->getColumnValue($srcKey));
115
-				$success = $fkObjects[$i]->save() && $success;
115
+				$success=$fkObjects[$i]->save() && $success;
116 116
 			}
117 117
 		}
118 118
 		return $success;
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	*/
97 97
 	protected function collectForeignObjects(&$results)
98 98
 	{
99
-		list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys();
100
-		$properties = array_values($sourceKeys);
101
-		$indexValues = $this->getIndexValues($properties, $results);
102
-		$this->fetchForeignObjects($results, $foreignKeys,$indexValues,$sourceKeys);
99
+		list($sourceKeys, $foreignKeys)=$this->getRelationForeignKeys();
100
+		$properties=array_values($sourceKeys);
101
+		$indexValues=$this->getIndexValues($properties, $results);
102
+		$this->fetchForeignObjects($results, $foreignKeys, $indexValues, $sourceKeys);
103 103
 	}
104 104
 
105 105
 	/**
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getRelationForeignKeys()
109 109
 	{
110
-		$association = $this->getAssociationTable();
111
-		$sourceKeys = $this->findForeignKeys($association, $this->getSourceRecord(), true);
112
-		$fkObject = $this->getContext()->getForeignRecordFinder();
113
-		$foreignKeys = $this->findForeignKeys($association, $fkObject);
110
+		$association=$this->getAssociationTable();
111
+		$sourceKeys=$this->findForeignKeys($association, $this->getSourceRecord(), true);
112
+		$fkObject=$this->getContext()->getForeignRecordFinder();
113
+		$foreignKeys=$this->findForeignKeys($association, $fkObject);
114 114
 		return array($sourceKeys, $foreignKeys);
115 115
 	}
116 116
 
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	{
122 122
 		if($this->_association===null)
123 123
 		{
124
-			$gateway = $this->getSourceRecord()->getRecordGateway();
125
-			$conn = $this->getSourceRecord()->getDbConnection();
124
+			$gateway=$this->getSourceRecord()->getRecordGateway();
125
+			$conn=$this->getSourceRecord()->getDbConnection();
126 126
 			//table name may include the fk column name separated with a dot.
127
-			$table = explode('.', $this->getContext()->getAssociationTable());
128
-			if(count($table)>1)
127
+			$table=explode('.', $this->getContext()->getAssociationTable());
128
+			if(count($table) > 1)
129 129
 			{
130
-				$columns = preg_replace('/^\((.*)\)/', '\1', $table[1]);
131
-				$this->_association_columns = preg_split('/\s*[, ]\*/',$columns);
130
+				$columns=preg_replace('/^\((.*)\)/', '\1', $table[1]);
131
+				$this->_association_columns=preg_split('/\s*[, ]\*/', $columns);
132 132
 			}
133
-			$this->_association = $gateway->getTableInfo($conn, $table[0]);
133
+			$this->_association=$gateway->getTableInfo($conn, $table[0]);
134 134
 		}
135 135
 		return $this->_association;
136 136
 	}
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	{
143 143
 		if($this->_sourceTable===null)
144 144
 		{
145
-			$gateway = $this->getSourceRecord()->getRecordGateway();
146
-			$this->_sourceTable = $gateway->getRecordTableInfo($this->getSourceRecord());
145
+			$gateway=$this->getSourceRecord()->getRecordGateway();
146
+			$this->_sourceTable=$gateway->getRecordTableInfo($this->getSourceRecord());
147 147
 		}
148 148
 		return $this->_sourceTable;
149 149
 	}
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		if($this->_foreignTable===null)
157 157
 		{
158
-			$gateway = $this->getSourceRecord()->getRecordGateway();
159
-			$fkObject = $this->getContext()->getForeignRecordFinder();
160
-			$this->_foreignTable = $gateway->getRecordTableInfo($fkObject);
158
+			$gateway=$this->getSourceRecord()->getRecordGateway();
159
+			$fkObject=$this->getContext()->getForeignRecordFinder();
160
+			$this->_foreignTable=$gateway->getRecordTableInfo($fkObject);
161 161
 		}
162 162
 		return $this->_foreignTable;
163 163
 	}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function getForeignCommandBuilder()
177 177
 	{
178
-		$obj = $this->getContext()->getForeignRecordFinder();
178
+		$obj=$this->getContext()->getForeignRecordFinder();
179 179
 		return $this->getSourceRecord()->getRecordGateway()->getCommand($obj);
180 180
 	}
181 181
 
@@ -185,21 +185,21 @@  discard block
 block discarded – undo
185 185
 	 * @param array field names
186 186
 	 * @param array foreign key index values.
187 187
 	 */
188
-	protected function fetchForeignObjects(&$results,$foreignKeys,$indexValues,$sourceKeys)
188
+	protected function fetchForeignObjects(&$results, $foreignKeys, $indexValues, $sourceKeys)
189 189
 	{
190
-		$criteria = $this->getCriteria();
191
-		$finder = $this->getContext()->getForeignRecordFinder();
192
-		$type = get_class($finder);
193
-		$command = $this->createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys);
194
-		$srcProps = array_keys($sourceKeys);
190
+		$criteria=$this->getCriteria();
191
+		$finder=$this->getContext()->getForeignRecordFinder();
192
+		$type=get_class($finder);
193
+		$command=$this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys);
194
+		$srcProps=array_keys($sourceKeys);
195 195
 		$collections=array();
196 196
 		foreach($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row)
197 197
 		{
198
-			$hash = $this->getObjectHash($row, $srcProps);
198
+			$hash=$this->getObjectHash($row, $srcProps);
199 199
 			foreach($srcProps as $column)
200 200
 				unset($row[$column]);
201
-			$obj = $this->createFkObject($type,$row,$foreignKeys);
202
-			$collections[$hash][] = $obj;
201
+			$obj=$this->createFkObject($type, $row, $foreignKeys);
202
+			$collections[$hash][]=$obj;
203 203
 		}
204 204
 		$this->setResultCollection($results, $collections, array_values($sourceKeys));
205 205
 	}
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * @param array foreign key column names
211 211
 	 * @return TActiveRecord
212 212
 	 */
213
-	protected function createFkObject($type,$row,$foreignKeys)
213
+	protected function createFkObject($type, $row, $foreignKeys)
214 214
 	{
215
-		$obj = TActiveRecord::createRecord($type, $row);
215
+		$obj=TActiveRecord::createRecord($type, $row);
216 216
 		if(count($this->_association_columns) > 0)
217 217
 		{
218 218
 			$i=0;
@@ -228,22 +228,22 @@  discard block
 block discarded – undo
228 228
 	 * @param array field names
229 229
 	 * @param array field values
230 230
 	 */
231
-	public function createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys)
231
+	public function createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys)
232 232
 	{
233
-		$innerJoin = $this->getAssociationJoin($foreignKeys,$indexValues,$sourceKeys);
234
-		$fkTable = $this->getForeignTable()->getTableFullName();
235
-		$srcColumns = $this->getSourceColumns($sourceKeys);
233
+		$innerJoin=$this->getAssociationJoin($foreignKeys, $indexValues, $sourceKeys);
234
+		$fkTable=$this->getForeignTable()->getTableFullName();
235
+		$srcColumns=$this->getSourceColumns($sourceKeys);
236 236
 		if(($where=$criteria->getCondition())===null)
237 237
 			$where='1=1';
238
-		$sql = "SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}";
238
+		$sql="SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}";
239 239
 
240
-		$parameters = $criteria->getParameters()->toArray();
241
-		$ordering = $criteria->getOrdersBy();
242
-		$limit = $criteria->getLimit();
243
-		$offset = $criteria->getOffset();
240
+		$parameters=$criteria->getParameters()->toArray();
241
+		$ordering=$criteria->getOrdersBy();
242
+		$limit=$criteria->getLimit();
243
+		$offset=$criteria->getOffset();
244 244
 
245
-		$builder = $this->getForeignCommandBuilder()->getBuilder();
246
-		$command = $builder->applyCriterias($sql,$parameters,$ordering,$limit,$offset);
245
+		$builder=$this->getForeignCommandBuilder()->getBuilder();
246
+		$command=$builder->applyCriterias($sql, $parameters, $ordering, $limit, $offset);
247 247
 		$this->getCommandBuilder()->onCreateCommand($command, $criteria);
248 248
 		return $command;
249 249
 	}
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	protected function getSourceColumns($sourceKeys)
256 256
 	{
257 257
 		$columns=array();
258
-		$table = $this->getAssociationTable();
259
-		$tableName = $table->getTableFullName();
260
-		$columnNames = array_merge(array_keys($sourceKeys),$this->_association_columns);
258
+		$table=$this->getAssociationTable();
259
+		$tableName=$table->getTableFullName();
260
+		$columnNames=array_merge(array_keys($sourceKeys), $this->_association_columns);
261 261
 		foreach($columnNames as $name)
262
-			$columns[] = $tableName.'.'.$table->getColumn($name)->getColumnName();
262
+			$columns[]=$tableName.'.'.$table->getColumn($name)->getColumnName();
263 263
 		return implode(', ', $columns);
264 264
 	}
265 265
 
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
 	 * @param array source table column names.
271 271
 	 * @return string inner join condition for M-N relationship via association table.
272 272
 	 */
273
-	protected function getAssociationJoin($foreignKeys,$indexValues,$sourceKeys)
273
+	protected function getAssociationJoin($foreignKeys, $indexValues, $sourceKeys)
274 274
 	{
275
-		$refInfo= $this->getAssociationTable();
276
-		$fkInfo = $this->getForeignTable();
275
+		$refInfo=$this->getAssociationTable();
276
+		$fkInfo=$this->getForeignTable();
277 277
 
278
-		$refTable = $refInfo->getTableFullName();
279
-		$fkTable = $fkInfo->getTableFullName();
278
+		$refTable=$refInfo->getTableFullName();
279
+		$fkTable=$fkInfo->getTableFullName();
280 280
 
281
-		$joins = array();
282
-		$hasAssociationColumns = count($this->_association_columns) > 0;
281
+		$joins=array();
282
+		$hasAssociationColumns=count($this->_association_columns) > 0;
283 283
 		$i=0;
284 284
 		foreach($foreignKeys as $ref=>$fk)
285 285
 		{
286 286
 			if($hasAssociationColumns)
287
-				$refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
287
+				$refField=$refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
288 288
 			else
289
-				$refField = $refInfo->getColumn($ref)->getColumnName();
290
-			$fkField = $fkInfo->getColumn($fk)->getColumnName();
291
-			$joins[] = "{$fkTable}.{$fkField} = {$refTable}.{$refField}";
289
+				$refField=$refInfo->getColumn($ref)->getColumnName();
290
+			$fkField=$fkInfo->getColumn($fk)->getColumnName();
291
+			$joins[]="{$fkTable}.{$fkField} = {$refTable}.{$refField}";
292 292
 		}
293
-		$joinCondition = implode(' AND ', $joins);
294
-		$index = $this->getCommandBuilder()->getIndexKeyCondition($refInfo,array_keys($sourceKeys), $indexValues);
293
+		$joinCondition=implode(' AND ', $joins);
294
+		$index=$this->getCommandBuilder()->getIndexKeyCondition($refInfo, array_keys($sourceKeys), $indexValues);
295 295
 		return "INNER JOIN {$refTable} ON ({$joinCondition}) AND {$index}";
296 296
 	}
297 297
 
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
 	 */
302 302
 	public function updateAssociatedRecords()
303 303
 	{
304
-		$obj = $this->getContext()->getSourceRecord();
305
-		$fkObjects = &$obj->{$this->getContext()->getProperty()};
304
+		$obj=$this->getContext()->getSourceRecord();
305
+		$fkObjects=&$obj->{$this->getContext()->getProperty()};
306 306
 		$success=true;
307
-		if(($total = count($fkObjects))> 0)
307
+		if(($total=count($fkObjects)) > 0)
308 308
 		{
309
-			$source = $this->getSourceRecord();
310
-			$builder = $this->getAssociationTableCommandBuilder();
311
-			for($i=0;$i<$total;$i++)
312
-				$success = $fkObjects[$i]->save() && $success;
309
+			$source=$this->getSourceRecord();
310
+			$builder=$this->getAssociationTableCommandBuilder();
311
+			for($i=0; $i < $total; $i++)
312
+				$success=$fkObjects[$i]->save() && $success;
313 313
 			return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success;
314 314
 		}
315 315
 		return $success;
@@ -320,57 +320,57 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	protected function getAssociationTableCommandBuilder()
322 322
 	{
323
-		$conn = $this->getContext()->getSourceRecord()->getDbConnection();
323
+		$conn=$this->getContext()->getSourceRecord()->getDbConnection();
324 324
 		return $this->getAssociationTable()->createCommandBuilder($conn);
325 325
 	}
326 326
 
327
-	private function hasAssociationData($builder,$data)
327
+	private function hasAssociationData($builder, $data)
328 328
 	{
329 329
 		$condition=array();
330
-		$table = $this->getAssociationTable();
330
+		$table=$this->getAssociationTable();
331 331
 		foreach($data as $name=>$value)
332
-			$condition[] = $table->getColumn($name)->getColumnName().' = ?';
333
-		$command = $builder->createCountCommand(implode(' AND ', $condition),array_values($data));
334
-		$result = $this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar()));
332
+			$condition[]=$table->getColumn($name)->getColumnName().' = ?';
333
+		$command=$builder->createCountCommand(implode(' AND ', $condition), array_values($data));
334
+		$result=$this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar()));
335 335
 		return intval($result) > 0;
336 336
 	}
337 337
 
338
-	private function addAssociationData($builder,$data)
338
+	private function addAssociationData($builder, $data)
339 339
 	{
340
-		$command = $builder->createInsertCommand($data);
340
+		$command=$builder->createInsertCommand($data);
341 341
 		return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0;
342 342
 	}
343 343
 
344
-	private function updateAssociationTable($obj,$fkObjects, $builder)
344
+	private function updateAssociationTable($obj, $fkObjects, $builder)
345 345
 	{
346
-		$source = $this->getSourceRecordValues($obj);
347
-		$foreignKeys = $this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]);
346
+		$source=$this->getSourceRecordValues($obj);
347
+		$foreignKeys=$this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]);
348 348
 		$success=true;
349 349
 		foreach($fkObjects as $fkObject)
350 350
 		{
351
-			$data = array_merge($source, $this->getForeignObjectValues($foreignKeys,$fkObject));
352
-			if(!$this->hasAssociationData($builder,$data))
353
-				$success = $this->addAssociationData($builder,$data) && $success;
351
+			$data=array_merge($source, $this->getForeignObjectValues($foreignKeys, $fkObject));
352
+			if(!$this->hasAssociationData($builder, $data))
353
+				$success=$this->addAssociationData($builder, $data) && $success;
354 354
 		}
355 355
 		return $success;
356 356
 	}
357 357
 
358 358
 	private function getSourceRecordValues($obj)
359 359
 	{
360
-		$sourceKeys = $this->findForeignKeys($this->getAssociationTable(), $obj);
361
-		$indexValues = $this->getIndexValues(array_values($sourceKeys), $obj);
362
-		$data = array();
360
+		$sourceKeys=$this->findForeignKeys($this->getAssociationTable(), $obj);
361
+		$indexValues=$this->getIndexValues(array_values($sourceKeys), $obj);
362
+		$data=array();
363 363
 		$i=0;
364 364
 		foreach($sourceKeys as $name=>$srcKey)
365
-			$data[$name] = $indexValues[0][$i++];
365
+			$data[$name]=$indexValues[0][$i++];
366 366
 		return $data;
367 367
 	}
368 368
 
369
-	private function getForeignObjectValues($foreignKeys,$fkObject)
369
+	private function getForeignObjectValues($foreignKeys, $fkObject)
370 370
 	{
371 371
 		$data=array();
372 372
 		foreach($foreignKeys as $name=>$fKey)
373
-			$data[$name] = $fkObject->getColumnValue($fKey);
373
+			$data[$name]=$fkObject->getColumnValue($fKey);
374 374
 		return $data;
375 375
 	}
376 376
 }
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	protected function collectForeignObjects(&$results)
94 94
 	{
95
-		$fkeys = $this->getRelationForeignKeys();
96
-		$properties = array_values($fkeys);
97
-		$fields = array_keys($fkeys);
95
+		$fkeys=$this->getRelationForeignKeys();
96
+		$properties=array_values($fkeys);
97
+		$fields=array_keys($fkeys);
98 98
 
99
-		$indexValues = $this->getIndexValues($properties, $results);
100
-		$fkObjects = $this->findForeignObjects($fields,$indexValues);
101
-		$this->populateResult($results,$properties,$fkObjects,$fields);
99
+		$indexValues=$this->getIndexValues($properties, $results);
100
+		$fkObjects=$this->findForeignObjects($fields, $indexValues);
101
+		$this->populateResult($results, $properties, $fkObjects, $fields);
102 102
 	}
103 103
 
104 104
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getRelationForeignKeys()
109 109
 	{
110
-		$fkObject = $this->getContext()->getForeignRecordFinder();
110
+		$fkObject=$this->getContext()->getForeignRecordFinder();
111 111
 		return $this->findForeignKeys($fkObject, $this->getSourceRecord());
112 112
 	}
113 113
 
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function setObjectProperty($source, $properties, &$collections)
120 120
 	{
121
-		$hash = $this->getObjectHash($source, $properties);
122
-		$prop = $this->getContext()->getProperty();
121
+		$hash=$this->getObjectHash($source, $properties);
122
+		$prop=$this->getContext()->getProperty();
123 123
 		if(isset($collections[$hash]) && count($collections[$hash]) > 0)
124 124
 		{
125 125
 			if(count($collections[$hash]) > 1)
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function updateAssociatedRecords()
136 136
 	{
137
-		$fkObject = $this->getContext()->getPropertyValue();
138
-		$source = $this->getSourceRecord();
139
-		$fkeys = $this->findForeignKeys($fkObject, $source);
137
+		$fkObject=$this->getContext()->getPropertyValue();
138
+		$source=$this->getSourceRecord();
139
+		$fkeys=$this->findForeignKeys($fkObject, $source);
140 140
 		foreach($fkeys as $fKey => $srcKey)
141 141
 			$fkObject->setColumnValue($fKey, $source->getColumnValue($srcKey));
142 142
 		return $fkObject->save();
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 
31 31
 	public function __construct(TActiveRecordRelationContext $context, $criteria)
32 32
 	{
33
-		$this->_context = $context;
34
-		$this->_criteria = $criteria;
33
+		$this->_context=$context;
34
+		$this->_criteria=$criteria;
35 35
 	}
36 36
 
37 37
 	/**
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * @param array method arguments
72 72
 	 * @return mixed TActiveRecord or array of TActiveRecord results depending on the method called.
73 73
 	 */
74
-	public function __call($method,$args)
74
+	public function __call($method, $args)
75 75
 	{
76 76
 		static $stack=array();
77 77
 
78
-		$results = call_user_func_array(array($this->getSourceRecord(),$method),$args);
79
-		$validArray = is_array($results) && count($results) > 0;
78
+		$results=call_user_func_array(array($this->getSourceRecord(), $method), $args);
79
+		$validArray=is_array($results) && count($results) > 0;
80 80
 		if($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
81 81
 		{
82 82
 			$this->collectForeignObjects($results);
83
-			while($obj = array_pop($stack))
83
+			while($obj=array_pop($stack))
84 84
 				$obj->collectForeignObjects($results);
85 85
 		}
86 86
 		else if($results instanceof TActiveRecordRelation)
87
-			$stack[] = $this; //call it later
88
-		else if($results === null || !$validArray)
89
-			$stack = array();
87
+			$stack[]=$this; //call it later
88
+		else if($results===null || !$validArray)
89
+			$stack=array();
90 90
 		return $results;
91 91
 	}
92 92
 
@@ -110,28 +110,28 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function findForeignKeys($from, $matchesRecord, $loose=false)
112 112
 	{
113
-		$gateway = $matchesRecord->getRecordGateway();
114
-		$recordTableInfo = $gateway->getRecordTableInfo($matchesRecord);
115
-		$matchingTableName = strtolower($recordTableInfo->getTableName());
116
-		$matchingFullTableName = strtolower($recordTableInfo->getTableFullName());
113
+		$gateway=$matchesRecord->getRecordGateway();
114
+		$recordTableInfo=$gateway->getRecordTableInfo($matchesRecord);
115
+		$matchingTableName=strtolower($recordTableInfo->getTableName());
116
+		$matchingFullTableName=strtolower($recordTableInfo->getTableFullName());
117 117
 		$tableInfo=$from;
118 118
 		if($from instanceof TActiveRecord)
119
-			$tableInfo = $gateway->getRecordTableInfo($from);
119
+			$tableInfo=$gateway->getRecordTableInfo($from);
120 120
 		//find first non-empty FK
121 121
 		foreach($tableInfo->getForeignKeys() as $fkeys)
122 122
 		{
123
-			$fkTable = strtolower($fkeys['table']);
123
+			$fkTable=strtolower($fkeys['table']);
124 124
 			if($fkTable===$matchingTableName || $fkTable===$matchingFullTableName)
125 125
 			{
126
-				$hasFkField = !$loose && $this->getContext()->hasFkField();
127
-				$key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
126
+				$hasFkField=!$loose && $this->getContext()->hasFkField();
127
+				$key=$hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
128 128
 				if(!empty($key))
129 129
 					return $key;
130 130
 			}
131 131
 		}
132 132
 
133 133
 		//none found
134
-		$matching = $gateway->getRecordTableInfo($matchesRecord)->getTableFullName();
134
+		$matching=$gateway->getRecordTableInfo($matchesRecord)->getTableFullName();
135 135
 		throw new TActiveRecordException('ar_relations_missing_fk',
136 136
 			$tableInfo->getTableFullName(), $matching);
137 137
 	}
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	private function getFkFields($fkeys)
151 151
 	{
152
-		$matching = array();
152
+		$matching=array();
153 153
 		preg_match_all('/\s*(\S+\.)?([\w-]+)\s*/', $this->getContext()->getFkField(), $matching);
154
-		$fields = array();
154
+		$fields=array();
155 155
 		foreach($fkeys as $fkName => $field)
156 156
 		{
157 157
 			if(in_array($fkName, $matching[2]))
158
-				$fields[$fkName] = $field;
158
+				$fields[$fkName]=$field;
159 159
 		}
160 160
 		return $fields;
161 161
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	{
170 170
 		$ids=array();
171 171
 		foreach($properties as $property)
172
-			$ids[] = is_object($obj) ? (string)$obj->getColumnValue($property) : (string)$obj[$property];
172
+			$ids[]=is_object($obj) ? (string) $obj->getColumnValue($property) : (string) $obj[$property];
173 173
 		return serialize($ids);
174 174
 	}
175 175
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	protected function findForeignObjects($fields, $indexValues)
183 183
 	{
184
-		$finder = $this->getContext()->getForeignRecordFinder();
184
+		$finder=$this->getContext()->getForeignRecordFinder();
185 185
 		return $finder->findAllByIndex($this->_criteria, $fields, $indexValues);
186 186
 	}
187 187
 
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 	protected function getIndexValues($keys, $results)
195 195
 	{
196 196
 		if(!is_array($results) && !$results instanceof ArrayAccess)
197
-			$results = array($results);
197
+			$results=array($results);
198 198
 		$values=array();
199 199
 		foreach($results as $result)
200 200
 		{
201
-			$value = array();
201
+			$value=array();
202 202
 			foreach($keys as $name)
203
-				$value[] = $result->getColumnValue($name);
204
-			$values[] = $value;
203
+				$value[]=$result->getColumnValue($name);
204
+			$values[]=$value;
205 205
 		}
206 206
 		return $values;
207 207
 	}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @param array foreign objects
214 214
 	 * @param array foreign object field names.
215 215
 	 */
216
-	protected function populateResult(&$results,$properties,&$fkObjects,$fields)
216
+	protected function populateResult(&$results, $properties, &$fkObjects, $fields)
217 217
 	{
218 218
 		$collections=array();
219 219
 		foreach($fkObjects as $fkObject)
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	{
232 232
 		if(is_array($results) || $results instanceof ArrayAccess)
233 233
 		{
234
-			for($i=0,$k=count($results);$i<$k;$i++)
234
+			for($i=0, $k=count($results); $i < $k; $i++)
235 235
 				$this->setObjectProperty($results[$i], $properties, $collections);
236 236
 		}
237 237
 		else
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	protected function setObjectProperty($source, $properties, &$collections)
248 248
 	{
249
-		$hash = $this->getObjectHash($source, $properties);
250
-		$prop = $this->getContext()->getProperty();
249
+		$hash=$this->getObjectHash($source, $properties);
250
+		$prop=$this->getContext()->getProperty();
251 251
 		$source->$prop=isset($collections[$hash]) ? $collections[$hash] : array();
252 252
 	}
253 253
 }
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function setRecordPk($value)
84 84
 	{
85 85
 		$this->clearRecordObject();
86
-		$val = TPropertyValue::ensureArray($value);
86
+		$val=TPropertyValue::ensureArray($value);
87 87
 		$this->setViewState('PK', count($val) > 0 ? $val : null);
88 88
 	}
89 89
 
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function initializeEditForm()
110 110
 	{
111
-		$record = $this->getCurrentRecord();
112
-		$classPath = $this->getEditRenderer();
113
-		if($classPath === '')
111
+		$record=$this->getCurrentRecord();
112
+		$classPath=$this->getEditRenderer();
113
+		if($classPath==='')
114 114
 		{
115
-			$columns = $this->getTableInfo()->getColumns();
115
+			$columns=$this->getTableInfo()->getColumns();
116 116
 			$this->getInputRepeater()->setDataSource($columns);
117 117
 			$this->getInputRepeater()->dataBind();
118 118
 		}
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	protected function createEditRenderer($record, $classPath)
136 136
 	{
137
-		$this->_editRenderer = Prado::createComponent($classPath);
137
+		$this->_editRenderer=Prado::createComponent($classPath);
138 138
 		if($this->_editRenderer instanceof IScaffoldEditRenderer)
139 139
 		{
140
-			$index = $this->getControls()->remove($this->getInputRepeater());
141
-			$this->getControls()->insertAt($index,$this->_editRenderer);
140
+			$index=$this->getControls()->remove($this->getInputRepeater());
141
+			$this->getControls()->insertAt($index, $this->_editRenderer);
142 142
 			$this->_editRenderer->setData($record);
143 143
 		}
144 144
 		else
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	protected function createRepeaterEditItem($sender, $param)
155 155
 	{
156
-		$type = $param->getItem()->getItemType();
156
+		$type=$param->getItem()->getItemType();
157 157
 		if($type==TListItemType::Item || $type==TListItemType::AlternatingItem)
158 158
 		{
159
-			$item = $param->getItem();
160
-			$column = $item->getDataItem();
159
+			$item=$param->getItem();
160
+			$column=$item->getDataItem();
161 161
 			if($column===null)
162 162
 				return;
163 163
 
164
-			$record = $this->getCurrentRecord();
165
-			$builder = $this->getScaffoldInputBuilder($record);
164
+			$record=$this->getCurrentRecord();
165
+			$builder=$this->getScaffoldInputBuilder($record);
166 166
 			$builder->createScaffoldInput($this, $item, $column, $record);
167 167
 		}
168 168
 	}
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 	{
195 195
 		if($this->getPage()->getIsValid())
196 196
 		{
197
-			$record = $this->getCurrentRecord();
197
+			$record=$this->getCurrentRecord();
198 198
 			if($this->_editRenderer===null)
199 199
 			{
200
-				$table = $this->getTableInfo();
201
-				$builder = $this->getScaffoldInputBuilder($record);
200
+				$table=$this->getTableInfo();
201
+				$builder=$this->getScaffoldInputBuilder($record);
202 202
 				foreach($this->getInputRepeater()->getItems() as $item)
203 203
 				{
204
-					$column = $table->getColumn($item->getCustomData());
204
+					$column=$table->getColumn($item->getCustomData());
205 205
 					$builder->loadScaffoldInput($this, $item, $column, $record);
206 206
 				}
207 207
 			}
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 	protected function getScaffoldInputBuilder($record)
266 266
 	{
267 267
 		static $_builders=array();
268
-		$class = get_class($record);
268
+		$class=get_class($record);
269 269
 		if(!isset($_builders[$class]))
270 270
 		{
271 271
 			Prado::using('System.Data.ActiveRecord.Scaffold.InputBuilder.TScaffoldInputBase');
272
-			$_builders[$class] = TScaffoldInputBase::createInputBuilder($record);
272
+			$_builders[$class]=TScaffoldInputBase::createInputBuilder($record);
273 273
 		}
274 274
 		return $_builders[$class];
275 275
 	}
Please login to merge, or discard this patch.