src/ngrest/base/Api.php
public function getWithRelation($actionName)
    {
        $rel = $this->withRelations();
        
        $expand = Yii::$app->request->get('expand', null);
        $relationPrefixes = [];
        foreach (StringHelper::explode($expand, ',', true, true) as $relation) {
            // check for subrelation dot notation.
            $relationPrefixes[] = current(explode(".", $relation));
        }

        // no expand param found, return empty join with array.
        if (empty($relationPrefixes)) {
            return [];
        }

        foreach ($rel as $relationName) {
            // it seem to be the advance strucutre for given actions.
            if (is_array($relationName) &&  isset($rel[$actionName])) {
                return $this->relationsFromExpand($rel[$actionName], $relationPrefixes);
            }
        }
        // simple structure
        return $this->relationsFromExpand($rel, $relationPrefixes);
    }
public function getWithRelation($actionName)
    {
        $rel = $this->withRelations();
        
        $expand = Yii::$app->request->get('expand', null);
        $relationPrefixes = [];
        foreach (StringHelper::explode($expand, ',', true, true) as $relation) {
            // check for subrelation dot notation.
            $relationPrefixes[] = current(explode(".", $relation));
        }

        // no expand param found, return empty join with array.
        if (empty($relationPrefixes)) {
            return [];
        }

        foreach ($rel as $relationName) {
            // it seem to be the advance strucutre for given actions.
            if (is_array($relationName) &&  isset($rel[$actionName])) {
                return $this->relationsFromExpand($rel[$actionName], $relationPrefixes);
            }
        }
        // simple structure
        return $this->relationsFromExpand($rel, $relationPrefixes);
    }
public function getWithRelation ( $ actionName ) { $ rel = $ this -> withRelations ( ) ; $ expand = Yii :: $ app -> request -> get ( 'expand' , null ) ; $ relationPrefixes = [ ] ; foreach ( StringHelper :: explode ( $ expand , ',' , true , true ) as $ relation ) { // check for subrelation dot notation. $ relationPrefixes [ ] = current ( explode ( "." , $ relation ) ) ; } // no expand param found, return empty join with array. if ( empty ( $ relationPrefixes ) ) { return [ ] ; } foreach ( $ rel as $ relationName ) { // it seem to be the advance strucutre for given actions. if ( is_array ( $ relationName ) && isset ( $ rel [ $ actionName ] ) ) { return $ this -> relationsFromExpand ( $ rel [ $ actionName ] , $ relationPrefixes ) ; } } // simple structure return $ this -> relationsFromExpand ( $ rel , $ relationPrefixes ) ; }
Get the relations for the corresponding action name.

Since version 1.2.3 it also checks if the $expand get param is provided for the given relations, otherwise
the relation will not be joined trough `with`. This reduces the database querie time.

@param string $actionName The action name like `index`, `list`, `search`, `relation-call`.
@return array An array with relation names.
@since 1.2.2
Get the relations for the corresponding action name .