protected function _buildResultMap($fetchQuery, $options)
{
$resultMap = [];
$key = (array) $options['foreignKey'];
$hydrated = $fetchQuery->hydrate();
foreach ($fetchQuery->all() as $result) {
if (!isset($result[$this->_junctionProperty])) {
throw new RuntimeException(sprintf('"%s" is missing from the belongsToMany results. Results cannot be created.', $this->_junctionProperty));
}
$values = [];
foreach ($key as $k) {
$values[] = $result[$this->_junctionProperty][$k];
}
$resultMap[implode(';', $values)][] = $result;
}
return $resultMap;
}