protected function taskInstallDependenciesOfPackages() { $data = $this->post; $packages = isset($data['packages']) ? explode(',', $data['packages']) : ''; $packages = (array) $packages; $type = isset($data['type']) ? $data['type'] : ''; if (!$this->authorizeTask('install ' . $type, ['admin.' . $type, 'admin.super'])) { $this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')]; return false; } require_once __DIR__ . '/gpm.php'; try { $dependencies = $this->admin->getDependenciesNeededToInstall($packages); } catch (\Exception $e) { $this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()]; return; } $result = \Grav\Plugin\Admin\Gpm::install(array_keys($dependencies), ['theme' => $type == 'theme']); if ($result) { $this->admin->json_response = ['status' => 'success', 'message' => 'Dependencies installed successfully']; } else { $this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INSTALLATION_FAILED')]; } return true; }