1: <?php
2: namespace TIC\DormBundle\Traits;
3:
4: use Doctrine\ORM\Mapping as ORM;
5:
6: /**
7: * Gestion d'un champs d'activation sur une entité Doctrine.
8: */
9: trait EntityEnabled
10: {
11: /**
12: * @ORM\Column(type="boolean", options={"default"=true})
13: */
14: private $enabled = true;
15:
16: // --------------------------------------------------------------------- Shortcut methods
17:
18: /**
19: * Get the enabled state.
20: */
21: public function isEnabled(): bool
22: {
23: return $this->enabled ? true : false;
24: }
25:
26: // --------------------------------------------------------------------- Accessors (getters)
27:
28: /**
29: * Get the enabled state.
30: */
31: public function getEnabled(): ?bool
32: {
33: return $this->enabled;
34: }
35:
36: // --------------------------------------------------------------------- Mutators (setters)
37:
38: /**
39: * Set the enabled state.
40: */
41: public function setEnabled(?bool $enabled): self
42: {
43: $this->enabled = $enabled;
44: return $this;
45: }
46:
47: }
48: