Add new method into repository
[MAILPOET-4309]
This commit is contained in:
@@ -11,12 +11,26 @@ use MailPoet\Entities\ScheduledTaskSubscriberEntity;
|
||||
use MailPoet\Entities\SendingQueueEntity;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Carbon\Carbon;
|
||||
use MailPoetVendor\Carbon\CarbonImmutable;
|
||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||
use MailPoetVendor\Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
/**
|
||||
* @extends Repository<ScheduledTaskEntity>
|
||||
*/
|
||||
class ScheduledTasksRepository extends Repository {
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $entityManager,
|
||||
WPFunctions $wp
|
||||
) {
|
||||
$this->wp = $wp;
|
||||
parent::__construct($entityManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NewsletterEntity $newsletter
|
||||
* @return ScheduledTaskEntity[]
|
||||
@@ -210,6 +224,18 @@ class ScheduledTasksRepository extends Repository {
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function touchAllByIds(array $ids): void {
|
||||
$now = CarbonImmutable::createFromTimestamp((int)$this->wp->currentTime('timestamp'));
|
||||
$this->entityManager->createQueryBuilder()
|
||||
->update(ScheduledTaskEntity::class, 'st')
|
||||
->set('st.updatedAt', ':updatedAt')
|
||||
->setParameter('updatedAt', $now)
|
||||
->where('st.id IN (:ids)')
|
||||
->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY)
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
protected function findByTypeAndStatus($type, $status, $limit = null, $future = false) {
|
||||
$queryBuilder = $this->doctrineRepository->createQueryBuilder('st')
|
||||
->select('st')
|
||||
|
Reference in New Issue
Block a user