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/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public function getConfigTreeBuilder(): TreeBuilder

$rootNode
->children()
->booleanNode('use_interfaces')
->defaultFalse()
->end()
->arrayNode('bundles')
->defaultValue(['App'])
->requiresAtLeastOneElement()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter('tbn_qbrg.generator.template.entity_configuration', $entityConfiguration);
$container->setParameter('tbn_qbrg.generator.template.repository_extension', $repositoryExtensions);
$container->setParameter('tbn_qbrg.generator.template.use_interfaces', $config['use_interfaces']);

//the templates
$container->setParameter('tbn_qbrg.generator.template.top_repository', $config['templates']['top_repository']);
Expand Down
2 changes: 2 additions & 0 deletions src/Generator/TemplateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class TemplateService
{
public function __construct(
private bool $useInterfaces,
private $topRepositoryTemple,
private $columnTemplate,
private $bottomRepositoryTemplate,
Expand All @@ -30,6 +31,7 @@ public function renderTopClass(
): string {
$topClassparameter = array(
'namespace' => $namespace,
'useInterfaces' => $this->useInterfaces,
'entityClasspath' => $entityClasspath,
'entityClassname' => $entityClassname,
'extendClass' => $extendClass,
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
Tbn\QueryBuilderRepositoryGeneratorBundle\Generator\TemplateService:
class: Tbn\QueryBuilderRepositoryGeneratorBundle\Generator\TemplateService
arguments:
- "%tbn_qbrg.generator.template.use_interfaces%"
- "%tbn_qbrg.generator.template.top_repository%"
- "%tbn_qbrg.generator.template.column%"
- "%tbn_qbrg.generator.template.bottom_repository%"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Uid\Uuid;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
{% if useInterfaces %}
use Tbn\QueryBuilderRepositoryGeneratorBundle\Interface\FilterByInterface;
use Tbn\QueryBuilderRepositoryGeneratorBundle\Interface\FilterInInterface;
{% endif %}

/**
* Generated class for filter query builders
*
*/
class {{ entityClassname }}Base extends {{ extendClass }} implements FilterByInterface, FilterInInterface
class {{ entityClassname }}Base extends {{ extendClass }}{% if useInterfaces %} implements FilterByInterface, FilterInInterface{% endif %}
{
const NAME = '{{ entityDql }}';
protected static $parameterIndex = 0;
Expand Down
5 changes: 1 addition & 4 deletions tests/Repository/MyClassRepositoryBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
use Symfony\Component\Uid\Uuid;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Tbn\QueryBuilderRepositoryGeneratorBundle\Interface\FilterByInterface;
use Tbn\QueryBuilderRepositoryGeneratorBundle\Interface\FilterInInterface;

/**
* Generated class for filter query builders
*
*/
class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository implements FilterByInterface, FilterInInterface
{
class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository{
const NAME = 'myClass';
protected static $parameterIndex = 0;

Expand Down
5 changes: 1 addition & 4 deletions tests/Service/ExpectedMyClassRepositoryBase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Uid\Uuid;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Tbn\QueryBuilderRepositoryGeneratorBundle\Interface\FilterByInterface;
use Tbn\QueryBuilderRepositoryGeneratorBundle\Interface\FilterInInterface;

/**
* Generated class for filter query builders
*
*/
class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository implements FilterByInterface, FilterInInterface
{
class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository{
const NAME = 'myClass';
protected static $parameterIndex = 0;

Expand Down
Loading