public function __construct(string
$entity, ModelManager
$entityManager, CustomerStreamRepositoryInterface
$repository) { parent::
__construct($entity,
$entityManager);
$this->repository =
$repository;
} public function getList($identifiers) { $customerStreams = parent::
getList($identifiers);
$identifiers =
array_map('\intval',
$identifiers);
$customerAndNewsletterCountByStream =
$this->repository->
fetchStreamsCustomerCount($identifiers);
foreach ($customerStreams as &
$customerStream) { $id =
(int) $customerStream['id'
];
if (\
array_key_exists($id,
$customerAndNewsletterCountByStream)) { $customerStream =
array_merge($customerStream,
$customerAndNewsletterCountByStream[$id]);
} else { $customerStream['customer_count'
] = 0;
$customerStream['newsletter_count'
] = 0;
} }