@param \Interpro\Core\Contracts\Ref\ARef $ref

@return \Interpro\Extractor\Items\AItem
761208
public function create(ARef $ref)
    {
        //Скопировано c QS
        $type = $ref->getType();

        $fields  = $this->collectionFactory->createFieldsCollection();
        $owns    = $this->collectionFactory->createOwnsCollection();
        $refs    = $this->collectionFactory->createRefsCollection();
        $subVars = $this->collectionFactory->createSubVarCollection($ref);

        if($type->getRank() === TypeRank::BLOCK)
        {
            $item = new BlockItem($ref, $fields, $owns, $refs, $subVars);
        }
        elseif($type->getRank() === TypeRank::GROUP)
        {
            $item = new GroupItem($ref, $fields, $owns, $refs, $subVars);
        }
        else
        {
            throw new FeedbackException('При создании элемента передан тип с рангом отличным от блока и группы: '.$type->getRank().'!');
        }

        return $item;
    }
535100
protected function refToArray($ref)
    {
        $offset = 64;

        $len = strlen($ref);

        $div = 0;
        for ($i = 0; $i < $len; $i++) {
            $char = substr($ref, $i, 1);
            if (is_numeric($char)) {
                $div = $i;
                break;
            }
        }
        if ($div < 1) {
            return false;
        }

        $row = substr($ref, $div);

        $place_col = 0;
        $col = 0;
        for ($i = $div - 1; $i >= 0; $i--) {
            $place_weight = pow(26, $place_col);
            $place_value = ord(substr($ref, $i, 1)) - $offset;
            $col += $place_value * $place_weight;
            $place_col++;
        }

        //return as 0 based
        return array("row" => $row - 1, "col" => $col - 1);
    }
414504
public function loadItem($ident, StorableInterface $item = null)
    {
        $key = $this->model()->key();

        return $this->loadItemFromKey($key, $ident, $item);
    }
977489
public function setHead($reference)
    {
        if ($reference instanceof Reference) {
            $this->head = $reference;
        } elseif (is_array($reference)) {
            list ($name, $type) = $reference;
            $this->head = new Reference($name, $type);
        }

        return $this;
    }
878395
public function transform($collection)
    {   
        if (!$collection instanceof Collection) {  
            return null; 
        }
        
        $data = array();
        $accessor = PropertyAccess::createPropertyAccessor();
        
        foreach ($collection as $ref){
            if (!$ref instanceof Select2SortableInterface){
                throw new \InvalidArgumentException('Reference class must be instance of Select2SortableInterface');  
            }
            
            $data[] = $accessor->getValue($ref, $this->inversedProperty)->getId();
        }
        
        $this->collection = $collection;
        
        return implode(',', $data);
    }
117625
public static function ref($ref)
    {
        if (isset($ref['$id'])) {
            if ($ref['$ref'] == self::collectionName()) {
                return self::id($ref['$id']);
            }
        }

        return null;
    }
954440
protected function guessClassDescription($ref)
    {
        $description = '__class_' . $ref->getName() . '_description__';
        if ($ref->isSubclassOf('yii\db\ActiveRecord')) {
            $className = $ref->getName();
            $tableName = $className::tableName();
            $description = "is the model class for table \"{$tableName}\".";
        }

        return $description;
    }
1077602
private function loadExternalRef($reference)
    {
        list($prefix, $path) = parse_external_ref($reference);
        return $this->loaderManager->getLoader($prefix)->load($path);
    }
40218
protected function _getItem( $key, $id, array $ref = array() )
	{
		$criteria = $this->createSearch();
		$criteria->setConditions( $criteria->compare( '==', $key, $id ) );
		$items = $this->searchItems( $criteria, $ref );

		if( ( $item = reset( $items ) ) === false ) {
			throw new MShop_Exception( sprintf( 'Item with ID "%2$s" in "%1$s" not found', $key, $id ) );
		}

		return $item;
	}
283109
function Add($ref) {
		// Expand singular -> plurals
		foreach (array(
			'author' => 'authors',
			'url' => 'urls',
		) as $single => $plural)
			if (isset($ref[$single])) {
				$ref[$plural] = array($ref[$single]);
				unset($ref[$single]);
			}
	
		if (isset($ref['date']))
			$ref['date'] = $this->ToEpoc($ref['date']);

		$this->refs[] = $ref;
	}
1036254
public function sync(ARef $ref, OwnField $own)
    {
        $ownerType = $ref->getType();
        $owner_type_name = $ownerType->getName();
        $own_name = $own->getName();
        $id = $ref->getId();
        $field_type_name = $own->getFieldTypeName();

        if($field_type_name === 'int')
        {
            $model = IntModel::where('entity_name', '=', $owner_type_name)->where('entity_id', '=', $id)->where('name', '=', $own_name)->first();
        }
        elseif($field_type_name === 'timestamp')
        {
            $model = TimestampModel::where('entity_name', '=', $owner_type_name)->where('entity_id', '=', $id)->where('name', '=', $own_name)->first();
        }
        elseif($field_type_name === 'string')
        {
            $model = StringModel::where('entity_name', '=', $owner_type_name)->where('entity_id', '=', $id)->where('name', '=', $own_name)->first();
        }
        elseif($field_type_name === 'text')
        {
            $model = TextModel::where('entity_name', '=', $owner_type_name)->where('entity_id', '=', $id)->where('name', '=', $own_name)->first();
        }
        elseif($field_type_name === 'float')
        {
            $model = FloatModel::where('entity_name', '=', $owner_type_name)->where('entity_id', '=', $id)->where('name', '=', $own_name)->first();
        }
        elseif($field_type_name === 'bool')
        {
            $model = BoolModel::where('entity_name', '=', $owner_type_name)->where('entity_id', '=', $id)->where('name', '=', $own_name)->first();
        }
        else
        {
            throw new SyncException('Scalar синхронизатор не обрабатывает тип '.$field_type_name);
        }

        if(!$model)
        {
            if($field_type_name === 'int')
            {
                IntModel::create(['entity_name' => $owner_type_name, 'entity_id' => $id, 'name' => $own_name, 'value' => 0]);
            }
            elseif($field_type_name === 'timestamp')
            {
                TimestampModel::create(['entity_name' => $owner_type_name, 'entity_id' => $id, 'name' => $own_name, 'value' => time()]);
            }
            elseif($field_type_name === 'string')
            {
                StringModel::create(['entity_name' => $owner_type_name, 'entity_id' => $id, 'name' => $own_name, 'value' => '']);
            }
            elseif($field_type_name === 'text')
            {
                TextModel::create(['entity_name' => $owner_type_name, 'entity_id' => $id, 'name' => $own_name, 'value' => '']);
            }
            elseif($field_type_name === 'float')
            {
                FloatModel::create(['entity_name' => $owner_type_name, 'entity_id' => $id, 'name' => $own_name, 'value' => 0]);
            }
            elseif($field_type_name === 'bool')
            {
                BoolModel::create(['entity_name' => $owner_type_name, 'entity_id' => $id, 'name' => $own_name, 'value' => false]);
            }
        }
    }
1047023
function getReference($table, $ref = null) {
		if (isset($this->references[$table])) {
			if (!strlen($ref)) {
				return current($this->references[$table]);
			}
			if (isset($this->references[$table][$ref])) {
				return $this->references[$table][$ref];
			}
		}
	}
412351
protected function getObjectFormStage() : IForm
    {
        $objectValidationCallbacks = $this->objectValidationCallbacks;

        if ($objectValidationCallbacks) {
            /** @var callable $validationCallback */
            $validationCallback = array_shift($objectValidationCallbacks);

            foreach ($objectValidationCallbacks as $otherCallback) {
                $validationCallback = function ($object) use ($validationCallback, $otherCallback) {
                    return $validationCallback($object) && $otherCallback($object);
                };
            }
        } else {
            $validationCallback = null;
        }

        return ObjectForm::build($this->dataSource, $validationCallback);
    }
344813
public function ref($ref)
    {
        if (substr($ref, 0, 2) !== '#/') {
            // @todo Add support for external (http) refs?
            throw new Exception('Unsupported $ref "' . $ref . '", it should start with "#/"');
        }
        return $this->resolveRef($ref, '#/', $this, []);
    }
32259
private function removeRsfhrParam($ref)
	{
		$session = \System::getContainer()->get('session');
		if (!$session->isStarted()) {
			return;
		}

		$referrerSession = $session->get('referer');
		if (!empty($referrerSession[$ref]['current'])) {
			$referrerSession[$ref]['current'] = preg_replace('(([&?])rsfhr=1(&|$))', '$1', $referrerSession[$ref]['current']);
			$session->set('referer', $referrerSession);
		}
	}
1345258
public function extract(Document $document, Uri $ref)
    {
        $uri     = $this->resolver->resolve($document->getBaseUri(), $ref);
        $doc     = $this->getDocument($uri, $document);
        $result  = $doc->pointer($uri->getFragment());
        $baseUri = $doc->getBaseUri();

        // the extracted fragment gets merged into the root document so we must
        // resolve all $ref keys to the base uri so that the root document knows
        // where to find the $ref values
        array_walk_recursive($result, function (&$item, $key) use ($baseUri) {
            if ($key == '$ref') {
                $item = $this->resolver->resolve($baseUri, new Uri($item))->toString();
            }
        });

        return $result;
    }
97855
public function resolve($reference)
    {
        if (empty($reference)) {
            return $reference;
        }

        if ($this->isResolvableAnonymousReference($reference)) {
            return $this->resolveAnonymousReference($reference);
        }

        return $this->resolveInternal($reference);
    }