diff --git a/app/Http/Controllers/DeviceController.php b/app/Http/Controllers/DeviceController.php index 75fc5e54bd68..f7bb44deff65 100644 --- a/app/Http/Controllers/DeviceController.php +++ b/app/Http/Controllers/DeviceController.php @@ -90,7 +90,7 @@ public function index(Request $request, $device, $current_tab = 'overview', $var $data = $tabs[$current_tab]->data($device); // Device Link Menu, select the primary link - $device_links = $this->deviceLinkMenu($device, $current_tab); + $device_links = $this->deviceLinkMenu($device); $primary_device_link_name = Config::get('html.device.primary_link', 'edit'); if (! isset($device_links[$primary_device_link_name])) { $primary_device_link_name = array_key_first($device_links); @@ -150,33 +150,15 @@ private function buildDeviceGraphArrays($device) return $graphs; } - private function deviceLinkMenu(Device $device, string $current_tab): array + private function deviceLinkMenu(Device $device) { $device_links = []; if (Gate::allows('update', $device)) { - $suffix = 'edit'; - $title = __('Edit'); - - // check if metric has more specific edit page - if (preg_match('#health/metric=(\w+)#', \Request::path(), $matches)) { - if ($this->editTabExists($matches[1])) { - $current_tab = $matches[1]; - } elseif ($this->editTabExists($matches[1] . 's')) { - $current_tab = $matches[1] . 's'; - } - } - - // check if edit page exists - if ($this->editTabExists($current_tab)) { - $suffix .= "/section=$current_tab"; - $title .= ' ' . ucfirst($current_tab); - } - $device_links['edit'] = [ 'icon' => 'fa-gear', - 'url' => route('device', [$device->device_id, $suffix]), - 'title' => $title, + 'url' => route('device', [$device->device_id, 'edit']), + 'title' => __('Edit'), 'external' => false, ]; } @@ -230,9 +212,4 @@ private function deviceLinkMenu(Device $device, string $current_tab): array return $device_links; } - - private function editTabExists(string $tab): bool - { - return is_file(base_path("includes/html/pages/device/edit/$tab.inc.php")); - } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index adc501dd7cac..f1794b1910df 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7115,6 +7115,11 @@ parameters: count: 1 path: app/Http/Controllers/DeviceController.php + - + message: "#^Method App\\\\Http\\\\Controllers\\\\DeviceController\\:\\:deviceLinkMenu\\(\\) has no return type specified\\.$#" + count: 1 + path: app/Http/Controllers/DeviceController.php + - message: "#^Method App\\\\Http\\\\Controllers\\\\DeviceController\\:\\:index\\(\\) has no return type specified\\.$#" count: 1