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

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

            $aItemIds = [];
            foreach ($aItems as $oItem) {

                //  Note the ID
                $aItemIds[] = $oItem->id;

                //  Set the base property
                $oItem->{$sItemProperty} = Factory::resource('ExpandableField');
            }

            if (empty($aAssociatedModelData['where_in'])) {
                $aAssociatedModelData['where_in'] = [];
            }

            $aAssociatedModelData['where_in'][] = [
                $oAssociatedModel->getTableAlias() . '.' . $sAssociatedItemIdColumn,
                $aItemIds,
            ];

            $aAssociatedItems = $oAssociatedModel->getAll(null, null, $aAssociatedModelData);

            foreach ($aItems as $oItem) {
                foreach ($aAssociatedItems as $oAssociatedItem) {
                    if ($oItem->id == $oAssociatedItem->{$sAssociatedItemIdColumn}) {
                        $oItem->{$sItemProperty}->data[] = $oAssociatedItem;
                        $oItem->{$sItemProperty}->count++;
                    }
                }
            }
        }
    }
protected function getManyAssociatedItems(
        array &$aItems,
        $sItemProperty,
        $sAssociatedItemIdColumn,
        $sAssociatedModel,
        $sAssociatedModelProvider,
        array $aAssociatedModelData = []
    ) {
        if (!empty($aItems)) {

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

            $aItemIds = [];
            foreach ($aItems as $oItem) {

                //  Note the ID
                $aItemIds[] = $oItem->id;

                //  Set the base property
                $oItem->{$sItemProperty} = Factory::resource('ExpandableField');
            }

            if (empty($aAssociatedModelData['where_in'])) {
                $aAssociatedModelData['where_in'] = [];
            }

            $aAssociatedModelData['where_in'][] = [
                $oAssociatedModel->getTableAlias() . '.' . $sAssociatedItemIdColumn,
                $aItemIds,
            ];

            $aAssociatedItems = $oAssociatedModel->getAll(null, null, $aAssociatedModelData);

            foreach ($aItems as $oItem) {
                foreach ($aAssociatedItems as $oAssociatedItem) {
                    if ($oItem->id == $oAssociatedItem->{$sAssociatedItemIdColumn}) {
                        $oItem->{$sItemProperty}->data[] = $oAssociatedItem;
                        $oItem->{$sItemProperty}->count++;
                    }
                }
            }
        }
    }
protected function getManyAssociatedItems ( array & $ aItems , $ sItemProperty , $ sAssociatedItemIdColumn , $ sAssociatedModel , $ sAssociatedModelProvider , array $ aAssociatedModelData = [ ] ) { if ( ! empty ( $ aItems ) ) { $ oAssociatedModel = Factory :: model ( $ sAssociatedModel , $ sAssociatedModelProvider ) ; $ aItemIds = [ ] ; foreach ( $ aItems as $ oItem ) { //  Note the ID $ aItemIds [ ] = $ oItem -> id ; //  Set the base property $ oItem -> { $ sItemProperty } = Factory :: resource ( 'ExpandableField' ) ; } if ( empty ( $ aAssociatedModelData [ 'where_in' ] ) ) { $ aAssociatedModelData [ 'where_in' ] = [ ] ; } $ aAssociatedModelData [ 'where_in' ] [ ] = [ $ oAssociatedModel -> getTableAlias ( ) . '.' . $ sAssociatedItemIdColumn , $ aItemIds , ] ; $ aAssociatedItems = $ oAssociatedModel -> getAll ( null , null , $ aAssociatedModelData ) ; foreach ( $ aItems as $ oItem ) { foreach ( $ aAssociatedItems as $ oAssociatedItem ) { if ( $ oItem -> id == $ oAssociatedItem -> { $ sAssociatedItemIdColumn } ) { $ oItem -> { $ sItemProperty } -> data [ ] = $ oAssociatedItem ; $ oItem -> { $ sItemProperty } -> count ++ ; } } } } }
Get 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
Get associated content for the items in the result set where the the relationship is 1 to many