Skip to content

Commit

Permalink
Changed access to private __associations on Model to associations() c…
Browse files Browse the repository at this point in the history
…alls.
  • Loading branch information
predominant committed Apr 4, 2010
1 parent 97388d2 commit 3c2e7a0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/datasource.php
Expand Up @@ -527,7 +527,7 @@ function insertQueryData($query, $data, $association, $assocData, &$model, &$lin
}
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'])) {
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo/dbo_oracle.php
Expand Up @@ -1026,7 +1026,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,
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;
Expand Down Expand Up @@ -1088,7 +1088,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,
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};
Expand Down
6 changes: 3 additions & 3 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -779,7 +779,7 @@ function read(&$model, $queryData = array(), $recursive = null) {
$queryData['fields'] = $this->fields($model);
}

$_associations = $model->__associations;
$_associations = $model->associations();

if ($model->recursive == -1) {
$_associations = array();
Expand Down Expand Up @@ -922,7 +922,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,

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;
Expand Down Expand Up @@ -991,7 +991,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,

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};

Expand Down
10 changes: 10 additions & 0 deletions cake/libs/model/model.php
Expand Up @@ -2814,6 +2814,16 @@ function &getDataSource() {
return $db;
}

/**
* Get associations
*
* @return array
* @access public
*/
function associations() {
return $this->__associations;
}

/**
* Gets all the models with which this model is associated.
*
Expand Down
4 changes: 2 additions & 2 deletions cake/tests/cases/libs/model/datasources/dbo_source.test.php
Expand Up @@ -1400,7 +1400,7 @@ function testGenerateAssociationQuerySelfJoin() {

$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']);
Expand Down Expand Up @@ -2185,7 +2185,7 @@ function testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit() {
* @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;
Expand Down

0 comments on commit 3c2e7a0

Please sign in to comment.