associateRelationsWithAliases() public static méthode

public static associateRelationsWithAliases ( array $relations, string | string[] | null $aliases ) : RelationWithAlias[]
$relations array
$aliases string | string[] | null
Résultat RelationWithAlias[]
 /**
  * @test
  */
 public function shouldAssociateRelationsWithAliasesByRelationNames()
 {
     //given
     $relation1 = new Relation('relation1', 'Test\\OrderProduct', 'id', 'id_product', false);
     $relation2 = new Relation('relation2', 'Test\\OrderProduct', 'id', 'id_product', false);
     //when
     $relationToAlias = ModelQueryBuilderHelper::associateRelationsWithAliases(array($relation1, $relation2), array('relation2' => 'r2'));
     //then
     Assert::thatArray($relationToAlias)->containsExactly(new RelationWithAlias($relation1, null), new RelationWithAlias($relation2, 'r2'));
 }
Exemple #2
0
 private function createModelJoins($relationSelector, $aliases, $type, $on)
 {
     $relations = ModelQueryBuilderHelper::extractRelations($this->_model, $relationSelector);
     $relationWithAliases = ModelQueryBuilderHelper::associateRelationsWithAliases($relations, $aliases);
     return ModelQueryBuilderHelper::createModelJoins($this->getModelAliasOrTable(), $relationWithAliases, $type, $on);
 }