protected function import(string $name, string $relationship, array $options = []): Field
    {
        $source = $this->get($relationship);
        $reference = $source->getReferences();

        $class = off($reference, 'class');
        if (!class_exists($class)) {
            throw new SimplesRunTimeError("Cant not import '{$name}' from '{$class}'");
        }

        /** @var DataMapper $class */
        $import = $class::instance()->get($name);

        $options = array_merge($import->getOptions(), $options);

        $from = new Field($import->getCollection(), $name, $import->getType(), $options);
        $this->fields[$name] = $from->from($source);

        return $this->fields[$name];
    }
protected function import(string $name, string $relationship, array $options = []): Field
    {
        $source = $this->get($relationship);
        $reference = $source->getReferences();

        $class = off($reference, 'class');
        if (!class_exists($class)) {
            throw new SimplesRunTimeError("Cant not import '{$name}' from '{$class}'");
        }

        /** @var DataMapper $class */
        $import = $class::instance()->get($name);

        $options = array_merge($import->getOptions(), $options);

        $from = new Field($import->getCollection(), $name, $import->getType(), $options);
        $this->fields[$name] = $from->from($source);

        return $this->fields[$name];
    }
protected function import ( string $ name , string $ relationship , array $ options = [ ] ) : Field { $ source = $ this -> get ( $ relationship ) ; $ reference = $ source -> getReferences ( ) ; $ class = off ( $ reference , 'class' ) ; if ( ! class_exists ( $ class ) ) { throw new SimplesRunTimeError ( "Cant not import '{$name}' from '{$class}'" ) ; } /** @var DataMapper $class */ $ import = $ class :: instance ( ) -> get ( $ name ) ; $ options = array_merge ( $ import -> getOptions ( ) , $ options ) ; $ from = new Field ( $ import -> getCollection ( ) , $ name , $ import -> getType ( ) , $ options ) ; $ this -> fields [ $ name ] = $ from -> from ( $ source ) ; return $ this -> fields [ $ name ] ; }
Allow use this field like readonly in read filtering and getting it in record
@param string $name
@param string $relationship
@param array $options
@return Field
@throws SimplesRunTimeError
Allow use this field like readonly in read filtering and getting it in record