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
17 changes: 17 additions & 0 deletions src/Resources/views/Generator/AssociationTemplate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@
);
}

public function countBy{{ column }}(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterBy{{ column }}($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function deleteBy{{ column }}(
mixed $value,
): void {
Expand Down
17 changes: 17 additions & 0 deletions src/Resources/views/Generator/ColumnTemplate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@
);
}

public function countBy{{ column }}(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterBy{{ column }}($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsBy{{ column }}(
mixed $value,
bool $useQueryCache = false,
Expand Down
68 changes: 68 additions & 0 deletions tests/Repository/MyClassRepositoryBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,23 @@ public function findOneById(
);
}

public function countById(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterById($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsById(
mixed $value,
bool $useQueryCache = false,
Expand Down Expand Up @@ -593,6 +610,23 @@ public function findOneByNumber(
);
}

public function countByNumber(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterByNumber($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsByNumber(
mixed $value,
bool $useQueryCache = false,
Expand Down Expand Up @@ -728,6 +762,23 @@ public function findOneByName(
);
}

public function countByName(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterByName($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsByName(
mixed $value,
bool $useQueryCache = false,
Expand Down Expand Up @@ -929,6 +980,23 @@ public function findOneByForeignClasses(
);
}

public function countByForeignClasses(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterByForeignClasses($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function deleteByForeignClasses(
mixed $value,
): void {
Expand Down
68 changes: 68 additions & 0 deletions tests/Service/ExpectedMyClassRepositoryBase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,23 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
);
}

public function countById(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterById($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsById(
mixed $value,
bool $useQueryCache = false,
Expand Down Expand Up @@ -593,6 +610,23 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
);
}

public function countByNumber(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterByNumber($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsByNumber(
mixed $value,
bool $useQueryCache = false,
Expand Down Expand Up @@ -728,6 +762,23 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
);
}

public function countByName(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterByName($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function existsByName(
mixed $value,
bool $useQueryCache = false,
Expand Down Expand Up @@ -929,6 +980,23 @@ class MyClassRepositoryBase extends \Doctrine\Bundle\DoctrineBundle\Repository\S
);
}

public function countByForeignClasses(
mixed $value,
bool $useQueryCache = false,
?string $cacheId = null,
array $resultCacheTags = [],
): int {
$qb = $this->getNewQueryBuilder();
static::filterByForeignClasses($qb, $value);

return static::getQueryBuilderCount(
qb: $qb,
useQueryCache: $useQueryCache,
cacheId: $cacheId,
resultCacheTags: $resultCacheTags,
);
}

public function deleteByForeignClasses(
mixed $value,
): void {
Expand Down
Loading