array_merge($this->getWonStageList(), $this->getLostStageList()) ); } protected function filterWon(&$result) { $result['whereClause'][] = array( 'stage=' => $this->getWonStageList() ); } protected function filterLost(&$result) { $result['whereClause'][] = array( 'stage=' => $this->getLostStageList() ); } protected function getLostStageList() { $lostStageList = []; $probabilityMap = $this->getMetadata()->get(['entityDefs', 'Opportunity', 'fields', 'stage', 'probabilityMap'], []); $stageList = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []); foreach ($stageList as $stage) { if (empty($probabilityMap[$stage])) { $lostStageList[] = $stage; } } return $lostStageList; } protected function getWonStageList() { $wonStageList = []; $probabilityMap = $this->getMetadata()->get(['entityDefs', 'Opportunity', 'fields', 'stage', 'probabilityMap'], []); $stageList = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options', []); foreach ($stageList as $stage) { if (!empty($probabilityMap[$stage]) && $probabilityMap[$stage] == 100) { $wonStageList[] = $stage; } } return $wonStageList; } }