EnablableEntityTrait.php 574 Bytes
Newer Older
Julien Jorry committed
1 2 3 4 5 6
<?php

namespace App\Entity\EntityTrait;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
7
use Symfony\Component\Validator\Constraints as Assert;
Julien Jorry committed
8 9 10 11

trait EnablableEntityTrait
{
    /**
12
     * @var bool
Julien Jorry committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26
     * @Assert\Type("bool")
     * @ORM\Column(type="boolean")
     * @Groups({"read", "write"})
     */
    protected $enabled = true;

    public function isEnabled(): bool
    {
        return $this->enabled;
    }

    public function setEnabled(bool $enabled)
    {
        $this->enabled = $enabled;
27

Julien Jorry committed
28 29 30
        return $this;
    }
}