<?php

namespace AutoAdmin\Bundle\Media\Model;

use AutoAdmin\Bundle\Content\Entity\Traits\CreatedAtTrait;
use AutoAdmin\Bundle\Content\Entity\Traits\IdTrait;
use AutoAdmin\Bundle\Content\Entity\Traits\UpdatedAtTrait;
use AutoAdmin\Bundle\Content\Model\CreatedAtInterface;
use AutoAdmin\Bundle\Content\Model\UpdatedAtInterface;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class MediaModel
 *
 * @package AutoAdmin\Bundle\Media\Model
 */
#[ORM\MappedSuperclass]
abstract class AbstractMedia implements
    CreatedAtInterface,
    UpdatedAtInterface,
    MediaInterface
{
    use IdTrait;
    use CreatedAtTrait;
    use UpdatedAtTrait;

    /**
     * Used for detecting related file changes
     */
    #[ORM\Column(type: Types::INTEGER)]
    protected int $mediaChangedAt = 0;

    #[ORM\Column(type: Types::STRING)]
    protected string $mapping = 'default';

    #[ORM\Column(type: Types::JSON)]
    protected array $mappingConfig = [];

    public function __construct()
    {
        $this->createdAt = new DateTime();
    }

    public function getId(): mixed
    {
        return $this->id;
    }

    public function getMediaChangedAt(): mixed
    {
        return $this->mediaChangedAt;
    }

    public function setMediaChangedAt(mixed $mediaChangedAt): void
    {
        $this->mediaChangedAt = $mediaChangedAt;
    }

    public function getMapping(): string
    {
        return $this->mapping;
    }

    public function setMapping(string $mapping): void
    {
        $this->mapping = $mapping;
    }

    public function getMappingConfig(): array
    {
        return $this->mappingConfig;
    }

    public function setMappingConfig(array $mappingConfig): void
    {
        $this->mappingConfig = $mappingConfig;
    }
}
