2024-03-13 16:54:10 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\BlueprintFramework\Controllers;
|
|
|
|
|
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
2024-03-13 16:59:45 -04:00
|
|
|
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
2024-03-19 12:34:45 -04:00
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
2024-03-13 16:54:10 -04:00
|
|
|
|
|
|
|
class ExtensionConfigurationController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* BlueprintExtensionController constructor.
|
|
|
|
*/
|
2024-03-19 12:34:45 -04:00
|
|
|
public function __construct(private SettingsRepositoryInterface $settings,) {}
|
2024-03-13 16:54:10 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
2024-03-13 16:59:45 -04:00
|
|
|
public function update(ExtensionConfigurationRequest $request): RedirectResponse
|
2024-03-13 16:54:10 -04:00
|
|
|
{
|
2024-03-19 12:58:06 -04:00
|
|
|
foreach ($request->normalize() as $key => $value) { $this->settings->set('blueprint::extensionconfig_' . $key, $value); }
|
2024-03-13 16:54:10 -04:00
|
|
|
return redirect()->route('admin.extensions.'.$request->input('_identifier', 'blueprint').'.index');
|
|
|
|
}
|
2024-03-13 16:59:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class ExtensionConfigurationRequest extends AdminFormRequest
|
|
|
|
{
|
|
|
|
public function rules(): array {
|
|
|
|
return [
|
2024-03-19 12:34:45 -04:00
|
|
|
$this->input('_identifier', 'blueprint').'_adminlayouts' => 'boolean',
|
|
|
|
$this->input('_identifier', 'blueprint').'_dashboardwrapper' => 'boolean',
|
2024-03-13 16:59:45 -04:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attributes(): array {
|
|
|
|
return [
|
2024-03-19 12:34:45 -04:00
|
|
|
$this->input('_identifier', 'blueprint').'_adminlayouts' => 'admin layouts permission',
|
|
|
|
$this->input('_identifier', 'blueprint').'_dashboardwrapper' => 'dashboard wrapper permission',
|
2024-03-13 16:59:45 -04:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|