LeanMapper\Result::getReferencingRows PHP Method

getReferencingRows() public method

Creates new array of Row instances pointing to requested row in referencing Result
public getReferencingRows ( integer $id, string $table, string | null $viaColumn = null, Filtering $filtering = null, string $strategy = null ) : Row[]
$id integer
$table string
$viaColumn string | null
$filtering Filtering
$strategy string
return Row[]
    public function getReferencingRows($id, $table, $viaColumn = null, Filtering $filtering = null, $strategy = null)
    {
        if ($viaColumn === null) {
            $viaColumn = $this->mapper->getRelationshipColumn($table, $this->table);
        }
        $referencingResult = $this->getReferencingResult($table, $viaColumn, $filtering, $strategy);
        $resultHash = spl_object_hash($referencingResult);
        if (!isset($this->index[$resultHash])) {
            $column = $this->isAlias($viaColumn) ? $this->trimAlias($viaColumn) : $viaColumn;
            $this->index[$resultHash] = [];
            foreach ($referencingResult as $key => $row) {
                $this->index[$resultHash][$row[$column]][] = new Row($referencingResult, $key);
            }
        }
        if (!isset($this->index[$resultHash][$id])) {
            return [];
        }
        return $this->index[$resultHash][$id];
    }