Load list of segments on form editor page using doctrine

[MAILPOET-3164]
This commit is contained in:
Rostislav Wolny
2021-01-15 16:37:35 +01:00
committed by Veljko V
parent 09fa34f6e6
commit ade48fc359
2 changed files with 17 additions and 4 deletions

View File

@ -59,7 +59,7 @@ class SegmentSubscribersRepository {
* This method is fetches list of all segments basic data and count of subscribed subscribers.
* @return array<array{id: string, name: string, type: string, subscribers: int}>
*/
public function getSimpleSegmentListWithSubscribersCounts(): array {
public function getSimpleSegmentListWithSubscribersCounts(string $type = null): array {
$subscribersTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName();
$subscribersSegmentsTable = $this->entityManager->getClassMetadata(SubscriberSegmentEntity::class)->getTableName();
$segmentsTable = $this->entityManager->getClassMetadata(SegmentEntity::class)->getTableName();
@ -82,6 +82,13 @@ class SegmentSubscribersRepository {
->addGroupBy('segments.type')
->orderBy('segments.name')
->setParameter('statusSubscribed', SubscriberEntity::STATUS_SUBSCRIBED);
if ($type) {
$segmentsDataQuery
->andWhere('segments.type = :typeParam')
->setParameter('typeParam', $type);
}
$statement = $this->executeQuery($segmentsDataQuery);
$segments = $statement->fetchAll();