Changed access to private __associations on Model to associations() calls.

This commit is contained in:
predominant 2010-04-04 18:17:43 +10:00
parent 97388d2e61
commit 3c2e7a091d
5 changed files with 18 additions and 8 deletions

View file

@ -527,7 +527,7 @@ class DataSource extends Object {
}
break;
case '{$__cakeForeignKey__$}':
foreach ($model->__associations as $id => $name) {
foreach ($model->associations() as $id => $name) {
foreach ($model->$name as $assocName => $assoc) {
if ($assocName === $association) {
if (isset($assoc['foreignKey'])) {

View file

@ -1026,7 +1026,7 @@ class DboOracle extends DboSource {
if (!empty($fetch) && is_array($fetch)) {
if ($recursive > 0) {
foreach ($linkModel->__associations as $type1) {
foreach ($linkModel->associations() as $type1) {
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
$deepModel =& $linkModel->{$assoc1};
$tmpStack = $stack;
@ -1088,7 +1088,7 @@ class DboOracle extends DboSource {
if (!empty($fetch) && is_array($fetch)) {
if ($recursive > 0) {
foreach ($linkModel->__associations as $type1) {
foreach ($linkModel->associations() as $type1) {
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
$deepModel =& $linkModel->{$assoc1};

View file

@ -779,7 +779,7 @@ class DboSource extends DataSource {
$queryData['fields'] = $this->fields($model);
}
$_associations = $model->__associations;
$_associations = $model->associations();
if ($model->recursive == -1) {
$_associations = array();
@ -922,7 +922,7 @@ class DboSource extends DataSource {
if (!empty($fetch) && is_array($fetch)) {
if ($recursive > 0) {
foreach ($linkModel->__associations as $type1) {
foreach ($linkModel->associations() as $type1) {
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
$deepModel =& $linkModel->{$assoc1};
$tmpStack = $stack;
@ -991,7 +991,7 @@ class DboSource extends DataSource {
if (!empty($fetch) && is_array($fetch)) {
if ($recursive > 0) {
foreach ($linkModel->__associations as $type1) {
foreach ($linkModel->associations() as $type1) {
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
$deepModel =& $linkModel->{$assoc1};

View file

@ -2814,6 +2814,16 @@ class Model extends Overloadable {
return $db;
}
/**
* Get associations
*
* @return array
* @access public
*/
function associations() {
return $this->__associations;
}
/**
* Gets all the models with which this model is associated.
*

View file

@ -1400,7 +1400,7 @@ class DboSourceTest extends CakeTestCase {
$queryData = array();
foreach ($this->Model->Category2->__associations as $type) {
foreach ($this->Model->Category2->associations() as $type) {
foreach ($this->Model->Category2->{$type} as $assoc => $assocData) {
$linkModel =& $this->Model->Category2->{$assoc};
$external = isset($assocData['external']);
@ -2185,7 +2185,7 @@ class DboSourceTest extends CakeTestCase {
* @return void
*/
function _buildRelatedModels(&$model) {
foreach ($model->__associations as $type) {
foreach ($model->associations() as $type) {
foreach ($model->{$type} as $assoc => $assocData) {
if (is_string($assocData)) {
$className = $assocData;