public function getRelation($filterContentType = null, $options = [])
    {
        if (empty($this->relation)) {
            return false; // nothing to do here.
        }

        // Backwards compatibility: If '$options' is a string, assume we passed an id
        if (!is_array($options)) {
            $options = [
                'id' => $options,
            ];
        }

        $records = [];

        foreach ($this->relation as $contenttype => $ids) {
            if (!empty($filterContentType) && ($contenttype != $filterContentType)) {
                continue; // Skip other contenttypes, if we requested a specific type.
            }
            sort($ids);
            $params = ['hydrate' => true];
            $where = ['id' => implode(' || ', $ids)];
            $dummy = false;

            // If there were other options add them to the 'where'. We potentially overwrite the 'id' here.
            if (!empty($options)) {
                foreach ($options as $option => $value) {
                    $where[$option] = $value;
                }
            }

            // Only get published items, unless specifically stated otherwise.
            if (!isset($where['status'])) {
                $where['status'] = 'published';
            }

            $tempResult = $this->app['storage']->getContent($contenttype, $params, $dummy, $where);

            if (empty($tempResult)) {
                continue; // Go ahead if content not found.
            }

            // Variable $temp_result can be an array of object.
            if (is_array($tempResult)) {
                $records = array_merge($records, $tempResult);
            } else {
                $records[] = $tempResult;
            }
        }

        return $records;
    }
public function getRelation($filterContentType = null, $options = [])
    {
        if (empty($this->relation)) {
            return false; // nothing to do here.
        }

        // Backwards compatibility: If '$options' is a string, assume we passed an id
        if (!is_array($options)) {
            $options = [
                'id' => $options,
            ];
        }

        $records = [];

        foreach ($this->relation as $contenttype => $ids) {
            if (!empty($filterContentType) && ($contenttype != $filterContentType)) {
                continue; // Skip other contenttypes, if we requested a specific type.
            }
            sort($ids);
            $params = ['hydrate' => true];
            $where = ['id' => implode(' || ', $ids)];
            $dummy = false;

            // If there were other options add them to the 'where'. We potentially overwrite the 'id' here.
            if (!empty($options)) {
                foreach ($options as $option => $value) {
                    $where[$option] = $value;
                }
            }

            // Only get published items, unless specifically stated otherwise.
            if (!isset($where['status'])) {
                $where['status'] = 'published';
            }

            $tempResult = $this->app['storage']->getContent($contenttype, $params, $dummy, $where);

            if (empty($tempResult)) {
                continue; // Go ahead if content not found.
            }

            // Variable $temp_result can be an array of object.
            if (is_array($tempResult)) {
                $records = array_merge($records, $tempResult);
            } else {
                $records[] = $tempResult;
            }
        }

        return $records;
    }
public function getRelation ( $ filterContentType = null , $ options = [ ] ) { if ( empty ( $ this -> relation ) ) { return false ; // nothing to do here. } // Backwards compatibility: If '$options' is a string, assume we passed an id if ( ! is_array ( $ options ) ) { $ options = [ 'id' => $ options , ] ; } $ records = [ ] ; foreach ( $ this -> relation as $ contenttype => $ ids ) { if ( ! empty ( $ filterContentType ) && ( $ contenttype != $ filterContentType ) ) { continue ; // Skip other contenttypes, if we requested a specific type. } sort ( $ ids ) ; $ params = [ 'hydrate' => true ] ; $ where = [ 'id' => implode ( ' || ' , $ ids ) ] ; $ dummy = false ; // If there were other options add them to the 'where'. We potentially overwrite the 'id' here. if ( ! empty ( $ options ) ) { foreach ( $ options as $ option => $ value ) { $ where [ $ option ] = $ value ; } } // Only get published items, unless specifically stated otherwise. if ( ! isset ( $ where [ 'status' ] ) ) { $ where [ 'status' ] = 'published' ; } $ tempResult = $ this -> app [ 'storage' ] -> getContent ( $ contenttype , $ params , $ dummy , $ where ) ; if ( empty ( $ tempResult ) ) { continue ; // Go ahead if content not found. } // Variable $temp_result can be an array of object. if ( is_array ( $ tempResult ) ) { $ records = array_merge ( $ records , $ tempResult ) ; } else { $ records [ ] = $ tempResult ; } } return $ records ; }
Gets one or more related records.

@param string $filterContentType ContentType to filter returned results on
@param array  $options           a set of 'WHERE' options to apply to the filter

Backward compatibility note:
The $options parameter used to be $filterid, an integer

@return \Bolt\Legacy\Content[]
Gets one or more related records .