public function reverse() {
		if($this->reverseRelation !== null)
			return $this->reverseRelation;

		$origEntityName = $this->entityClass;
		$entityName = preg_replace('/^\\\/', '', $origEntityName);

		$relationDefinition = $this->getTargetDefinition();
		$name = $this->name;

		$rev_relations = [];
		foreach($this->dataMapper->relations($relationDefinition) as $rev_rel_name=>$rev_rel) {
			if($rev_rel->isPolymorphic()) {
				if(in_array($entityName, $rev_rel->get('entities'))) {
					if($this->get('for') !== null && $this->get('for') !== $rev_rel_name)
						continue;
					if($rev_rel->get('for') !== null && $rev_rel->get('for') !== $name)
						continue;
					$rev_relations[] = $rev_rel;
				}
			}
			else {
				$relEntityClass = preg_replace('/^\\\/', '', $rev_rel->get('entity'));
				if($relEntityClass === $entityName || $this->get('as') === $rev_rel->get('entity')) {
					if($rev_rel_name === $name)
						continue;
					if($this->get('for') !== null && $this->get('for') !== $rev_rel_name)
						continue;
					if($rev_rel->get('for') !== null && $rev_rel->get('for') !== $name)
						continue;
					$rev_relations[] = $rev_rel;
				}
			}
		}

		if(count($rev_relations) == 0)
			throw new \Exception('No reverse relation for '.$entityName.': '.$name);
		elseif(count($rev_relations) > 1)
			throw new \Exception('Multiple reverse relations for '.$entityName.': '.$name);
		else {
			$this->reverseRelation = $rev_relations[0];
			return $rev_relations[0];
		}
	}
public function reverse() {
		if($this->reverseRelation !== null)
			return $this->reverseRelation;

		$origEntityName = $this->entityClass;
		$entityName = preg_replace('/^\\\/', '', $origEntityName);

		$relationDefinition = $this->getTargetDefinition();
		$name = $this->name;

		$rev_relations = [];
		foreach($this->dataMapper->relations($relationDefinition) as $rev_rel_name=>$rev_rel) {
			if($rev_rel->isPolymorphic()) {
				if(in_array($entityName, $rev_rel->get('entities'))) {
					if($this->get('for') !== null && $this->get('for') !== $rev_rel_name)
						continue;
					if($rev_rel->get('for') !== null && $rev_rel->get('for') !== $name)
						continue;
					$rev_relations[] = $rev_rel;
				}
			}
			else {
				$relEntityClass = preg_replace('/^\\\/', '', $rev_rel->get('entity'));
				if($relEntityClass === $entityName || $this->get('as') === $rev_rel->get('entity')) {
					if($rev_rel_name === $name)
						continue;
					if($this->get('for') !== null && $this->get('for') !== $rev_rel_name)
						continue;
					if($rev_rel->get('for') !== null && $rev_rel->get('for') !== $name)
						continue;
					$rev_relations[] = $rev_rel;
				}
			}
		}

		if(count($rev_relations) == 0)
			throw new \Exception('No reverse relation for '.$entityName.': '.$name);
		elseif(count($rev_relations) > 1)
			throw new \Exception('Multiple reverse relations for '.$entityName.': '.$name);
		else {
			$this->reverseRelation = $rev_relations[0];
			return $rev_relations[0];
		}
	}
public function reverse ( ) { if ( $ this -> reverseRelation !== null ) return $ this -> reverseRelation ; $ origEntityName = $ this -> entityClass ; $ entityName = preg_replace ( '/^\\\/' , '' , $ origEntityName ) ; $ relationDefinition = $ this -> getTargetDefinition ( ) ; $ name = $ this -> name ; $ rev_relations = [ ] ; foreach ( $ this -> dataMapper -> relations ( $ relationDefinition ) as $ rev_rel_name => $ rev_rel ) { if ( $ rev_rel -> isPolymorphic ( ) ) { if ( in_array ( $ entityName , $ rev_rel -> get ( 'entities' ) ) ) { if ( $ this -> get ( 'for' ) !== null && $ this -> get ( 'for' ) !== $ rev_rel_name ) continue ; if ( $ rev_rel -> get ( 'for' ) !== null && $ rev_rel -> get ( 'for' ) !== $ name ) continue ; $ rev_relations [ ] = $ rev_rel ; } } else { $ relEntityClass = preg_replace ( '/^\\\/' , '' , $ rev_rel -> get ( 'entity' ) ) ; if ( $ relEntityClass === $ entityName || $ this -> get ( 'as' ) === $ rev_rel -> get ( 'entity' ) ) { if ( $ rev_rel_name === $ name ) continue ; if ( $ this -> get ( 'for' ) !== null && $ this -> get ( 'for' ) !== $ rev_rel_name ) continue ; if ( $ rev_rel -> get ( 'for' ) !== null && $ rev_rel -> get ( 'for' ) !== $ name ) continue ; $ rev_relations [ ] = $ rev_rel ; } } } if ( count ( $ rev_relations ) == 0 ) throw new \ Exception ( 'No reverse relation for ' . $ entityName . ': ' . $ name ) ; elseif ( count ( $ rev_relations ) > 1 ) throw new \ Exception ( 'Multiple reverse relations for ' . $ entityName . ': ' . $ name ) ; else { $ this -> reverseRelation = $ rev_relations [ 0 ] ; return $ rev_relations [ 0 ] ; } }
Get the reverse relation instance.
@return EntityRelation
Get the reverse relation instance .