public function subgridConfig($statusVariables, $depthLimit = null)
{
$depth = Status::depth($statusVariables);
if ($depthLimit !== null && $depthLimit < $depth) {
$depth = $depthLimit;
}
$config = $this->config;
for ($i = 1; $i < $depth; $i++) {
$found = false;
foreach ($config['fields'] as $field) {
if (!empty($field['type']) && $field['type'] == 'Grid' && $field['gridId'] == $statusVariables['gridId' . $i]) {
$config = $field['config'];
$found = true;
break;
}
}
if (!$found) {
throw new \Ip\Exception('Unknown subgrid');
}
}
return new self($config);
}