public function handleRedirect($route, $parentAssociation, $id = null, $responseCode)
{
$params = array();
if ($id && null_or_empty($parentAssociation)) {
$route = explode('.', $route)[0] . '.' . self::ACTION_EDIT;
$params = array($id);
} elseif ($id && !null_or_empty($parentAssociation)) {
$parent = explode('.', $route)[0];
$child = explode('.', $route)[1];
$route = $parent . '.' . $child . '.' . self::ACTION_EDIT;
$params = array_values(array_merge($parentAssociation, array($id)));
} elseif (is_null($id) && !null_or_empty($parentAssociation)) {
$parent = explode('.', $route)[0];
$child = explode('.', $route)[1];
$route = $parent . '.' . $child . '.' . self::ACTION_SHOW;
$params = array_values($parentAssociation);
} elseif (is_null($id) && null_or_empty($parentAssociation)) {
$route = explode('.', $route)[0] . '.' . self::ACTION_SHOW;
$params = array();
} else {
throw new InvalidArgumentException("incorrect format");
}
//handle error responses
return $this->redirect->route($route, $params);
}