<?php

namespace App\Dto\Output;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use App\Entity\View;
use Symfony\Component\Serializer\Annotation\Groups;

#[Get(shortName: 'View')]
final class ViewOutput extends AbstractOutput
{
    #[Groups(['view:read'])]
    #[ApiProperty(
        description: 'El nombre de la vista',
        example: 'Mi Vista Personalizada'
    )]
    public string $name;

    #[Groups(['view:read'])]
    #[ApiProperty(
        description: 'Indica si es una vista favorita',
        example: true
    )]
    public bool $favorite;

    #[Groups(['view:read'])]
    #[ApiProperty(
        description: 'Los filtros aplicados en la vista',
        example: []
    )]
    public ?array $filters = null;

    public function __construct(View $view)
    {
        parent::__construct($view);

        $this->name = $view->getName();
        $this->favorite = $view->isFavourite();
        $this->filters = $view->getFilters();
    }
}