src/Db/QSAMapper.php
public function getByRef(ARef $ref, $asUnitMember = false)
    {
        $type  = $ref->getType();
        $rank = $type->getRank();
        $type_name = $type->getName();
        $id = $ref->getId();

        if($rank === TypeRank::GROUP and $asUnitMember)
        {
            $selectionUnit = $this->tuner->getSelection($type_name, 'group');

            $collection = $this->select($selectionUnit);

            return $collection->getItem($id);
        }

        $result = $this->qsQuerier->selectByRef($ref);
        $result = Helpers::laravel_db_result_to_array($result->get());

        if(count($result) === 0)
        {
            throw new QSException('При получении элемента не найдены данные в таблице '.$type_name.': по ссылке '.$ref.'!');
        }

        $refs_array = $this->qsQuerier->getRefValues($type_name, $id);


        $item = $this->factory->create($ref);

        //====================================================поля
        $ownsMetaCollection = $type->getOwns();

        foreach($ownsMetaCollection as $ownMeta)
        {
            $fieldType = $ownMeta->getFieldType();
            $fieldMode = $ownMeta->getMode();

            $field_name = $ownMeta->getName();

            if($this->local($field_name)) //все поля локального хранения - С типы
            {
                $newField = $this->createLocalCField($item, $ownMeta, $result[0]);
            }
            else
            {
                if($fieldMode === TypeMode::MODE_B)
                {
                    $mapper = $this->mappersMediator->getBMapper($fieldType->getFamily());
                    $map = $mapper->getByRef($ref);
                    $newField = $this->createExternalBFieldByRef($item, $ownMeta, $map);
                }
                elseif($fieldMode === TypeMode::MODE_C)
                {
                    $mapper = $this->mappersMediator->getCMapper($fieldType->getFamily());
                    $map = $mapper->getByRef($ref);
                    $newField = $this->createExternalCFieldByRef($item, $ownMeta, $map);
                }
                else
                {
                    throw new QSException('В типе '.$type_name.' обнаружено поле-собственность типа отличного от В или С: '.$field_name.'('.$fieldMode.')!');
                }
            }

            $item->setOwn($newField);
            $item->setField($newField);
        }

        //====================================================ссылки
        $refsMetaCollection = $type->getRefs();

        foreach($refsMetaCollection as $refMeta)
        {
            $newField = $this->createRefField($item, $refMeta, $refs_array);

            $item->setRef($newField);
            $item->setField($newField);
        }

        return $item;
    }
public function getByRef(ARef $ref, $asUnitMember = false)
    {
        $type  = $ref->getType();
        $rank = $type->getRank();
        $type_name = $type->getName();
        $id = $ref->getId();

        if($rank === TypeRank::GROUP and $asUnitMember)
        {
            $selectionUnit = $this->tuner->getSelection($type_name, 'group');

            $collection = $this->select($selectionUnit);

            return $collection->getItem($id);
        }

        $result = $this->qsQuerier->selectByRef($ref);
        $result = Helpers::laravel_db_result_to_array($result->get());

        if(count($result) === 0)
        {
            throw new QSException('При получении элемента не найдены данные в таблице '.$type_name.': по ссылке '.$ref.'!');
        }

        $refs_array = $this->qsQuerier->getRefValues($type_name, $id);


        $item = $this->factory->create($ref);

        //====================================================поля
        $ownsMetaCollection = $type->getOwns();

        foreach($ownsMetaCollection as $ownMeta)
        {
            $fieldType = $ownMeta->getFieldType();
            $fieldMode = $ownMeta->getMode();

            $field_name = $ownMeta->getName();

            if($this->local($field_name)) //все поля локального хранения - С типы
            {
                $newField = $this->createLocalCField($item, $ownMeta, $result[0]);
            }
            else
            {
                if($fieldMode === TypeMode::MODE_B)
                {
                    $mapper = $this->mappersMediator->getBMapper($fieldType->getFamily());
                    $map = $mapper->getByRef($ref);
                    $newField = $this->createExternalBFieldByRef($item, $ownMeta, $map);
                }
                elseif($fieldMode === TypeMode::MODE_C)
                {
                    $mapper = $this->mappersMediator->getCMapper($fieldType->getFamily());
                    $map = $mapper->getByRef($ref);
                    $newField = $this->createExternalCFieldByRef($item, $ownMeta, $map);
                }
                else
                {
                    throw new QSException('В типе '.$type_name.' обнаружено поле-собственность типа отличного от В или С: '.$field_name.'('.$fieldMode.')!');
                }
            }

            $item->setOwn($newField);
            $item->setField($newField);
        }

        //====================================================ссылки
        $refsMetaCollection = $type->getRefs();

        foreach($refsMetaCollection as $refMeta)
        {
            $newField = $this->createRefField($item, $refMeta, $refs_array);

            $item->setRef($newField);
            $item->setField($newField);
        }

        return $item;
    }
@param \Interpro\Core\Contracts\Ref\ARef $ref
@param bool $asUnitMember

@return \Interpro\Extractor\Contracts\Items\AItem