src/Common/Model/Base.php
protected function countManyAssociatedItems(
        array &$aItems,
        $sItemProperty,
        $sAssociatedItemIdColumn,
        $sAssociatedModel,
        $sAssociatedModelProvider,
        array $aAssociatedModelData = []
    ) {
        if (!empty($aItems)) {

            $oAssociatedModel = Factory::model($sAssociatedModel, $sAssociatedModelProvider);

            foreach ($aItems as $oItem) {
                //  Use a new array so as not to impact the original request
                $aQueryData = $aAssociatedModelData;
                if (empty($aQueryData['where'])) {
                    $aQueryData['where'] = [];
                }
                $aQueryData['where'][]   = [$sAssociatedItemIdColumn, $oItem->id];
                $oItem->{$sItemProperty} = $oAssociatedModel->countAll($aQueryData);
            }
        }
    }
protected function countManyAssociatedItems(
        array &$aItems,
        $sItemProperty,
        $sAssociatedItemIdColumn,
        $sAssociatedModel,
        $sAssociatedModelProvider,
        array $aAssociatedModelData = []
    ) {
        if (!empty($aItems)) {

            $oAssociatedModel = Factory::model($sAssociatedModel, $sAssociatedModelProvider);

            foreach ($aItems as $oItem) {
                //  Use a new array so as not to impact the original request
                $aQueryData = $aAssociatedModelData;
                if (empty($aQueryData['where'])) {
                    $aQueryData['where'] = [];
                }
                $aQueryData['where'][]   = [$sAssociatedItemIdColumn, $oItem->id];
                $oItem->{$sItemProperty} = $oAssociatedModel->countAll($aQueryData);
            }
        }
    }
protected function countManyAssociatedItems ( array & $ aItems , $ sItemProperty , $ sAssociatedItemIdColumn , $ sAssociatedModel , $ sAssociatedModelProvider , array $ aAssociatedModelData = [ ] ) { if ( ! empty ( $ aItems ) ) { $ oAssociatedModel = Factory :: model ( $ sAssociatedModel , $ sAssociatedModelProvider ) ; foreach ( $ aItems as $ oItem ) { //  Use a new array so as not to impact the original request $ aQueryData = $ aAssociatedModelData ; if ( empty ( $ aQueryData [ 'where' ] ) ) { $ aQueryData [ 'where' ] = [ ] ; } $ aQueryData [ 'where' ] [ ] = [ $ sAssociatedItemIdColumn , $ oItem -> id ] ; $ oItem -> { $ sItemProperty } = $ oAssociatedModel -> countAll ( $ aQueryData ) ; } } }
Count associated content for the items in the result set where the the relationship is 1 to many

@param array  &$aItems                   The result set of items
@param string  $sItemProperty            What property of each item to assign the associated content
@param string  $sAssociatedItemIdColumn  Which property in the associated content which contains the item's ID
@param string  $sAssociatedModel         The name of the model which handles the associated content
@param string  $sAssociatedModelProvider Which module provides the associated model
@param array   $aAssociatedModelData     Data to pass to the associated model's getByIds method()

@return void
Count associated content for the items in the result set where the the relationship is 1 to many