request->getParam('controller')); $action = \Cake\Utility\Inflector::variable($this->request->getParam('action')); $currentURL = "/{$controller}/{$action}"; if ($url == $currentURL) { $active = true; } $hasActiveChild = false; if (!empty($children)) { $flattened = Cake\Utility\Hash::flatten($children); $flattenedValues = array_values($flattened); if (in_array($currentURL, $flattenedValues)) { $hasActiveChild = true; } } $severity = [ 'primary' => -1, 'info' => 0, 'warning' => 1, 'danger' => 2, ]; $hasNotification = false; $childHasNotification = false; $maxSeverity = -1; $childMaxSeverity = -1; $notificationAmount = 0; foreach ($children as $childName => $child) { // children notification foreach ($notifications as $notification) { if (!empty($notification['_sidebarId']) && $notification['_sidebarId'] == $childName) { $childHasNotification = true; $childMaxSeverity = max($childMaxSeverity, $severity[$notification['variant']] ?? 0); } } } foreach ($notifications as $notification) { // leaf notification if (!empty($notification['_sidebarId']) && $notification['_sidebarId'] == $parentName) { $hasNotification = true; $maxSeverity = max($maxSeverity, $severity[$notification['variant']] ?? 0); $notificationAmount += 1; } } $notificationVariant = array_flip($severity)[$maxSeverity]; $childNotificationVariant = array_flip($severity)[$childMaxSeverity]; ?>