<?php

namespace App\Entity;

use App\Entity\Content\Status;
use App\Entity\Traits\TimestampableTrait;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use Doctrine\ORM\Mapping\DiscriminatorMap;
use Doctrine\ORM\Mapping\InheritanceType;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Entity()
 * @ORM\Table("event_log")
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"content" = "EventLogContent"})
 */
abstract class EventLogAbstract implements BroadcastableInterface
{
    use TimestampableTrait;

    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\User")
     * @ORM\JoinColumn(onDelete="CASCADE")
     * @Gedmo\Blameable(on="create")
     */
    private $createdBy;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\User")
     * @ORM\JoinColumn(onDelete="CASCADE")
     */
    private $oldUser;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\User")
     * @ORM\JoinColumn(onDelete="CASCADE")
     */
    private $newUser;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Content\Status")
     */
    private $oldStatus;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Content\Status")
     */
    private $newStatus;

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

    public function getCreatedBy(): ?User
    {
        return $this->createdBy;
    }

    public function setCreatedBy(?User $createdBy): self
    {
        $this->createdBy = $createdBy;

        return $this;
    }

    public function getOldUser(): ?User
    {
        return $this->oldUser;
    }

    public function setOldUser(?User $oldUser): self
    {
        $this->oldUser = $oldUser;

        return $this;
    }

    public function getNewUser(): ?User
    {
        return $this->newUser;
    }

    public function setNewUser(?User $newUser): self
    {
        $this->newUser = $newUser;

        return $this;
    }

    public function getOldStatus(): ?Status
    {
        return $this->oldStatus;
    }

    public function setOldStatus(?Status $oldStatus): self
    {
        $this->oldStatus = $oldStatus;

        return $this;
    }

    public function getNewStatus(): ?Status
    {
        return $this->newStatus;
    }

    public function setNewStatus(?Status $newStatus): self
    {
        $this->newStatus = $newStatus;

        return $this;
    }

    public function getDataType(): String
    {
        return 'eventlog';
    }
}
