Skip to content

Commit

Permalink
Merge pull request #18 from aaronwaldon/patch-1
Browse files Browse the repository at this point in the history
Eager loading fix
  • Loading branch information
Samuel Marineau-Cyr authored Sep 13, 2017
2 parents c4240be + 37994d3 commit 6b73ca9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion focuspoint/elementtypes/FocusPoint_AssetElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ public function populateElementModel($row)
$model = FocusPoint_AssetFileModel::populateModel($row);
return $model;
}
}

/**
* Adds the focusX and focusY points to the row that populates the model. This
* allows the focus point to still work with eager loading.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query
->addSelect('ff.focusX, ff.focusY')
->leftJoin('focuspoint_focuspoints ff', 'ff.assetId = elements.id');

parent::modifyElementsQuery($query, $criteria);
}
}

0 comments on commit 6b73ca9

Please sign in to comment.