58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\ApiResource;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\Put;
|
|
use App\State\ShareSettingsProcessor;
|
|
use App\State\ShareSettingsProvider;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
|
|
#[ApiResource(
|
|
operations: [
|
|
new Get(
|
|
uriTemplate: '/settings/share',
|
|
normalizationContext: ['groups' => ['share_settings:read']],
|
|
provider: ShareSettingsProvider::class,
|
|
security: "is_granted('ROLE_ADMIN')",
|
|
),
|
|
new Put(
|
|
uriTemplate: '/settings/share',
|
|
denormalizationContext: ['groups' => ['share_settings:write']],
|
|
normalizationContext: ['groups' => ['share_settings:read']],
|
|
provider: ShareSettingsProvider::class,
|
|
processor: ShareSettingsProcessor::class,
|
|
security: "is_granted('ROLE_ADMIN')",
|
|
),
|
|
],
|
|
)]
|
|
final class ShareSettings
|
|
{
|
|
#[Groups(['share_settings:read', 'share_settings:write'])]
|
|
public ?string $host = null;
|
|
|
|
#[Groups(['share_settings:read', 'share_settings:write'])]
|
|
public ?string $shareName = null;
|
|
|
|
#[Groups(['share_settings:read', 'share_settings:write'])]
|
|
public ?string $basePath = null;
|
|
|
|
#[Groups(['share_settings:read', 'share_settings:write'])]
|
|
public ?string $domain = null;
|
|
|
|
#[Groups(['share_settings:read', 'share_settings:write'])]
|
|
public ?string $username = null;
|
|
|
|
#[Groups(['share_settings:write'])]
|
|
public ?string $password = null;
|
|
|
|
#[Groups(['share_settings:read', 'share_settings:write'])]
|
|
public bool $enabled = false;
|
|
|
|
#[Groups(['share_settings:read'])]
|
|
public bool $hasPassword = false;
|
|
}
|