Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update Behavior

  • Loading branch information...
commit 358db2e214ea0b1c331817e36ba3a1f213f7f82f 1 parent 6276cf1
Sam Sherlock authored December 10, 2011

Showing 1 changed file with 6 additions and 23 deletions. Show diff stats Hide diff stats

  1. 29  Model/Behavior/LinkableBehavior.php
29  Model/Behavior/LinkableBehavior.php
@@ -25,6 +25,8 @@ class LinkableBehavior extends ModelBehavior {
25 25
 
26 26
 	protected $_defaults = array('type' => 'LEFT');
27 27
 
  28
+	public $settings = array();
  29
+
28 30
 /**
29 31
  * Initializes this behavior for the model $Model
30 32
  *
@@ -35,9 +37,9 @@ class LinkableBehavior extends ModelBehavior {
35 37
 	public function setup(Model $Model, $settings = array()) {
36 38
 		if (!isset($this->settings[$Model->alias])) {
37 39
 			$this->settings[$Model->alias] = array(
38  
-				'delimiter' => ';',
39  
-				'enclosure' => '"',
40  
-				'hasHeader' => true
  40
+				'type' => true, 'table' => true, 'alias' => true,
  41
+				'conditions' => true, 'fields' => true, 'reference' => true,
  42
+				'class' => true, 'defaults' => true
41 43
 			);
42 44
 		}
43 45
 		$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings);
@@ -88,21 +90,12 @@ public function beforeFind(Model $Model, $query) {
88 90
 					}
89 91
 					App::uses('ConnectionManager', 'Model');
90 92
 					$sources = ConnectionManager::sourceList();
91  
-					//diebug($options);
92 93
 
93 94
 					$_Model = ClassRegistry::init($options['class']);			// the incoming model to be linked in query
94 95
 					$Reference = ClassRegistry::init($options['reference']); 
95  
-					//debug($_Model);
96  
-					//diebug($Reference);	// the already in query model that links to $_Model
97  
-					//$db =& $_Model->getDataSource();
  96
+					// the already in query model that links to $_Model
98 97
 					$db = ConnectionManager::getDataSource($_Model->useDbConfig);
99 98
 					$associations = ConnectionManager::getDataSource($Reference->useDbConfig);
100  
-					//debug($_Model);
101  
-					//
102  
-					//	debug($Reference);
103  
-					//	debug($associations);
104  
-					//	debug($associations[$Reference->alias]);
105  
-					//	debug($Reference->belongsTo[$_Model->alias]);
106 99
 					if (isset($Reference->belongsTo[$_Model->alias])) {
107 100
 						$type = 'hasOne';
108 101
 						$association = $Reference->belongsTo[$_Model->alias];
@@ -155,16 +148,6 @@ public function beforeFind(Model $Model, $query) {
155 148
 							$modelKey = $_Model->escapeField();
156 149
 							$options['conditions'] = "{$modelLink} = {$modelKey}";
157 150
 						} else {
158  
-							//try {
159  
-							//	$_Model->getDataSource()->fullTableName($_Model);	
160  
-							//} catch(MissingTableException $e) {
161  
-							//	if(array_key_exists($_Model->alias, array_flip(array_keys($Reference->belongsTo)))) {
162  
-							//	//	debug($Reference->belongsTo[$_Model->alias]);
163  
-							//	//die('self join');
164  
-							//	}
165  
-							//	//debug($_Model->alias);debug($Reference->belongsTo);
166  
-							//	//die('self join');
167  
-							//}
168 151
 							$referenceKey = $Reference->escapeField($association['foreignKey']);
169 152
 							$modelKey = $_Model->escapeField($_Model->primaryKey);
170 153
 							$options['conditions'] = "{$modelKey} = {$referenceKey}";

0 notes on commit 358db2e

Please sign in to comment.
Something went wrong with that request. Please try again.