getListings($data, $segment ?: null); } private function getListings($data, Segment $segment = null) { if(!$segment || $segment->type === Segment::TYPE_DEFAULT || $segment->type === Segment::TYPE_WP_USERS) { $listing = new Handler('\MailPoet\Models\Subscriber', $data); return $listing_data = $listing->get(); } $handlers = Hooks::applyFilters('mailpoet_get_subscribers_listings_in_segment_handlers', array()); foreach($handlers as $handler) { $listings = $handler->get($segment, $data); if($listings) { return $listings; } } throw new \InvalidArgumentException('No handler found for segment'); } }