diff --git a/lib/Segments/DynamicSegments/DynamicSegmentsListingRepository.php b/lib/Segments/DynamicSegments/DynamicSegmentsListingRepository.php index 166c24885d..8101af595f 100644 --- a/lib/Segments/DynamicSegments/DynamicSegmentsListingRepository.php +++ b/lib/Segments/DynamicSegments/DynamicSegmentsListingRepository.php @@ -4,7 +4,12 @@ namespace MailPoet\Segments\DynamicSegments; use MailPoet\Entities\SegmentEntity; use MailPoet\Segments\SegmentListingRepository; +use MailPoetVendor\Doctrine\ORM\QueryBuilder; class DynamicSegmentsListingRepository extends SegmentListingRepository { - protected $types = [SegmentEntity::TYPE_DYNAMIC]; + protected function applyParameters(QueryBuilder $queryBuilder, array $parameters) { + $queryBuilder + ->andWhere('s.type = :type') + ->setParameter('type', SegmentEntity::TYPE_DYNAMIC); + } } diff --git a/lib/Segments/SegmentListingRepository.php b/lib/Segments/SegmentListingRepository.php index a75ab5ca8b..360a909b0b 100644 --- a/lib/Segments/SegmentListingRepository.php +++ b/lib/Segments/SegmentListingRepository.php @@ -15,8 +15,6 @@ class SegmentListingRepository extends ListingRepository { /** @var WooCommerce */ private $wooCommerce; - protected $types = [SegmentEntity::TYPE_DEFAULT, SegmentEntity::TYPE_WP_USERS]; - public function __construct( EntityManager $entityManager, WooCommerce $wooCommerce @@ -52,7 +50,7 @@ class SegmentListingRepository extends ListingRepository { } protected function applyParameters(QueryBuilder $queryBuilder, array $parameters) { - $types = $this->types; + $types = [SegmentEntity::TYPE_DEFAULT, SegmentEntity::TYPE_WP_USERS]; if ($this->wooCommerce->shouldShowWooCommerceSegment()) { $types[] = SegmentEntity::TYPE_WC_USERS; }