Get a relationship resource for a fully qualified reference.

@param string $fullRelationshipReference
@return \Drp\JsonApiParser\RelationshipResource|null
359680
protected function getRelationshipResourceForReference($fullRelationshipReference)
    {
        $relationshipParts = explode('.', $fullRelationshipReference);

        if (count($relationshipParts) !== 3) {
            return null;
        }

        if ($this->resourceType() !== array_shift($relationshipParts)) {
            return null;
        }

        $relationshipName = array_shift($relationshipParts);
        $relationshipReference = Arr::get(
            $this->mapRelationshipsToIdAndData(),
            $relationshipName
        );
        if ($relationshipReference === null) {
            return null;
        }

        if (Arr::get($relationshipReference, 'type') === array_shift($relationshipParts)) {
            return new RelationshipResource($relationshipName, $relationshipReference);
        }

        return null;
    }
14225
public Relation getRelation_ref() {
    if (RelationMention_Type.featOkTst && ((RelationMention_Type)jcasType).casFeat_relation_ref == null)
      jcasType.jcas.throwFeatMissing("relation_ref", "de.julielab.jules.types.ace.RelationMention");
    return (Relation)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((RelationMention_Type)jcasType).casFeatCode_relation_ref)));}
159762
public function getRelation($contentType = null)
    {
        if (!$this->relation instanceof Collection\Relations) {
            $this->relation = new Collection\Relations();
        }

        if ($contentType !== null) {
            return $this->relation[$contentType];
        }

        return $this->relation;
    }
742689
protected function getQuickSearchRelation($activeRelation, $scenario)
    {
        /** @var ActiveRecord $relationModel */
        $relationModel = new $activeRelation->modelClass();
        $relationModel->scenario = $scenario;

        $parts = explode('\\', $activeRelation->modelClass);
        $modelClass = array_pop($parts);
        $namespace = implode('\\', $parts);
        $searchModelClass = $namespace . '\\search\\' . $modelClass;
        $relationSearchModel = class_exists($searchModelClass) ? new $searchModelClass : new $activeRelation->modelClass;

        return [
            'model'      => $relationModel,
            'searchModel'=> $relationSearchModel,
            'attributes' => [],
        ];
    }
491391
public function getRelatedResourceReference(
        ResourceSet $sourceResourceSet,
        $sourceEntityInstance,
        ResourceSet $targetResourceSet,
        ResourceProperty $targetProperty
    ) {
        $entityClassName = $targetResourceSet->getResourceType()->getInstanceType()->name;
        $entityName = $this->getEntityName($entityClassName);
        $fieldName = $this->getTableName($entityName) . '_id';

        return $this->getResource($targetResourceSet, null, [
            'id' => $sourceEntityInstance->$fieldName
        ]);
    }
114750
public static function getReference() {
		if(self::$entity_manager == null)
			self::initialize();

		return call_user_func_array(array(self::$entity_manager, "getReference"), func_get_args());
	}
557601
public function getRelationships(): array
    {
        return array_column(
            array_filter(array_map(function ($includeKey, $settings) {
                return $settings['relation'] ? [$includeKey, $settings['relation']] : null;
            }, array_keys($this->getIncludeMap()), array_values($this->getIncludeMap()))),
            1, 0
        );
    }
74181
public function getRelation(string $relation) : Relationship
    {
        // We want to run a relationship query without any constrains so that we will
        // not have to remove these where clauses manually which gets really hacky
        // and is error prone while we remove the developer's own where clauses.
        $query = Relationship::noConstraints(function () use ($relation) {
            return $this->entityMap->$relation($this->mapper->newInstance());
        });

        $nested = $this->nestedRelations($relation);

        // If there are nested relationships set on the query, we will put those onto
        // the query instances so that they can be handled after this relationship
        // is loaded. In this way they will all trickle down as they are loaded.
        if (count($nested) > 0) {
            $query->getQuery()->with($nested);
        }

        return $query;
    }
1320690
public function getReference(ConnectionInterface $con = null)
    {
        if ($this->aReference === null && ($this->reference_id !== null)) {
            $this->aReference = ChildReferenceQuery::create()->findPk($this->reference_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aReference->addVideos($this);
             */
        }

        return $this->aReference;
    }
757820
public function getResources(
        ResourceTransformer $resourceTransformer,
        ResourceDefinition $resourceDefinition,
        Context $context,
        $request = null
    ) {
        if (!$this->hasApplicableContentType()) {
            return null;
        }

        $rawContent = $this->getRawContent();
        $content = json_decode($rawContent, true);

        if (!$content) {
            throw new \InvalidArgumentException("Could not decode body: " . $rawContent);
        }

        $resourceCollection = $resourceTransformer->getResourceFactory()->createResourceCollection();

        if (isset($content[ResourceTransformer::RELATIONSHIP_ITEMS])) {
            // This is a list of items
            foreach ($content[ResourceTransformer::RELATIONSHIP_ITEMS] as $item) {
                $resource = $resourceTransformer->fromArray(
                    $resourceDefinition,
                    $item,
                    $context
                );
                $resourceCollection->add($resource);
            }
        } else {
            $resource = $resourceTransformer->fromArray(
                $resourceDefinition,
                $content,
                $context
            );
            $resourceCollection->add($resource);
        }

        return $resourceCollection;
    }
442321
public function getRelation($name)
    {
        // We want to run a relationship query without any constrains so that we will
        // not have to remove these where clauses manually which gets really hacky
        // and error prone. We don't want constraints because we add eager ones.
        $relation = Relation::noConstraints(function () use ($name) {
            try {
                return $this->getModel()->{$name}();
            } catch (BadMethodCallException $e) {
                throw new RuntimeException("Call to undefined relationship [".$name."] on model [".get_class($this->getModel())."].");
            }
        });

        $nested = $this->relationsNestedUnder($name);

        // If there are nested relationships set on the query, we will put those onto
        // the query instances so that they can be handled after this relationship
        // is loaded. In this way they will all trickle down as they are loaded.
        if (count($nested) > 0) {
            $relation->getQuery()->with($nested);
        }

        return $relation;
    }
814518
public function getRelatedResourceSet(
        QueryType $queryType,
        ResourceSet $sourceResourceSet,
        $sourceEntityInstance,
        ResourceSet $targetResourceSet,
        ResourceProperty $targetProperty,
        $filterInfo = null,
        $orderBy = null,
        $top = null,
        $skip = null
    ) {
        // Correct filter
        $srcClass = get_class($sourceEntityInstance);
        $filterFieldName = $this->getTableName($this->getEntityName($srcClass)) . '_id';
        $navigationPropertiesUsedInTheFilterClause = null;
        $filterExpAsDataSourceExp = '';
        if ($filterInfo) {
            $navigationPropertiesUsedInTheFilterClause = $filterInfo->getNavigationPropertiesUsed();
            $filterExpAsDataSourceExp = $filterInfo->getExpressionAsString();
        }
        $filterExpAsDataSourceExp .= $filterExpAsDataSourceExp ? ' AND ' : '';
        $filterExpAsDataSourceExp .= $filterFieldName . ' = ' . $sourceEntityInstance->id;
        $completeFilterInfo = new FilterInfo($navigationPropertiesUsedInTheFilterClause, $filterExpAsDataSourceExp);

        return $this->getResourceSet($queryType, $targetResourceSet, $completeFilterInfo, $orderBy, $top, $skip);
    }
435468
public function getRelation($name)
    {
        // We want to run a relationship query without any constrains so that we will
        // not have to remove these where clauses manually which gets really hacky
        // and error prone. We don't want constraints because we add eager ones.
        $relation = Relation::noConstraints(function () use ($name) {
            $instance = $this->getModel()->newInstance();
            if (method_exists($instance, $name)) {
                return $instance->$name();
            }

            if ($relation = $instance->getRelationshipFromConfig($name)) {
                return $relation;
            }

            throw new RuntimeException("Call to undefined relationship [{$name}] on resource [{$this->getModel()->getTable()}].");
        });

        $nested = $this->relationsNestedUnder($name);

        // If there are nested relationships set on the query, we will put those onto
        // the query instances so that they can be handled after this relationship
        // is loaded. In this way they will all trickle down as they are loaded.
        if (count($nested) > 0) {
            $relation->getQuery()->with($nested);
        }

        return $relation;
    }
680371
final public function getRelated($relatedProperty) {
		
		$cacheName = $relatedProperty . 'RelatedObject';
		
		// object exists in cache, return it
		if ($this->issetCache($cacheName)) {
			return $this->getCache($cacheName);
		}
		
		// get table foreign-keys
		$foreignKeys = $this->db->getForeignKeys(static::TABLE_NAME);
		
		// get field name by mapped property
		$relatedField = $this->getMappedField($relatedProperty);
		
		// the table referenced by fk
		$referencedTable = NULL;
			
		// search the fk-table
		foreach ($foreignKeys as $fk) {
			if ($fk->COLUMN_NAME == $relatedField) {
				$referencedTable  = $fk->REFERENCED_TABLE_NAME;
				$referencedColumn = $fk->REFERENCED_COLUMN_NAME;
				break;
			}
		}
		
		// if not table is referenced, raise an error
		if (!$referencedTable) {
			$this->addError('Property ' . $relatedProperty . ' has not a foreign-key mapped into DB');
			return NULL;
		}
		
		// class that maps the referenced table
		$relatedClass = NULL;
		$loadedClasses = \get_declared_classes();
		
		// search in loaded classes
		foreach ($loadedClasses as $c) {
			if (is_subclass_of($c, 'Pair\ActiveRecord') and property_exists($c, 'TABLE_NAME') and $c::TABLE_NAME == $referencedTable) {
				$relatedClass = $c;
				break;
			}
		}
			
		// class cannot be found
		if (!$relatedClass) {
			
			// if not found, search in the whole application (FIXME encapsulation violated here...)
			$classes = Utilities::getActiveRecordClasses();
			
			// search for required one
			foreach ($classes as $class => $opts) {
				if ($opts['tableName'] == $referencedTable) {
					include_once($opts['folder'] . '/' . $opts['file']);
					$relatedClass = $class;
					break;
				}
			}
			
		}
		
		// class cannot be found
		if (!$relatedClass) {
			$this->addError('Table ' . $referencedTable . ' has not any Pair-class mapping');
			return NULL;
		}
		
		// create the new wanted Pair object
		$obj = new $relatedClass($this->$relatedProperty);
		
		// if loaded, return it otherwise NULL
		$ret = ($obj->isLoaded() ? $obj : NULL);
		
		// related object is being registered in cache of this object
		$this->setCache($cacheName, $ret);
		
		return $ret;
		
	}
64462
protected function getFinalEntityMapper(array $nestedRelations) : IEntityMapper
    {
        $entityMapper = null;

        foreach (array_reverse($nestedRelations) as $relation) {
            if ($relation instanceof EntityRelation) {
                $entityMapper = $relation->getEntityMapper();
                break;
            }
        }

        return $entityMapper ?: $this->rootEntityMapper;
    }
1267344
protected function recordFetchedRelationship(RelationshipResource $relationship)
    {
        $this->fetchedRelationships[] = $this->resource['type'] .
            '.' . $relationship->getName() .
            '.' . $relationship->getType();
    }
83109
protected function getMerchantRelationshipByKey(string $merchantRelationshipKey): MerchantRelationshipTransfer
    {
        if ($this->merchantRelationshipsHeapSize > static::MERCHANT_RELATIONSHIPS_HEAP_LIMIT) {
            $this->merchantRelationshipsHeapSize = 0;
            $this->merchantRelationshipsHeap = [];
        }

        if (!isset($this->merchantRelationshipsHeap[$merchantRelationshipKey])) {
            $merchantRelationshipTransfer = $this->merchantRelationshipFacade->findMerchantRelationshipByKey(
                (new MerchantRelationshipTransfer())->setMerchantRelationshipKey($merchantRelationshipKey)
            );

            if (!$merchantRelationshipTransfer) {
                throw new EntityNotFoundException(sprintf('Merchant relationship not found: %s', $merchantRelationshipKey));
            }

            $this->merchantRelationshipsHeap[$merchantRelationshipKey] = $merchantRelationshipTransfer;
            $this->merchantRelationshipsHeapSize++;
        }

        return $this->merchantRelationshipsHeap[$merchantRelationshipKey];
    }