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
6 changes: 6 additions & 0 deletions src/Configuration/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ public function getExtendRepository(string $entityName): string

return $extendRepository;
}

public function isExtendeRepository(
string $repository,
): bool {
return static::DEFAULT_REPOSITORY_EXTEND !== $repository;
}
}
3 changes: 3 additions & 0 deletions src/Generator/RepositoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ private function generateRepository(array $allMetadata, string $bundleName, Clas
$idType = $idField['type'];
}
$extendClass = $this->configurator->getExtendRepository($entityClasspath);
$isExtendedClass = $this->configurator->isExtendeRepository($extendClass);

$renderedTemplate = $this->templateService->renderTopClass(
$extendClass,
$isExtendedClass,
$entityNamespace,
$entityClasspath,
$entityClassname,
Expand Down
2 changes: 2 additions & 0 deletions src/Generator/TemplateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(

public function renderTopClass(
string $extendClass,
bool $isExtendedClass,
string $namespace,
string $entityClasspath,
string $entityClassname,
Expand All @@ -32,6 +33,7 @@ public function renderTopClass(
'entityClasspath' => $entityClasspath,
'entityClassname' => $entityClassname,
'extendClass' => $extendClass,
'isExtendedClass' => $isExtendedClass,
'bundleName' => $bundleName,
'entityDql' => $entityDql,
'idType' => $idType,
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/views/Generator/TopRepositoryTemplate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class {{ entityClassname }}Base extends {{ extendClass }} implements FilterByInt
ManagerRegistry $registry,
string $entity = \{{ entityClasspath }}::class,
) {
{% if isExtendedClass %}
parent::__construct($appCache, $registry, $entity);
{% else %}
parent::__construct($registry, $entity);
{% endif %}
}

public static function getName(): string
Expand Down
Loading