Move dynamic segments from Premium plugin
[MAILPOET-2382]
This commit is contained in:
committed by
Jack Kitterhing
parent
0af9f09f50
commit
70a89b7939
23
lib/DynamicSegments/Persistence/Loading/SubscribersCount.php
Normal file
23
lib/DynamicSegments/Persistence/Loading/SubscribersCount.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Premium\DynamicSegments\Persistence\Loading;
|
||||
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Premium\Models\DynamicSegment;
|
||||
|
||||
class SubscribersCount {
|
||||
|
||||
/**
|
||||
* @param DynamicSegment $dynamic_segment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getSubscribersCount(DynamicSegment $dynamic_segment) {
|
||||
$orm = Subscriber::selectExpr('count(distinct ' . Subscriber::$_table . '.id) as cnt');
|
||||
foreach ($dynamic_segment->getFilters() as $filter) {
|
||||
$orm = $filter->toSql($orm);
|
||||
}
|
||||
return $orm->findOne()->cnt;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user