src/Entity/Notification.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NotificationRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Blameable\Traits\BlameableEntity;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassNotificationRepository::class)]
  11. #[UniqueEntity('key')]
  12. class Notification
  13. {
  14.     use TimestampableEntity//Hook timestampable behavior. Updates createdAt, updatedAt fields 
  15.     use BlameableEntity//Hook blameable behavior. Updates createdBy, updatedBy fields
  16.     const NOTIFICATION_TYPE_EMAIL 'EMAIL_NOTIFICATION';
  17.     const ORDER_CREATED "ORDER_CREATED";
  18.     const USER_REGISTERED "USER_REGISTERED";
  19.     const ON_RESET_PASSWORD "ON_RESET_PASSWORD";
  20.     const EXECUTE_AUTHORIZATION_PAYMENT "EXECUTE_AUTHORIZATION_PAYMENT";
  21.     const CANCEL_PREAUTHORIZATION_PAYMENT "CANCEL_PREAUTHORIZATION_PAYMENT";
  22.     const NEW_RETURN "NEW_RETURN";
  23.     const NEW_FRIEND "NEW_FRIEND";
  24.     const ON_USER_DEACTIVATION "ON_USER_DEACTIVATION";
  25.     const CANCEL_CHILDREN_ORDER "CANCEL_CHILDREN_ORDER";
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue(strategy"IDENTITY")]
  28.     #[ORM\Column]
  29.     private ?int $id null;
  30.     #[ORM\Column(length100uniquetrue)]
  31.     #[Assert\NotNull()]
  32.     #[Assert\Length(max100)]
  33.     private ?string $key null;
  34.     #[ORM\Column(length50)]
  35.     #[Assert\NotNull()]
  36.     #[Assert\Length(max50)]
  37.     private ?string $type null;
  38.     #[ORM\Column]
  39.     #[Assert\NotNull()]
  40.     private ?bool $active true;
  41.     #[ORM\Column(length255)]
  42.     private ?string $title null;
  43.     #[ORM\Column(typeTypes::TEXT)]
  44.     private ?string $body null;
  45.     public function __toString()
  46.     {
  47.         return $this->getKey();
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getKey(): ?string
  54.     {
  55.         return $this->key;
  56.     }
  57.     public function setKey(string $key): self
  58.     {
  59.         $this->key $key;
  60.         return $this;
  61.     }
  62.     public function getType(): ?string
  63.     {
  64.         return $this->type;
  65.     }
  66.     public function setType(string $type): self
  67.     {
  68.         $this->type $type;
  69.         return $this;
  70.     }
  71.     public function isActive(): ?bool
  72.     {
  73.         return $this->active;
  74.     }
  75.     public function setActive(bool $active): self
  76.     {
  77.         $this->active $active;
  78.         return $this;
  79.     }
  80.     public function getTitle(): ?string
  81.     {
  82.         return $this->title;
  83.     }
  84.     public function getReplacedTitle($replacements): ?string
  85.     {     
  86.         return str_replace(array_keys($replacements), array_values($replacements), $this->title);
  87.     }
  88.     public function setTitle(string $title): self
  89.     {
  90.         $this->title $title;
  91.         return $this;
  92.     }
  93.     public function getBody(): ?string
  94.     {
  95.         return $this->body;
  96.     }
  97.     public function getReplacedBody($replacements): ?string
  98.     {
  99.         return str_replace(array_keys($replacements), array_values($replacements), $this->body);
  100.     }
  101.     public function setBody(string $body): self
  102.     {
  103.         $this->body $body;
  104.         return $this;
  105.     }
  106. }