Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Generator/RepositoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ private function generateRepository(array $allMetadata, string $bundleName, Clas
$associationMappings = $meta->associationMappings;
$customRepositoryClassName = $meta->customRepositoryClassName;

$rootEntityName = $meta->rootEntityName;

$pathParts = explode('\\', $customRepositoryClassName);
$entityClassname = end($pathParts);

Expand All @@ -80,6 +82,7 @@ private function generateRepository(array $allMetadata, string $bundleName, Clas
$bundleName,
$entityDql,
$idType,
$rootEntityName,
);

//parse the columns
Expand Down
2 changes: 2 additions & 0 deletions src/Generator/TemplateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function renderTopClass(
?string $bundleName,
string $entityDql,
$idType,
$rootEntityName,
): string {
$topClassparameter = array(
'namespace' => $namespace,
Expand All @@ -34,6 +35,7 @@ public function renderTopClass(
'bundleName' => $bundleName,
'entityDql' => $entityDql,
'idType' => $idType,
'rootEntityName' => $rootEntityName,
);

return $this->twig->render($this->topRepositoryTemple, $topClassparameter);
Expand Down
9 changes: 9 additions & 0 deletions src/Resources/views/Generator/TopRepositoryTemplate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class {{ entityClassname }}Base extends {{ extendClass }}
});
}

/**
* @return \{{rootEntityName}}[]
*/
public function getQueryBuilderResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand All @@ -100,6 +103,9 @@ class {{ entityClassname }}Base extends {{ extendClass }}
);
}

/**
* @return \{{rootEntityName}}
*/
public function getQueryBuilderSingleResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand All @@ -115,6 +121,9 @@ class {{ entityClassname }}Base extends {{ extendClass }}
);
}

/**
* @return ?\{{rootEntityName}}
*/
public function getQueryBuilderOneOrNullResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand Down
9 changes: 9 additions & 0 deletions tests/Repository/MyClassRepositoryBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ private function getCachedResult(
});
}

/**
* @return \Tbn\QueryBuilderRepositoryGeneratorBundle\Tests\Entity\MyClass[]
*/
public function getQueryBuilderResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand All @@ -100,6 +103,9 @@ public function getQueryBuilderResult(
);
}

/**
* @return \Tbn\QueryBuilderRepositoryGeneratorBundle\Tests\Entity\MyClass
*/
public function getQueryBuilderSingleResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand All @@ -115,6 +121,9 @@ public function getQueryBuilderSingleResult(
);
}

/**
* @return ?\Tbn\QueryBuilderRepositoryGeneratorBundle\Tests\Entity\MyClass
*/
public function getQueryBuilderOneOrNullResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand Down
9 changes: 9 additions & 0 deletions tests/Service/ExpectedMyClassRepositoryBase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
});
}

/**
* @return \Tbn\QueryBuilderRepositoryGeneratorBundle\Tests\Entity\MyClass[]
*/
public function getQueryBuilderResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand All @@ -100,6 +103,9 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
);
}

/**
* @return \Tbn\QueryBuilderRepositoryGeneratorBundle\Tests\Entity\MyClass
*/
public function getQueryBuilderSingleResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand All @@ -115,6 +121,9 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
);
}

/**
* @return ?\Tbn\QueryBuilderRepositoryGeneratorBundle\Tests\Entity\MyClass
*/
public function getQueryBuilderOneOrNullResult(
QueryBuilder $qb,
bool $useQueryCache = false,
Expand Down
Loading