public function mapPk($query, $pk)
{
foreach ($this->primaryKeys as $key) {
$filter = 'filterBy' . ucfirst($key);
if (!isset($pk[$key])) {
throw new \Exception(sprintf('Primary key %s not found.', $key));
}
$value = $pk[$key];
if (method_exists($query, $filter)) {
$query->{$filter}($value);
}
}
}