Create a new repository

[MAILPOET-2439]
This commit is contained in:
Pavel Dohnal
2019-10-24 11:03:35 +02:00
committed by Jack Kitterhing
parent 2a3445f806
commit 368ed59f2a
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace MailPoet\Cron\Workers\StatsNotifications;
use MailPoet\Doctrine\Repository;
use MailPoet\Entities\StatsNotificationEntity;
class StatsNotificationsRepository extends Repository {
protected function getEntityClassName() {
return StatsNotificationEntity::class;
}
/**
* @param int $newsletter_id
* @return array
*/
public function findAllForNewsletter($newsletter_id) {
return $this->doctrine_repository
->createQueryBuilder('stn')
->join('stn.task', 'tasks')
->join('stn.newsletter', 'n')
->addSelect('tasks')
->where('tasks.type = :taskType')
->setParameter('taskType', Worker::TASK_TYPE)
->andWhere('n.id = :newsletterId')
->setParameter('newsletterId', $newsletter_id)
->getQuery()
->getResult();
}
}