src/UthandoCommon/Service/AbstractRelationalMapperService.php
public function populate($model, $children)
    {
        $allChildren = ($children === true) ? true : false;
        $children = (is_array($children)) ? $children : [];

        foreach ($this->getReferenceMap() as $name => $options) {
            if ($allChildren || in_array($name, $children)) {

                $service        = $this->getRelatedService($name);
                $getIdMethod    = 'get' . ucfirst($options['refCol']);
                $setMethod      = $options['setMethod'] ?? 'set' . ucfirst($name);
                $getMethod      = $options['getMethod'] ?? 'getById';
                $childModel     = $service->$getMethod($model->$getIdMethod(), $options['refCol']);

                if ($childModel instanceof HydratingResultSet) {
                    $childModelObjects = [];

                    foreach ($childModel as $row) {
                        $childModelObjects[] = $row;
                    }

                    $childModel = $childModelObjects;
                }

                $model->$setMethod($childModel);
            }
        }

        return $model;
    }
public function populate($model, $children)
    {
        $allChildren = ($children === true) ? true : false;
        $children = (is_array($children)) ? $children : [];

        foreach ($this->getReferenceMap() as $name => $options) {
            if ($allChildren || in_array($name, $children)) {

                $service        = $this->getRelatedService($name);
                $getIdMethod    = 'get' . ucfirst($options['refCol']);
                $setMethod      = $options['setMethod'] ?? 'set' . ucfirst($name);
                $getMethod      = $options['getMethod'] ?? 'getById';
                $childModel     = $service->$getMethod($model->$getIdMethod(), $options['refCol']);

                if ($childModel instanceof HydratingResultSet) {
                    $childModelObjects = [];

                    foreach ($childModel as $row) {
                        $childModelObjects[] = $row;
                    }

                    $childModel = $childModelObjects;
                }

                $model->$setMethod($childModel);
            }
        }

        return $model;
    }
public function populate ( $ model , $ children ) { $ allChildren = ( $ children === true ) ? true : false ; $ children = ( is_array ( $ children ) ) ? $ children : [ ] ; foreach ( $ this -> getReferenceMap ( ) as $ name => $ options ) { if ( $ allChildren || in_array ( $ name , $ children ) ) { $ service = $ this -> getRelatedService ( $ name ) ; $ getIdMethod = 'get' . ucfirst ( $ options [ 'refCol' ] ) ; $ setMethod = $ options [ 'setMethod' ] ?? 'set' . ucfirst ( $ name ) ; $ getMethod = $ options [ 'getMethod' ] ?? 'getById' ; $ childModel = $ service -> $ getMethod ( $ model -> $ getIdMethod ( ) , $ options [ 'refCol' ] ) ; if ( $ childModel instanceof HydratingResultSet ) { $ childModelObjects = [ ] ; foreach ( $ childModel as $ row ) { $ childModelObjects [ ] = $ row ; } $ childModel = $ childModelObjects ; } $ model -> $ setMethod ( $ childModel ) ; } } return $ model ; }
populate relational records.

@param \UthandoCommon\Model\Model $model
@param bool|array $children
@return \UthandoCommon\Model\Model
populate relational records .