/** * @param array $ownerIds * @param array $opportunityHistory * @param Opportunity $opportunity * * @return bool */ protected function isOwnerOk($ownerIds, $opportunityHistory, $opportunity) { $userRepository = $this->getEntityManager()->getRepository('OroUserBundle:User'); if ($oldOwner = $this->getHistoryOldValue($opportunityHistory, 'owner')) { $isOwnerOk = in_array($userRepository->findOneByUsername($oldOwner)->getId(), $ownerIds); } else { $isOwnerOk = in_array($opportunity->getOwner()->getId(), $ownerIds); } return $isOwnerOk; }